1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-08-27 23:31:41 +02:00

[PM-6426] Setting up the full sync process as an interval rather than a timeout

This commit is contained in:
Cesar Gonzalez 2024-04-01 15:24:47 -05:00
parent 83cb105b49
commit daa8916ad6
No known key found for this signature in database
GPG Key ID: 3381A5457F8CCECF

View File

@ -1053,9 +1053,13 @@ export default class MainBackground {
if (!this.isPrivateMode) {
await this.refreshBadge();
}
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.fullSync(true);
await this.fullSync(true);
await this.taskSchedulerService.setInterval(
() => this.fullSync(),
5 * 60 * 1000, // check every 5 minutes
ScheduledTaskNames.scheduleNextSyncTimeout,
);
setTimeout(() => this.notificationsService.init(), 2500);
resolve();
}, 500);
@ -1289,18 +1293,5 @@ export default class MainBackground {
if (override || lastSyncAgo >= syncInternal) {
await this.syncService.fullSync(override);
}
await this.scheduleNextSync();
}
private async scheduleNextSync() {
await this.taskSchedulerService.clearScheduledTask({
taskName: ScheduledTaskNames.scheduleNextSyncTimeout,
});
await this.taskSchedulerService.setTimeout(
() => this.fullSync(),
5 * 60 * 1000, // check every 5 minutes
ScheduledTaskNames.scheduleNextSyncTimeout,
);
}
}