mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
[PS-713] Fix locale search bug (#3014)
* [PS-713] Fix locale search bug * [PS-713] Add new locales to start at 1 char search * [PS-713] Switch to ReplaySubject and other edits from PR comments * PS-713: Add destroy to other sub and make locale inline a const * PS-713: Use firstValueFrom instead of takeUntil * PS-713: get this.locale asynchronously Co-authored-by: Colton Hurst <churst@bitwarden.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import { DomSanitizer } from "@angular/platform-browser";
|
||||
import { NavigationEnd, Router } from "@angular/router";
|
||||
import * as jq from "jquery";
|
||||
import { IndividualConfig, ToastrService } from "ngx-toastr";
|
||||
import { Subject, takeUntil } from "rxjs";
|
||||
import Swal from "sweetalert2";
|
||||
|
||||
import { AuthService } from "@bitwarden/common/abstractions/auth.service";
|
||||
@@ -48,6 +49,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
private lastActivity: number = null;
|
||||
private idleTimer: number = null;
|
||||
private isIdle = false;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
@@ -78,7 +80,9 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.document.documentElement.lang = this.i18nService.locale;
|
||||
this.i18nService.locale$.pipe(takeUntil(this.destroy$)).subscribe((locale) => {
|
||||
this.document.documentElement.lang = locale;
|
||||
});
|
||||
|
||||
this.ngZone.runOutsideAngular(() => {
|
||||
window.onmousemove = () => this.recordActivity();
|
||||
@@ -181,7 +185,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
});
|
||||
});
|
||||
|
||||
this.router.events.subscribe((event) => {
|
||||
this.router.events.pipe(takeUntil(this.destroy$)).subscribe((event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
const modals = Array.from(document.querySelectorAll(".modal"));
|
||||
for (const modal of modals) {
|
||||
@@ -211,6 +215,8 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
|
||||
ngOnDestroy() {
|
||||
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
||||
this.destroy$.next();
|
||||
this.destroy$.unsubscribe();
|
||||
}
|
||||
|
||||
private async logOut(expired: boolean) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { formatDate } from "@angular/common";
|
||||
import { Component, EventEmitter, Input, Output, OnInit } from "@angular/core";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
@@ -23,6 +24,8 @@ export class SponsoringOrgRowComponent implements OnInit {
|
||||
revokeSponsorshipPromise: Promise<any>;
|
||||
resendEmailPromise: Promise<any>;
|
||||
|
||||
private locale = "";
|
||||
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
@@ -30,7 +33,9 @@ export class SponsoringOrgRowComponent implements OnInit {
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
async ngOnInit() {
|
||||
this.locale = await firstValueFrom(this.i18nService.locale$);
|
||||
|
||||
this.setStatus(
|
||||
this.isSelfHosted,
|
||||
this.sponsoringOrg.familySponsorshipToDelete,
|
||||
@@ -98,7 +103,7 @@ export class SponsoringOrgRowComponent implements OnInit {
|
||||
// They want to delete but there is a valid until date which means there is an active sponsorship
|
||||
this.statusMessage = this.i18nService.t(
|
||||
"revokeWhenExpired",
|
||||
formatDate(validUntil, "MM/dd/yyyy", this.i18nService.locale)
|
||||
formatDate(validUntil, "MM/dd/yyyy", this.locale)
|
||||
);
|
||||
this.statusClass = "text-danger";
|
||||
} else if (toDelete) {
|
||||
|
||||
Reference in New Issue
Block a user