mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-26 17:08:33 +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:
parent
3cacf8a8c4
commit
8b521aa35e
@ -27,7 +27,7 @@
|
||||
[cdkConnectedOverlayHasBackdrop]="true"
|
||||
[cdkConnectedOverlayBackdropClass]="'cdk-overlay-transparent-backdrop'"
|
||||
(backdropClick)="toggle()"
|
||||
[cdkConnectedOverlayOpen]="isOpen"
|
||||
[cdkConnectedOverlayOpen]="showSwitcher && isOpen"
|
||||
cdkConnectedOverlayMinWidth="250px"
|
||||
>
|
||||
<div class="account-switcher-dropdown" [@transformPanel]="'open'">
|
||||
|
@ -7,6 +7,7 @@ import { StateService } from "jslib-common/abstractions/state.service";
|
||||
import { VaultTimeoutService } from "jslib-common/abstractions/vaultTimeout.service";
|
||||
|
||||
import { AuthenticationStatus } from "jslib-common/enums/authenticationStatus";
|
||||
import { Utils } from "jslib-common/misc/utils";
|
||||
|
||||
import { Account } from "jslib-common/models/domain/account";
|
||||
|
||||
@ -56,7 +57,7 @@ export class AccountSwitcherComponent implements OnInit {
|
||||
serverUrl: string;
|
||||
|
||||
get showSwitcher() {
|
||||
return this.accounts != null && Object.keys(this.accounts).length > 0;
|
||||
return !Utils.isNullOrWhitespace(this.activeAccountEmail);
|
||||
}
|
||||
|
||||
constructor(
|
||||
@ -91,9 +92,6 @@ export class AccountSwitcherComponent implements OnInit {
|
||||
async switch(userId: string) {
|
||||
this.toggle();
|
||||
|
||||
if (userId === (await this.stateService.getUserId())) {
|
||||
return;
|
||||
}
|
||||
this.messagingService.send("switchAccount", { userId: userId });
|
||||
}
|
||||
|
||||
@ -102,9 +100,10 @@ export class AccountSwitcherComponent implements OnInit {
|
||||
}): Promise<{ [userId: string]: SwitcherAccount }> {
|
||||
const switcherAccounts: { [userId: string]: SwitcherAccount } = {};
|
||||
for (const userId in baseAccounts) {
|
||||
if (userId == null) {
|
||||
if (userId == null || userId === (await this.stateService.getUserId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 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({
|
||||
userId: userId,
|
||||
|
Loading…
Reference in New Issue
Block a user