mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +00:00
Rework ExtensionAnonLayoutWrapperDataService to use BehaviorSubject
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
import { Observable, Subject } from "rxjs";
|
import { BehaviorSubject, Observable } from "rxjs";
|
||||||
|
|
||||||
import {
|
import { AnonLayoutWrapperData, AnonLayoutWrapperDataService , DefaultAnonLayoutWrapperDataService } from "@bitwarden/auth/angular";
|
||||||
AnonLayoutWrapperDataService,
|
|
||||||
DefaultAnonLayoutWrapperDataService,
|
|
||||||
} from "@bitwarden/auth/angular";
|
|
||||||
|
|
||||||
import { ExtensionAnonLayoutWrapperData } from "./extension-anon-layout-wrapper.component";
|
import { ExtensionAnonLayoutWrapperData } from "./extension-anon-layout-wrapper.component";
|
||||||
|
|
||||||
@@ -11,13 +8,20 @@ export class ExtensionAnonLayoutWrapperDataService
|
|||||||
extends DefaultAnonLayoutWrapperDataService
|
extends DefaultAnonLayoutWrapperDataService
|
||||||
implements AnonLayoutWrapperDataService
|
implements AnonLayoutWrapperDataService
|
||||||
{
|
{
|
||||||
protected override anonLayoutWrapperDataSubject = new Subject<ExtensionAnonLayoutWrapperData>();
|
protected anonLayoutWrapperDataSubject = new BehaviorSubject<ExtensionAnonLayoutWrapperData>(
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
anonLayoutWrapperDataObservable$ = this.anonLayoutWrapperDataSubject.asObservable();
|
||||||
|
|
||||||
override setAnonLayoutWrapperData(data: ExtensionAnonLayoutWrapperData): void {
|
anonLayoutWrapperData$(): Observable<AnonLayoutWrapperData> {
|
||||||
|
return this.anonLayoutWrapperDataObservable$;
|
||||||
|
}
|
||||||
|
|
||||||
|
setAnonLayoutWrapperData(data: ExtensionAnonLayoutWrapperData): void {
|
||||||
this.anonLayoutWrapperDataSubject.next(data);
|
this.anonLayoutWrapperDataSubject.next(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
override anonLayoutWrapperData$(): Observable<ExtensionAnonLayoutWrapperData> {
|
getAnonLayoutWrapperData$(): Observable<ExtensionAnonLayoutWrapperData> {
|
||||||
return this.anonLayoutWrapperDataSubject.asObservable();
|
return this.anonLayoutWrapperDataObservable$;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,7 @@ import { Component, OnDestroy, OnInit } from "@angular/core";
|
|||||||
import { ActivatedRoute, Data, NavigationEnd, Router, RouterModule } from "@angular/router";
|
import { ActivatedRoute, Data, NavigationEnd, Router, RouterModule } from "@angular/router";
|
||||||
import { Subject, filter, switchMap, takeUntil, tap } from "rxjs";
|
import { Subject, filter, switchMap, takeUntil, tap } from "rxjs";
|
||||||
|
|
||||||
import {
|
import { AnonLayoutComponent, AnonLayoutWrapperData } from "@bitwarden/auth/angular";
|
||||||
AnonLayoutComponent,
|
|
||||||
AnonLayoutWrapperData,
|
|
||||||
AnonLayoutWrapperDataService,
|
|
||||||
} from "@bitwarden/auth/angular";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { Icon, IconModule, Translation } from "@bitwarden/components";
|
import { Icon, IconModule, Translation } from "@bitwarden/components";
|
||||||
|
|
||||||
@@ -16,6 +12,7 @@ import { PopupHeaderComponent } from "../../../platform/popup/layout/popup-heade
|
|||||||
import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component";
|
import { PopupPageComponent } from "../../../platform/popup/layout/popup-page.component";
|
||||||
import { CurrentAccountComponent } from "../account-switching/current-account.component";
|
import { CurrentAccountComponent } from "../account-switching/current-account.component";
|
||||||
|
|
||||||
|
import { ExtensionAnonLayoutWrapperDataService } from "./extension-anon-layout-wrapper-data.service";
|
||||||
import { ExtensionBitwardenLogo } from "./extension-bitwarden-logo.icon";
|
import { ExtensionBitwardenLogo } from "./extension-bitwarden-logo.icon";
|
||||||
|
|
||||||
export interface ExtensionAnonLayoutWrapperData extends AnonLayoutWrapperData {
|
export interface ExtensionAnonLayoutWrapperData extends AnonLayoutWrapperData {
|
||||||
@@ -58,7 +55,7 @@ export class ExtensionAnonLayoutWrapperComponent implements OnInit, OnDestroy {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private extensionAnonLayoutWrapperDataService: AnonLayoutWrapperDataService,
|
private extensionAnonLayoutWrapperDataService: ExtensionAnonLayoutWrapperDataService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit(): Promise<void> {
|
async ngOnInit(): Promise<void> {
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ export class ExtensionLoginComponentService
|
|||||||
return flagEnabled("showPasswordless");
|
return flagEnabled("showPasswordless");
|
||||||
}
|
}
|
||||||
|
|
||||||
showBackButton(): void {
|
showBackButton(show: boolean): void {
|
||||||
this.extensionAnonLayoutWrapperDataService.setAnonLayoutWrapperData({ showBackButton: true });
|
this.extensionAnonLayoutWrapperDataService.setAnonLayoutWrapperData({
|
||||||
|
showBackButton: show,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export class DefaultLoginComponentService implements LoginComponentService {
|
|||||||
/**
|
/**
|
||||||
* No-op implementation of showBackButton
|
* No-op implementation of showBackButton
|
||||||
*/
|
*/
|
||||||
showBackButton(): void {
|
showBackButton(show: boolean): void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,5 +42,5 @@ export abstract class LoginComponentService {
|
|||||||
/**
|
/**
|
||||||
* Shows the back button.
|
* Shows the back button.
|
||||||
*/
|
*/
|
||||||
showBackButton: () => void;
|
showBackButton: (show: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,6 +327,8 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|||||||
pageSubtitle: this.emailFormControl.value,
|
pageSubtitle: this.emailFormControl.value,
|
||||||
pageIcon: this.Icons.WaveIcon,
|
pageIcon: this.Icons.WaveIcon,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.loginComponentService.showBackButton(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -348,8 +350,6 @@ export class LoginComponent implements OnInit, OnDestroy {
|
|||||||
this.masterPasswordInputRef?.nativeElement?.focus();
|
this.masterPasswordInputRef?.nativeElement?.focus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loginComponentService.showBackButton();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user