Skip to content

Commit

Permalink
Avoid using async/await with then callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorflg authored and iagoaraujo committed Oct 23, 2024
1 parent 2c299e3 commit 1c052c4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/utils/MineWinsConflictsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,17 @@ export class MineWinsConflictsResolver<T> implements ConflictsResolver<T> {
}

public async resolveAll() {
return await this.client.getConflicts<AxiosResponse<VBaseConflictData[]>>(this.bucket).then((data) => {
const { data: conflicts }: { data: VBaseConflictData[] } = data

const resolved = conflicts.map((conflict) => {
conflict.base.parsedContent = this.parseConflict(conflict.base)
conflict.master.parsedContent = this.parseConflict(conflict.master)
conflict.mine.parsedContent = this.parseConflict(conflict.mine)
return this.resolveConflictMineWins(conflict)
})

return resolved as any
const conflictsResponse = await this.client.getConflicts<AxiosResponse<VBaseConflictData[]>>(this.bucket)
const { data: conflicts }: { data: VBaseConflictData[] } = conflictsResponse

const resolvedConflicts = conflicts.map((conflict) => {
conflict.base.parsedContent = this.parseConflict(conflict.base)
conflict.master.parsedContent = this.parseConflict(conflict.master)
conflict.mine.parsedContent = this.parseConflict(conflict.mine)
return this.resolveConflictMineWins(conflict)
})

return resolvedConflicts
}

protected mergeMineWins(base: Configuration, master: Configuration, mine: Configuration) {
Expand Down

0 comments on commit 1c052c4

Please sign in to comment.