mirror of
https://github.com/bitwarden/browser
synced 2026-02-10 13:40:06 +00:00
Refactor toast calls out of auth services. Toasts are now triggered by an observable emission that gets picked up by an observable pipeline in a new `DeviceTrustToastService` (libs/angular). That observable pipeline is then subscribed by by consuming the `AppComponent` for each client.
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { merge, Observable, tap } from "rxjs";
|
|
|
|
import { AuthRequestServiceAbstraction } from "@bitwarden/auth/common";
|
|
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
|
import { ToastService } from "@bitwarden/components";
|
|
|
|
import { DeviceTrustToastService as DeviceTrustToastServiceAbstraction } from "./device-trust-toast.service.abstraction";
|
|
|
|
export class DeviceTrustToastService implements DeviceTrustToastServiceAbstraction {
|
|
private adminLoginApproved$: Observable<void>;
|
|
private deviceTrusted$: Observable<void>;
|
|
|
|
setupListeners$: Observable<void>;
|
|
|
|
constructor(
|
|
private authRequestService: AuthRequestServiceAbstraction,
|
|
private deviceTrustService: DeviceTrustServiceAbstraction,
|
|
private i18nService: I18nService,
|
|
private toastService: ToastService,
|
|
) {
|
|
this.adminLoginApproved$ = this.authRequestService.adminLoginApproved$.pipe(
|
|
tap(() => {
|
|
this.toastService.showToast({
|
|
variant: "success",
|
|
title: "",
|
|
message: this.i18nService.t("loginApproved"),
|
|
});
|
|
}),
|
|
);
|
|
|
|
this.deviceTrusted$ = this.deviceTrustService.deviceTrusted$.pipe(
|
|
tap(() => {
|
|
this.toastService.showToast({
|
|
variant: "success",
|
|
title: "",
|
|
message: this.i18nService.t("deviceTrusted"),
|
|
});
|
|
}),
|
|
);
|
|
|
|
this.setupListeners$ = merge(this.adminLoginApproved$, this.deviceTrusted$);
|
|
}
|
|
}
|