mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-27 12:36:14 +01:00
Update send component to follow existing patterns (#270)
This commit is contained in:
parent
380b28d66a
commit
0951424de7
@ -17,10 +17,6 @@ import { SearchService } from '../../../abstractions/search.service';
|
|||||||
import { SendService } from '../../../abstractions/send.service';
|
import { SendService } from '../../../abstractions/send.service';
|
||||||
import { UserService } from '../../../abstractions/user.service';
|
import { UserService } from '../../../abstractions/user.service';
|
||||||
|
|
||||||
import { BroadcasterService } from '../../../angular/services/broadcaster.service';
|
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = 'SendComponent';
|
|
||||||
|
|
||||||
export class SendComponent implements OnInit {
|
export class SendComponent implements OnInit {
|
||||||
|
|
||||||
disableSend = false;
|
disableSend = false;
|
||||||
@ -49,9 +45,8 @@ export class SendComponent implements OnInit {
|
|||||||
|
|
||||||
constructor(protected sendService: SendService, protected i18nService: I18nService,
|
constructor(protected sendService: SendService, protected i18nService: I18nService,
|
||||||
protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService,
|
protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService,
|
||||||
protected broadcasterService: BroadcasterService, protected ngZone: NgZone,
|
protected ngZone: NgZone, protected searchService: SearchService,
|
||||||
protected searchService: SearchService, protected policyService: PolicyService,
|
protected policyService: PolicyService, protected userService: UserService) { }
|
||||||
protected userService: UserService) { }
|
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
const policies = await this.policyService.getAll(PolicyType.DisableSend);
|
const policies = await this.policyService.getAll(PolicyType.DisableSend);
|
||||||
@ -63,22 +58,6 @@ export class SendComponent implements OnInit {
|
|||||||
!o.canManagePolicies &&
|
!o.canManagePolicies &&
|
||||||
policies.some(p => p.organizationId === o.id && p.enabled);
|
policies.some(p => p.organizationId === o.id && p.enabled);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
|
|
||||||
this.ngZone.run(async () => {
|
|
||||||
switch (message.command) {
|
|
||||||
case 'syncCompleted':
|
|
||||||
if (message.successfully) {
|
|
||||||
await this.load();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async load(filter: (send: SendView) => boolean = null) {
|
async load(filter: (send: SendView) => boolean = null) {
|
||||||
@ -87,8 +66,10 @@ export class SendComponent implements OnInit {
|
|||||||
this.sends = sends;
|
this.sends = sends;
|
||||||
if (this.onSuccessfulLoad != null) {
|
if (this.onSuccessfulLoad != null) {
|
||||||
await this.onSuccessfulLoad();
|
await this.onSuccessfulLoad();
|
||||||
|
} else {
|
||||||
|
// Default action
|
||||||
|
this.selectAll();
|
||||||
}
|
}
|
||||||
this.selectAll();
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user