feat: Added a conflict resolution dialog and a Conflicts view for easier management of conflicts (#2337)

This commit is contained in:
Aman Harwara
2023-06-25 14:27:51 +05:30
committed by GitHub
parent 49d43fd14b
commit e0e9249334
48 changed files with 1201 additions and 94 deletions

View File

@@ -187,6 +187,8 @@ export abstract class Collection<
const conflictOf = element.content.conflict_of
if (conflictOf) {
this.conflictMap.establishRelationship(conflictOf, element.uuid)
} else if (this.conflictMap.getInverseRelationships(element.uuid).length > 0) {
this.conflictMap.removeFromMap(element.uuid)
}
this.referenceMap.setAllRelationships(
@@ -203,6 +205,9 @@ export abstract class Collection<
if (element.deleted) {
this.nondeletedIndex.delete(element.uuid)
if (this.conflictMap.getInverseRelationships(element.uuid).length > 0) {
this.conflictMap.removeFromMap(element.uuid)
}
} else {
this.nondeletedIndex.add(element.uuid)
}
@@ -260,4 +265,8 @@ export abstract class Collection<
remove(array, { uuid: element.uuid as never })
this.typedMap[element.content_type] = array
}
public numberOfItemsWithConflicts(): number {
return this.conflictMap.directMapSize
}
}

View File

@@ -18,7 +18,7 @@ export class TagItemsIndex implements SNIndex {
private isItemCountable = (item: ItemInterface) => {
if (isDecryptedItem(item)) {
return !item.archived && !item.trashed
return !item.archived && !item.trashed && !item.conflictOf
}
return false
}

View File

@@ -10,8 +10,9 @@ import { FilterDisplayOptions } from './DisplayOptions'
export function computeUnifiedFilterForDisplayOptions(
options: FilterDisplayOptions,
collection: ReferenceLookupCollection,
additionalFilters: ItemFilter[] = [],
): ItemFilter {
const filters = computeFiltersForDisplayOptions(options, collection)
const filters = computeFiltersForDisplayOptions(options, collection).concat(additionalFilters)
return (item: SearchableDecryptedItem) => {
return itemPassesFilters(item, filters)
@@ -74,5 +75,9 @@ export function computeFiltersForDisplayOptions(
filters.push((item) => itemMatchesQuery(item, query, collection))
}
if (!viewsPredicate?.keypathIncludesString('conflict_of')) {
filters.push((item) => !item.conflictOf)
}
return filters
}