fix(syncing-server): front load themes and user prefs as high priority load items (#935)
This commit is contained in:
parent
d41dd3bdda
commit
2200dca69d
1 changed files with 10 additions and 7 deletions
|
@ -59,7 +59,7 @@ export class SyncItems implements UseCaseInterface<SyncItemsResponse> {
|
||||||
)
|
)
|
||||||
const isSharedVaultExclusiveSync = dto.sharedVaultUuids && dto.sharedVaultUuids.length > 0
|
const isSharedVaultExclusiveSync = dto.sharedVaultUuids && dto.sharedVaultUuids.length > 0
|
||||||
if (this.isFirstSync(dto) && !isSharedVaultExclusiveSync) {
|
if (this.isFirstSync(dto) && !isSharedVaultExclusiveSync) {
|
||||||
retrievedItems = await this.frontLoadKeysItemsToTop(dto.userUuid, retrievedItems)
|
retrievedItems = await this.frontLoadHighLoadingPriorityItemsToTop(dto.userUuid, retrievedItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
const sharedVaultsOrError = await this.getSharedVaultsUseCase.execute({
|
const sharedVaultsOrError = await this.getSharedVaultsUseCase.execute({
|
||||||
|
@ -139,19 +139,22 @@ export class SyncItems implements UseCaseInterface<SyncItemsResponse> {
|
||||||
return retrievedItems.filter((item: Item) => syncConflictIds.indexOf(item.id.toString()) === -1)
|
return retrievedItems.filter((item: Item) => syncConflictIds.indexOf(item.id.toString()) === -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async frontLoadKeysItemsToTop(userUuid: string, retrievedItems: Array<Item>): Promise<Array<Item>> {
|
private async frontLoadHighLoadingPriorityItemsToTop(
|
||||||
const itemsKeys = await this.itemRepository.findAll({
|
userUuid: string,
|
||||||
|
retrievedItems: Array<Item>,
|
||||||
|
): Promise<Array<Item>> {
|
||||||
|
const highPriorityItems = await this.itemRepository.findAll({
|
||||||
userUuid,
|
userUuid,
|
||||||
contentType: ContentType.TYPES.ItemsKey,
|
contentType: [ContentType.TYPES.ItemsKey, ContentType.TYPES.UserPrefs, ContentType.TYPES.Theme],
|
||||||
sortBy: 'updated_at_timestamp',
|
sortBy: 'updated_at_timestamp',
|
||||||
sortOrder: 'ASC',
|
sortOrder: 'ASC',
|
||||||
})
|
})
|
||||||
|
|
||||||
const retrievedItemsIds: Array<string> = retrievedItems.map((item: Item) => item.id.toString())
|
const retrievedItemsIds: Array<string> = retrievedItems.map((item: Item) => item.id.toString())
|
||||||
|
|
||||||
itemsKeys.forEach((itemKey: Item) => {
|
highPriorityItems.forEach((highPriorityItem: Item) => {
|
||||||
if (retrievedItemsIds.indexOf(itemKey.id.toString()) === -1) {
|
if (retrievedItemsIds.indexOf(highPriorityItem.id.toString()) === -1) {
|
||||||
retrievedItems.unshift(itemKey)
|
retrievedItems.unshift(highPriorityItem)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue