mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 06:13:38 +00:00
[PM-17852] ensure query param is removed when component is destroyed (#13342)
* ensure query param is removed when compoent is destroyed * cleanup
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
// FIXME: Update this file to be type safe and remove this and next line
|
||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
import { DIALOG_DATA, DialogConfig } from "@angular/cdk/dialog";
|
import { DIALOG_DATA, DialogConfig } from "@angular/cdk/dialog";
|
||||||
import { Component, Inject, OnInit } from "@angular/core";
|
import { Component, Inject, OnDestroy, OnInit } from "@angular/core";
|
||||||
import { FormBuilder } from "@angular/forms";
|
import { FormBuilder } from "@angular/forms";
|
||||||
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
|
import { firstValueFrom, switchMap } from "rxjs";
|
||||||
|
|
||||||
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
|
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
|
||||||
import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
|
import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
|
||||||
@@ -12,7 +14,6 @@ import { ListResponse } from "@bitwarden/common/models/response/list.response";
|
|||||||
import { EventView } from "@bitwarden/common/models/view/event.view";
|
import { EventView } from "@bitwarden/common/models/view/event.view";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
|
||||||
import { DialogService, TableDataSource, ToastService } from "@bitwarden/components";
|
import { DialogService, TableDataSource, ToastService } from "@bitwarden/components";
|
||||||
|
|
||||||
@@ -34,7 +35,7 @@ export interface EntityEventsDialogParams {
|
|||||||
templateUrl: "entity-events.component.html",
|
templateUrl: "entity-events.component.html",
|
||||||
standalone: true,
|
standalone: true,
|
||||||
})
|
})
|
||||||
export class EntityEventsComponent implements OnInit {
|
export class EntityEventsComponent implements OnInit, OnDestroy {
|
||||||
loading = true;
|
loading = true;
|
||||||
continuationToken: string;
|
continuationToken: string;
|
||||||
protected dataSource = new TableDataSource<EventView>();
|
protected dataSource = new TableDataSource<EventView>();
|
||||||
@@ -59,13 +60,14 @@ export class EntityEventsComponent implements OnInit {
|
|||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private eventService: EventService,
|
private eventService: EventService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
|
||||||
private userNamePipe: UserNamePipe,
|
private userNamePipe: UserNamePipe,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private organizationUserApiService: OrganizationUserApiService,
|
private organizationUserApiService: OrganizationUserApiService,
|
||||||
private formBuilder: FormBuilder,
|
private formBuilder: FormBuilder,
|
||||||
private validationService: ValidationService,
|
private validationService: ValidationService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
|
private router: Router,
|
||||||
|
private activeRoute: ActivatedRoute,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@@ -77,6 +79,21 @@ export class EntityEventsComponent implements OnInit {
|
|||||||
await this.load();
|
await this.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async ngOnDestroy() {
|
||||||
|
await firstValueFrom(
|
||||||
|
this.activeRoute.queryParams.pipe(
|
||||||
|
switchMap(async (params) => {
|
||||||
|
await this.router.navigate([], {
|
||||||
|
queryParams: {
|
||||||
|
...params,
|
||||||
|
viewEvents: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
try {
|
try {
|
||||||
if (this.showUser) {
|
if (this.showUser) {
|
||||||
|
|||||||
Reference in New Issue
Block a user