1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-27 17:18:04 +01:00

[Account switching] Hide active account (#1241)

* Hide active account from dropdown

* No longer need to check if selected account is active before switching

* Applied feedback from PR review
This commit is contained in:
Daniel James Smith 2022-01-18 21:43:14 +01:00 committed by GitHub
parent 3cacf8a8c4
commit 8b521aa35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 6 deletions

View File

@ -27,7 +27,7 @@
[cdkConnectedOverlayHasBackdrop]="true" [cdkConnectedOverlayHasBackdrop]="true"
[cdkConnectedOverlayBackdropClass]="'cdk-overlay-transparent-backdrop'" [cdkConnectedOverlayBackdropClass]="'cdk-overlay-transparent-backdrop'"
(backdropClick)="toggle()" (backdropClick)="toggle()"
[cdkConnectedOverlayOpen]="isOpen" [cdkConnectedOverlayOpen]="showSwitcher && isOpen"
cdkConnectedOverlayMinWidth="250px" cdkConnectedOverlayMinWidth="250px"
> >
<div class="account-switcher-dropdown" [@transformPanel]="'open'"> <div class="account-switcher-dropdown" [@transformPanel]="'open'">

View File

@ -7,6 +7,7 @@ import { StateService } from "jslib-common/abstractions/state.service";
import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service"; import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service";
import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus"; import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus";
import { Utils } from "jslib-common/misc/utils";
import { Account } from "jslib-common/models/domain/account"; import { Account } from "jslib-common/models/domain/account";
@ -56,7 +57,7 @@ export class AccountSwitcherComponent implements OnInit {
serverUrl: string; serverUrl: string;
get showSwitcher() { get showSwitcher() {
return this.accounts != null && Object.keys(this.accounts).length > 0; return !Utils.isNullOrWhitespace(this.activeAccountEmail);
} }
constructor( constructor(
@ -91,9 +92,6 @@ export class AccountSwitcherComponent implements OnInit {
async switch(userId: string) { async switch(userId: string) {
this.toggle(); this.toggle();
if (userId === (await this.stateService.getUserId())) {
return;
}
this.messagingService.send("switchAccount", { userId: userId }); this.messagingService.send("switchAccount", { userId: userId });
} }
@ -102,9 +100,10 @@ export class AccountSwitcherComponent implements OnInit {
}): Promise<{ [userId: string]: SwitcherAccount }> { }): Promise<{ [userId: string]: SwitcherAccount }> {
const switcherAccounts: { [userId: string]: SwitcherAccount } = {}; const switcherAccounts: { [userId: string]: SwitcherAccount } = {};
for (const userId in baseAccounts) { for (const userId in baseAccounts) {
if (userId == null) { if (userId == null || userId === (await this.stateService.getUserId())) {
continue; continue;
} }
// environmentUrls are stored on disk and must be retrieved seperatly from the in memory state offered from subscribing to accounts // environmentUrls are stored on disk and must be retrieved seperatly from the in memory state offered from subscribing to accounts
baseAccounts[userId].settings.environmentUrls = await this.stateService.getEnvironmentUrls({ baseAccounts[userId].settings.environmentUrls = await this.stateService.getEnvironmentUrls({
userId: userId, userId: userId,