1
0
mirror of https://github.com/bitwarden/web synced 2025-12-22 19:23:42 +00:00

move premium component to it's own route

This commit is contained in:
Kyle Spearrin
2018-07-03 09:27:59 -04:00
parent 16c3d4c253
commit 70dbca67e7
7 changed files with 77 additions and 17 deletions

View File

@@ -1,9 +1,46 @@
import {
Component,
NgZone,
OnDestroy,
OnInit,
} from '@angular/core';
import { TokenService } from 'jslib/abstractions/token.service';
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
const BroadcasterSubscriptionId = 'SettingsComponent';
@Component({
selector: 'app-settings',
templateUrl: 'settings.component.html',
})
export class SettingsComponent { }
export class SettingsComponent implements OnInit, OnDestroy {
premium: boolean;
constructor(private tokenService: TokenService, private broadcasterService: BroadcasterService,
private ngZone: NgZone) { }
async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
case 'purchasedPremium':
await this.load();
break;
default:
}
});
});
await this.load();
}
ngOnDestroy() {
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
}
async load() {
this.premium = await this.tokenService.getPremium();
}
}