diff --git a/libs/angular/src/key-management/encrypted-migration/encrypted-migrations-scheduler.service.ts b/libs/angular/src/key-management/encrypted-migration/encrypted-migrations-scheduler.service.ts index f78c70f7c9f..42b3ddf2588 100644 --- a/libs/angular/src/key-management/encrypted-migration/encrypted-migrations-scheduler.service.ts +++ b/libs/angular/src/key-management/encrypted-migration/encrypted-migrations-scheduler.service.ts @@ -1,4 +1,4 @@ -import { combineLatest, map, switchMap, of, firstValueFrom, filter, tap, delay } from "rxjs"; +import { combineLatest, switchMap, of, firstValueFrom, filter, delay, concatMap } from "rxjs"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service"; @@ -28,11 +28,6 @@ export const ENCRYPTED_MIGRATION_DISMISSED = new UserKeyDefinition( ); const DISMISS_TIME_HOURS = 24; -type UserSyncData = { - userId: UserId; - lastSync: Date | null; -}; - /** * This services schedules encrypted migrations for users on clients that are interactive (non-cli), and handles manual interaction, * if it is required by showing a UI prompt. It is only one means of triggering migrations, in case the user stays unlocked for a while, @@ -71,9 +66,8 @@ export class DefaultEncryptedMigrationsSchedulerService this.syncService.lastSync$(userId).pipe(filter((lastSync) => lastSync != null)), ]).pipe( filter(([authStatus]) => authStatus === AuthenticationStatus.Unlocked), - map(([, lastSync]) => ({ userId, lastSync }) as UserSyncData), delay(5_000), - tap(({ userId }) => this.runMigrationsIfNeeded(userId)), + concatMap(() => this.runMigrationsIfNeeded(userId)), ), ), );