1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01: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:
Thomas Rittson 2022-11-03 08:34:53 +10:00 committed by GitHub
parent 4b495a1b2a
commit 07090e9382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,4 @@
import { Injectable, OnDestroy, OnInit } from "@angular/core";
import { Subject, takeUntil } from "rxjs";
import { Injectable } from "@angular/core";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
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";
@Injectable()
export class EventService implements OnInit, OnDestroy {
private destroy$ = new Subject<void>();
export class EventService {
private policies: Policy[];
constructor(private i18nService: I18nService, private policyService: PolicyService) {}
ngOnInit(): void {
this.policyService.policies$.pipe(takeUntil(this.destroy$)).subscribe((policies) => {
constructor(private i18nService: I18nService, policyService: PolicyService) {
policyService.policies$.subscribe((policies) => {
this.policies = policies;
});
}
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
getDefaultDateFilters() {
const d = new Date();
const end = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 23, 59);