Skip to content

Commit

Permalink
Add resolveAll to the ConflictResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorflg committed Oct 3, 2024
1 parent bfe0cae commit 45428dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added
- resolveAll to `MineWinsConflictsResolver` to handle an array of conflicts.

## [6.47.0] - 2024-06-11
### Added
- Add option to save asynchronous cache
Expand Down
15 changes: 15 additions & 0 deletions src/utils/MineWinsConflictsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ 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
})
}

protected mergeMineWins(base: Configuration, master: Configuration, mine: Configuration) {
if (isArray(master)) {
return this.mergeMineWinsArray((base || []) as ConfigurationData[], master, (mine || []) as ConfigurationData[])
Expand Down

0 comments on commit 45428dc

Please sign in to comment.