mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-05 00:41:15 +02: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"
|
[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'">
|
||||||
|
|
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user