chore: add sync backoff mechanism checks (#2786)
This commit is contained in:
@@ -145,6 +145,8 @@ import {
|
||||
IsVaultAdmin,
|
||||
IsReadonlyVaultMember,
|
||||
DesignateSurvivor,
|
||||
SyncBackoffService,
|
||||
SyncBackoffServiceInterface,
|
||||
} from '@standardnotes/services'
|
||||
import { ItemManager } from '../../Services/Items/ItemManager'
|
||||
import { PayloadManager } from '../../Services/Payloads/PayloadManager'
|
||||
@@ -1351,6 +1353,10 @@ export class Dependencies {
|
||||
)
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.SyncBackoffService, () => {
|
||||
return new SyncBackoffService()
|
||||
})
|
||||
|
||||
this.factory.set(TYPES.SyncService, () => {
|
||||
return new SyncService(
|
||||
this.get<ItemManager>(TYPES.ItemManager),
|
||||
@@ -1369,6 +1375,7 @@ export class Dependencies {
|
||||
this.get<Logger>(TYPES.Logger),
|
||||
this.get<WebSocketsService>(TYPES.WebSocketsService),
|
||||
this.get<SyncFrequencyGuardInterface>(TYPES.SyncFrequencyGuard),
|
||||
this.get<SyncBackoffServiceInterface>(TYPES.SyncBackoffService),
|
||||
this.get<InternalEventBus>(TYPES.InternalEventBus),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -30,6 +30,7 @@ export const TYPES = {
|
||||
SubscriptionManager: Symbol.for('SubscriptionManager'),
|
||||
HistoryManager: Symbol.for('HistoryManager'),
|
||||
SyncFrequencyGuard: Symbol.for('SyncFrequencyGuard'),
|
||||
SyncBackoffService: Symbol.for('SyncBackoffService'),
|
||||
SyncService: Symbol.for('SyncService'),
|
||||
ProtectionService: Symbol.for('ProtectionService'),
|
||||
UserService: Symbol.for('UserService'),
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user