mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
Fix undefined property error in event logs (#3947)
EventService.policies was undefined because the service was erroneously using ngOnInit to subscribe to the policies observable
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { Injectable, OnDestroy, OnInit } from "@angular/core";
|
import { Injectable } from "@angular/core";
|
||||||
import { Subject, takeUntil } from "rxjs";
|
|
||||||
|
|
||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
@@ -10,23 +9,15 @@ import { Policy } from "@bitwarden/common/models/domain/policy";
|
|||||||
import { EventResponse } from "@bitwarden/common/models/response/event.response";
|
import { EventResponse } from "@bitwarden/common/models/response/event.response";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class EventService implements OnInit, OnDestroy {
|
export class EventService {
|
||||||
private destroy$ = new Subject<void>();
|
|
||||||
private policies: Policy[];
|
private policies: Policy[];
|
||||||
|
|
||||||
constructor(private i18nService: I18nService, private policyService: PolicyService) {}
|
constructor(private i18nService: I18nService, policyService: PolicyService) {
|
||||||
|
policyService.policies$.subscribe((policies) => {
|
||||||
ngOnInit(): void {
|
|
||||||
this.policyService.policies$.pipe(takeUntil(this.destroy$)).subscribe((policies) => {
|
|
||||||
this.policies = policies;
|
this.policies = policies;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.destroy$.next();
|
|
||||||
this.destroy$.complete();
|
|
||||||
}
|
|
||||||
|
|
||||||
getDefaultDateFilters() {
|
getDefaultDateFilters() {
|
||||||
const d = new Date();
|
const d = new Date();
|
||||||
const end = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59);
|
const end = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59);
|
||||||
|
|||||||
Reference in New Issue
Block a user