chore: add sync backoff mechanism checks (#2786)

This commit is contained in:
Karol Sójko
2024-01-23 09:04:55 +01:00
committed by GitHub
parent 2757884d10
commit ba236a2f2b
7 changed files with 115 additions and 1 deletions

View File

@@ -86,6 +86,7 @@ import {
ApplicationSyncOptions,
WebSocketsServiceEvent,
WebSocketsService,
SyncBackoffServiceInterface,
} from '@standardnotes/services'
import { OfflineSyncResponse } from './Offline/Response'
import {
@@ -171,6 +172,7 @@ export class SyncService
private logger: LoggerInterface,
private sockets: WebSocketsService,
private syncFrequencyGuard: SyncFrequencyGuardInterface,
private syncBackoffService: SyncBackoffServiceInterface,
protected override internalEventBus: InternalEventBusInterface,
) {
super(internalEventBus)
@@ -452,7 +454,11 @@ export class SyncService
}
private itemsNeedingSync() {
return this.itemManager.getDirtyItems()
const dirtyItems = this.itemManager.getDirtyItems()
const itemsWithoutBackoffPenalty = dirtyItems.filter((item) => !this.syncBackoffService.isItemInBackoff(item))
return itemsWithoutBackoffPenalty
}
public async markAllItemsAsNeedingSyncAndPersist(): Promise<void> {