-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-14366] Deprecated active user state from billing state service #12273
base: main
Are you sure you want to change the base?
Changes from 16 commits
79f0f64
056fbfe
e943dc9
79e02e1
5f5d38e
4643a64
e9d9ec9
8232a72
55e6f24
39c8a0d
f9f4ceb
ad0c18e
bc9dc37
62662e3
85af1e6
a9d072c
5f03ba7
6a69690
d6c1494
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,17 @@ describe("SendV2Component", () => { | |
CurrentAccountComponent, | ||
], | ||
providers: [ | ||
{ provide: AccountService, useValue: mock<AccountService>() }, | ||
{ | ||
provide: AccountService, | ||
useValue: { | ||
activeAccount$: of({ | ||
id: "123", | ||
email: "[email protected]", | ||
emailVerified: true, | ||
name: "Test User", | ||
}), | ||
}, | ||
}, | ||
{ provide: AuthService, useValue: mock<AuthService>() }, | ||
{ provide: AvatarService, useValue: mock<AvatarService>() }, | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
// FIXME: Update this file to be type safe and remove this and next line | ||
// @ts-strict-ignore | ||
import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angular/core"; | ||
import { Subject, takeUntil } from "rxjs"; | ||
import { Subject, takeUntil, switchMap } from "rxjs"; | ||
|
||
import { EventCollectionService } from "@bitwarden/common/abstractions/event/event-collection.service"; | ||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; | ||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service"; | ||
import { EventType } from "@bitwarden/common/enums"; | ||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; | ||
|
@@ -36,11 +37,17 @@ | |
private totpService: TotpServiceAbstraction, | ||
private passwordRepromptService: PasswordRepromptService, | ||
private billingAccountProfileStateService: BillingAccountProfileStateService, | ||
private accountService: AccountService, | ||
) {} | ||
|
||
ngOnInit() { | ||
this.billingAccountProfileStateService.hasPremiumFromAnySource$ | ||
.pipe(takeUntil(this.componentIsDestroyed$)) | ||
this.accountService.activeAccount$ | ||
.pipe( | ||
switchMap((account) => | ||
this.billingAccountProfileStateService.hasPremiumFromAnySource$(account.id), | ||
), | ||
takeUntil(this.componentIsDestroyed$), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. non blocking โ๏ธ this pattern for unsubscribing is outdated and we should favor using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion! I created a tech debt task here for us to handle this in a follow-up PR |
||
) | ||
.subscribe((canAccessPremium: boolean) => { | ||
this.userHasPremiumAccess = canAccessPremium; | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oo, moving this out of the loop was a good idea; thanks ๐