1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-26 05:03:33 +00:00

Move lastSync State (#10272)

This commit is contained in:
Justin Baur
2024-08-06 15:01:42 -04:00
committed by GitHub
parent 887b98988a
commit dcb21c2685
22 changed files with 198 additions and 110 deletions

View File

@@ -849,6 +849,7 @@ export default class MainBackground {
this.sendService,
this.sendApiService,
messageListener,
this.stateProvider,
);
} else {
this.syncService = new DefaultSyncService(
@@ -876,6 +877,7 @@ export default class MainBackground {
this.billingAccountProfileStateService,
this.tokenService,
this.authService,
this.stateProvider,
);
this.syncServiceListener = new SyncServiceListener(
@@ -1358,7 +1360,6 @@ export default class MainBackground {
);
await Promise.all([
this.syncService.setLastSync(new Date(0), userBeingLoggedOut),
this.cryptoService.clearKeys(userBeingLoggedOut),
this.cipherService.clear(userBeingLoggedOut),
this.folderService.clear(userBeingLoggedOut),

View File

@@ -7,8 +7,11 @@ import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { MessageListener, MessageSender } from "@bitwarden/common/platform/messaging";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { FakeStateProvider, mockAccountServiceWith } from "@bitwarden/common/spec";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
import { InternalSendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
import { UserId } from "@bitwarden/common/types/guid";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service";
import { FolderApiServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder-api.service.abstraction";
@@ -18,6 +21,7 @@ import { DO_FULL_SYNC, ForegroundSyncService, FullSyncMessage } from "./foregrou
import { FullSyncFinishedMessage } from "./sync-service.listener";
describe("ForegroundSyncService", () => {
const userId = Utils.newGuid() as UserId;
const stateService = mock<StateService>();
const folderService = mock<InternalFolderService>();
const folderApiService = mock<FolderApiServiceAbstraction>();
@@ -31,6 +35,7 @@ describe("ForegroundSyncService", () => {
const sendService = mock<InternalSendService>();
const sendApiService = mock<SendApiService>();
const messageListener = mock<MessageListener>();
const stateProvider = new FakeStateProvider(mockAccountServiceWith(userId));
const sut = new ForegroundSyncService(
stateService,
@@ -46,6 +51,7 @@ describe("ForegroundSyncService", () => {
sendService,
sendApiService,
messageListener,
stateProvider,
);
beforeEach(() => {

View File

@@ -11,6 +11,7 @@ import {
MessageSender,
} from "@bitwarden/common/platform/messaging";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { StateProvider } from "@bitwarden/common/platform/state";
import { CoreSyncService } from "@bitwarden/common/platform/sync/internal";
import { SendApiService } from "@bitwarden/common/tools/send/services/send-api.service.abstraction";
import { InternalSendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
@@ -40,6 +41,7 @@ export class ForegroundSyncService extends CoreSyncService {
sendService: InternalSendService,
sendApiService: SendApiService,
private readonly messageListener: MessageListener,
stateProvider: StateProvider,
) {
super(
stateService,
@@ -54,6 +56,7 @@ export class ForegroundSyncService extends CoreSyncService {
authService,
sendService,
sendApiService,
stateProvider,
);
}