1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-05 23:53:21 +00:00
Files
directory-connector/src/app/tabs/more.component.ts
Addison Beck d2ba7631b5 [refactor] Implement StateService (#192)
* [refactor(Account Switching)] Implement StateService

* [bug] Migration service updates

* [bug] Fix organizationId coming in as null

* [bug] Use correct storage location

* [bug] Fix secure storage issues

* [bug] Small fixes

* [bug] lint fixes

* [bug] Undo comment

* [bug] Make method names match super

* update jslib

* Add index signature to keys

* Run prettier

* Start dbus

* Start dbus a different way

* Update build.yml

* Add eval

* Init keyring as well

* Remove eval

* Add eval's back

* Remove unused import

* Remove unnecessary null checks

* Change userId to be entityId instead of clientId

* Remove config service

* lint fixes

* Add clientKeys to account

Co-authored-by: Robyn MacCallum <robyntmaccallum@gmail.com>
2021-12-22 15:16:23 -05:00

78 lines
2.3 KiB
TypeScript

import { ChangeDetectorRef, Component, NgZone, OnInit } from "@angular/core";
import { BroadcasterService } from "jslib-common/abstractions/broadcaster.service";
import { I18nService } from "jslib-common/abstractions/i18n.service";
import { MessagingService } from "jslib-common/abstractions/messaging.service";
import { PlatformUtilsService } from "jslib-common/abstractions/platformUtils.service";
import { StateService } from "../../abstractions/state.service";
const BroadcasterSubscriptionId = "MoreComponent";
@Component({
selector: "app-more",
templateUrl: "more.component.html",
})
export class MoreComponent implements OnInit {
version: string;
year: string;
checkingForUpdate = false;
constructor(
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private messagingService: MessagingService,
private broadcasterService: BroadcasterService,
private ngZone: NgZone,
private changeDetectorRef: ChangeDetectorRef,
private stateService: StateService
) {}
async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {
case "checkingForUpdate":
this.checkingForUpdate = true;
break;
case "doneCheckingForUpdate":
this.checkingForUpdate = false;
break;
default:
break;
}
this.changeDetectorRef.detectChanges();
});
});
this.year = new Date().getFullYear().toString();
this.version = await this.platformUtilsService.getApplicationVersion();
}
ngOnDestroy() {
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
}
update() {
this.messagingService.send("checkForUpdate");
}
async logOut() {
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t("logOutConfirmation"),
this.i18nService.t("logOut"),
this.i18nService.t("yes"),
this.i18nService.t("cancel")
);
if (confirmed) {
this.messagingService.send("logout");
}
}
async clearCache() {
await this.stateService.clearSyncSettings(true);
this.platformUtilsService.showToast("success", null, this.i18nService.t("syncCacheCleared"));
}
}