mirror of
https://github.com/bitwarden/browser
synced 2026-02-18 02:19:18 +00:00
removed broadcast service
This commit is contained in:
@@ -4,7 +4,6 @@ import { BehaviorSubject } from "rxjs";
|
||||
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
@@ -69,7 +68,6 @@ describe("SendV2Component", () => {
|
||||
{ provide: ToastService, useValue: mock<ToastService>() },
|
||||
{ provide: PolicyService, useValue: mockPolicyService },
|
||||
{ provide: AccountService, useValue: mockAccountService },
|
||||
{ provide: BroadcasterService, useValue: mock<BroadcasterService>() },
|
||||
],
|
||||
})
|
||||
.overrideComponent(SendV2Component, {
|
||||
@@ -468,26 +466,4 @@ describe("SendV2Component", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Sync Completion Handling", () => {
|
||||
it("subscribes to broadcaster on init", () => {
|
||||
const broadcasterService = TestBed.inject(BroadcasterService);
|
||||
|
||||
component.ngOnInit();
|
||||
|
||||
expect(broadcasterService.subscribe).toHaveBeenCalledWith(
|
||||
"SendV2Component",
|
||||
expect.any(Function),
|
||||
);
|
||||
});
|
||||
|
||||
it("unsubscribes from broadcaster on destroy", () => {
|
||||
const broadcasterService = TestBed.inject(BroadcasterService);
|
||||
|
||||
component.ngOnInit();
|
||||
component.ngOnDestroy();
|
||||
|
||||
expect(broadcasterService.unsubscribe).toHaveBeenCalledWith("SendV2Component");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,18 +7,14 @@ import {
|
||||
signal,
|
||||
viewChild,
|
||||
AfterViewInit,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
NgZone,
|
||||
} from "@angular/core";
|
||||
import { takeUntilDestroyed , toSignal } from "@angular/core/rxjs-interop";
|
||||
import { takeUntilDestroyed, toSignal } from "@angular/core/rxjs-interop";
|
||||
import { firstValueFrom, map, switchMap } from "rxjs";
|
||||
|
||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||
import { getUserId } from "@bitwarden/common/auth/services/account.service";
|
||||
import { BroadcasterService } from "@bitwarden/common/platform/abstractions/broadcaster.service";
|
||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
@@ -39,7 +35,7 @@ import { AddEditComponent } from "../send/add-edit.component";
|
||||
templateUrl: "send-v2.component.html",
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class SendV2Component implements OnInit, AfterViewInit, OnDestroy {
|
||||
export class SendV2Component implements AfterViewInit {
|
||||
protected readonly sendType = SendType;
|
||||
protected readonly addEditComponent = viewChild(AddEditComponent);
|
||||
protected readonly filteredSends = toSignal(this.sendItemsService.filteredAndSortedSends$, {
|
||||
@@ -84,8 +80,6 @@ export class SendV2Component implements OnInit, AfterViewInit, OnDestroy {
|
||||
private toastService: ToastService,
|
||||
private policyService: PolicyService,
|
||||
private accountService: AccountService,
|
||||
private broadcasterService: BroadcasterService,
|
||||
private ngZone: NgZone,
|
||||
private destroyRef: DestroyRef,
|
||||
) {
|
||||
// Check if DisableSend enterprise policy applies to current user
|
||||
@@ -102,17 +96,6 @@ export class SendV2Component implements OnInit, AfterViewInit, OnDestroy {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
// Subscribe to sync completion events to refresh send list
|
||||
this.broadcasterService.subscribe("SendV2Component", (message: any) => {
|
||||
void this.ngZone.run(async () => {
|
||||
if (message.command === "syncCompleted") {
|
||||
// SendItemsService automatically refreshes via observable
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
// Handle pending add operation after view initializes
|
||||
if (this.action() === "add" && this.pendingAddType() !== null) {
|
||||
@@ -121,10 +104,6 @@ export class SendV2Component implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.broadcasterService.unsubscribe("SendV2Component");
|
||||
}
|
||||
|
||||
// Select a Send to view/edit
|
||||
protected async selectSend(sendId: string): Promise<void> {
|
||||
if (sendId === this.sendId() && this.action() === "edit") {
|
||||
|
||||
Reference in New Issue
Block a user