mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +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
|
||||
// @ts-strict-ignore
|
||||
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 { ActivatedRoute, Router } from "@angular/router";
|
||||
import { firstValueFrom, switchMap } from "rxjs";
|
||||
|
||||
import { OrganizationUserApiService } from "@bitwarden/admin-console/common";
|
||||
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 { I18nService } from "@bitwarden/common/platform/abstractions/i18n.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 { DialogService, TableDataSource, ToastService } from "@bitwarden/components";
|
||||
|
||||
@@ -34,7 +35,7 @@ export interface EntityEventsDialogParams {
|
||||
templateUrl: "entity-events.component.html",
|
||||
standalone: true,
|
||||
})
|
||||
export class EntityEventsComponent implements OnInit {
|
||||
export class EntityEventsComponent implements OnInit, OnDestroy {
|
||||
loading = true;
|
||||
continuationToken: string;
|
||||
protected dataSource = new TableDataSource<EventView>();
|
||||
@@ -59,13 +60,14 @@ export class EntityEventsComponent implements OnInit {
|
||||
private apiService: ApiService,
|
||||
private i18nService: I18nService,
|
||||
private eventService: EventService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private userNamePipe: UserNamePipe,
|
||||
private logService: LogService,
|
||||
private organizationUserApiService: OrganizationUserApiService,
|
||||
private formBuilder: FormBuilder,
|
||||
private validationService: ValidationService,
|
||||
private toastService: ToastService,
|
||||
private router: Router,
|
||||
private activeRoute: ActivatedRoute,
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -77,6 +79,21 @@ export class EntityEventsComponent implements OnInit {
|
||||
await this.load();
|
||||
}
|
||||
|
||||
async ngOnDestroy() {
|
||||
await firstValueFrom(
|
||||
this.activeRoute.queryParams.pipe(
|
||||
switchMap(async (params) => {
|
||||
await this.router.navigate([], {
|
||||
queryParams: {
|
||||
...params,
|
||||
viewEvents: null,
|
||||
},
|
||||
});
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
async load() {
|
||||
try {
|
||||
if (this.showUser) {
|
||||
|
||||
Reference in New Issue
Block a user