mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
[PM-8316] Fix account switcher on logged out account on startup (#10342)
* Fix account switcher on logged out account on startup * Undo space removal * Add additional checks for null values * Fix account switching on timeout on browser
This commit is contained in:
@@ -1234,6 +1234,18 @@ export default class MainBackground {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the user is logged out, switch to the next account
|
||||||
|
const active = await firstValueFrom(this.accountService.activeAccount$);
|
||||||
|
if (active == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const authStatus = await firstValueFrom(
|
||||||
|
this.authService.authStatuses$.pipe(map((statuses) => statuses[active.id])),
|
||||||
|
);
|
||||||
|
if (authStatus === AuthenticationStatus.LoggedOut) {
|
||||||
|
const nextUpAccount = await firstValueFrom(this.accountService.nextUpAccount$);
|
||||||
|
await this.switchAccount(nextUpAccount?.id);
|
||||||
|
}
|
||||||
await this.initOverlayAndTabsBackground();
|
await this.initOverlayAndTabsBackground();
|
||||||
|
|
||||||
return new Promise<void>((resolve) => {
|
return new Promise<void>((resolve) => {
|
||||||
|
|||||||
@@ -151,6 +151,24 @@ export class AccountSwitcherComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
const active = await firstValueFrom(this.accountService.activeAccount$);
|
||||||
|
if (active == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const authStatus = await firstValueFrom(
|
||||||
|
this.authService.authStatuses$.pipe(map((statuses) => statuses[active.id])),
|
||||||
|
);
|
||||||
|
if (authStatus === AuthenticationStatus.LoggedOut) {
|
||||||
|
const nextUpAccount = await firstValueFrom(this.accountService.nextUpAccount$);
|
||||||
|
if (nextUpAccount != null) {
|
||||||
|
await this.switch(nextUpAccount.id);
|
||||||
|
} else {
|
||||||
|
await this.addAccount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
this.isOpen = !this.isOpen;
|
this.isOpen = !this.isOpen;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user