-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:bitwarden/clients
# Conflicts: # apps/desktop/src/main.ts
- Loading branch information
Showing
257 changed files
with
6,992 additions
and
1,550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
apps/browser/src/auth/background/service-factories/avatar-service.factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { AvatarService as AvatarServiceAbstraction } from "@bitwarden/common/auth/abstractions/avatar.service"; | ||
import { AvatarService } from "@bitwarden/common/auth/services/avatar.service"; | ||
|
||
import { | ||
ApiServiceInitOptions, | ||
apiServiceFactory, | ||
} from "../../../platform/background/service-factories/api-service.factory"; | ||
import { | ||
CachedServices, | ||
factory, | ||
FactoryOptions, | ||
} from "../../../platform/background/service-factories/factory-options"; | ||
import { | ||
stateProviderFactory, | ||
StateProviderInitOptions, | ||
} from "../../../platform/background/service-factories/state-provider.factory"; | ||
|
||
type AvatarServiceFactoryOptions = FactoryOptions; | ||
|
||
export type AvatarServiceInitOptions = AvatarServiceFactoryOptions & | ||
ApiServiceInitOptions & | ||
StateProviderInitOptions; | ||
|
||
export function avatarServiceFactory( | ||
cache: { avatarService?: AvatarServiceAbstraction } & CachedServices, | ||
opts: AvatarServiceInitOptions, | ||
): Promise<AvatarServiceAbstraction> { | ||
return factory( | ||
cache, | ||
"avatarService", | ||
opts, | ||
async () => | ||
new AvatarService( | ||
await apiServiceFactory(cache, opts), | ||
await stateProviderFactory(cache, opts), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 37 additions & 8 deletions
45
apps/browser/src/auth/popup/account-switching/current-account.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,61 @@ | ||
import { Location } from "@angular/common"; | ||
import { Component } from "@angular/core"; | ||
import { ActivatedRoute, Router } from "@angular/router"; | ||
import { Observable, combineLatest, switchMap } from "rxjs"; | ||
|
||
import { CurrentAccountService } from "./services/current-account.service"; | ||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; | ||
import { AvatarService } from "@bitwarden/common/auth/abstractions/avatar.service"; | ||
import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authentication-status"; | ||
import { UserId } from "@bitwarden/common/types/guid"; | ||
|
||
export type CurrentAccount = { | ||
id: UserId; | ||
name: string | undefined; | ||
email: string; | ||
status: AuthenticationStatus; | ||
avatarColor: string; | ||
}; | ||
|
||
@Component({ | ||
selector: "app-current-account", | ||
templateUrl: "current-account.component.html", | ||
}) | ||
export class CurrentAccountComponent { | ||
currentAccount$: Observable<CurrentAccount>; | ||
|
||
constructor( | ||
private currentAccountService: CurrentAccountService, | ||
private accountService: AccountService, | ||
private avatarService: AvatarService, | ||
private router: Router, | ||
private location: Location, | ||
private route: ActivatedRoute, | ||
) {} | ||
) { | ||
this.currentAccount$ = combineLatest([ | ||
this.accountService.activeAccount$, | ||
this.avatarService.avatarColor$, | ||
]).pipe( | ||
switchMap(async ([account, avatarColor]) => { | ||
if (account == null) { | ||
return null; | ||
} | ||
const currentAccount: CurrentAccount = { | ||
id: account.id, | ||
name: account.name || account.email, | ||
email: account.email, | ||
status: account.status, | ||
avatarColor, | ||
}; | ||
|
||
get currentAccount$() { | ||
return this.currentAccountService.currentAccount$; | ||
return currentAccount; | ||
}), | ||
); | ||
} | ||
|
||
async currentAccountClicked() { | ||
if (this.route.snapshot.data.state.includes("account-switcher")) { | ||
this.location.back(); | ||
} else { | ||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling. | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
this.router.navigate(["/account-switcher"]); | ||
await this.router.navigate(["/account-switcher"]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.