mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-14 23:33:19 +00:00
wire up updater
This commit is contained in:
2
jslib
2
jslib
Submodule jslib updated: c3dad8fd1a...2032e14285
3
package-lock.json
generated
3
package-lock.json
generated
@@ -3889,8 +3889,7 @@
|
||||
"jsbn": {
|
||||
"version": "0.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"json-schema": {
|
||||
"version": "0.2.3",
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
<br /> {{'version' | i18n : version}}
|
||||
<br /> © 8bit Solutions LLC 2015-{{year}}
|
||||
</p>
|
||||
<button class="btn btn-primary" type="button" (click)="update()">
|
||||
<i class="fa fa-download fa-fw"></i>
|
||||
<button class="btn btn-primary" type="button" (click)="update()" [disabled]="checkingForUpdate">
|
||||
<i class="fa fa-download fa-fw" [hidden]="checkingForUpdate"></i>
|
||||
<i class="fa fa-spinner fa-fw fa-spin" [hidden]="!checkingForUpdate"></i>
|
||||
{{'checkForUpdates' | i18n}}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
NgZone,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
} from '@angular/core';
|
||||
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
|
||||
import { BroadcasterService } from 'jslib/angular/services/broadcaster.service';
|
||||
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { MessagingService } from 'jslib/abstractions/messaging.service';
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
|
||||
import { ConfigurationService } from '../../services/configuration.service';
|
||||
|
||||
const BroadcasterSubscriptionId = 'MoreComponent';
|
||||
|
||||
@Component({
|
||||
selector: 'app-more',
|
||||
templateUrl: 'more.component.html',
|
||||
@@ -17,17 +25,42 @@ import { ConfigurationService } from '../../services/configuration.service';
|
||||
export class MoreComponent implements OnInit {
|
||||
version: string;
|
||||
year: string;
|
||||
checkingForUpdate = false;
|
||||
|
||||
constructor(private platformUtilsService: PlatformUtilsService, private i18nService: I18nService,
|
||||
private messagingService: MessagingService, private configurationService: ConfigurationService,
|
||||
private toasterService: ToasterService) { }
|
||||
private toasterService: ToasterService, private broadcasterService: BroadcasterService,
|
||||
private ngZone: NgZone, private changeDetectorRef: ChangeDetectorRef) { }
|
||||
|
||||
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 = this.platformUtilsService.getApplicationVersion();
|
||||
}
|
||||
|
||||
async update() { }
|
||||
ngOnDestroy() {
|
||||
this.broadcasterService.unsubscribe(BroadcasterSubscriptionId);
|
||||
}
|
||||
|
||||
update() {
|
||||
this.messagingService.send('checkForUpdate');
|
||||
}
|
||||
|
||||
async logOut() {
|
||||
const confirmed = await this.platformUtilsService.showDialog(
|
||||
|
||||
10
src/main.ts
10
src/main.ts
@@ -9,6 +9,7 @@ import { KeytarStorageListener } from 'jslib/electron/keytarStorageListener';
|
||||
import { ElectronLogService } from 'jslib/electron/services/electronLog.service';
|
||||
import { ElectronMainMessagingService } from 'jslib/electron/services/electronMainMessaging.service';
|
||||
import { ElectronStorageService } from 'jslib/electron/services/electronStorage.service';
|
||||
import { UpdaterMain } from 'jslib/electron/updater.main';
|
||||
import { WindowMain } from 'jslib/electron/window.main';
|
||||
|
||||
export class Main {
|
||||
@@ -21,6 +22,7 @@ export class Main {
|
||||
windowMain: WindowMain;
|
||||
messagingMain: MessagingMain;
|
||||
menuMain: MenuMain;
|
||||
updaterMain: UpdaterMain;
|
||||
|
||||
constructor() {
|
||||
// Set paths for portable builds
|
||||
@@ -52,7 +54,12 @@ export class Main {
|
||||
|
||||
this.windowMain = new WindowMain(this.storageService);
|
||||
this.menuMain = new MenuMain(this);
|
||||
this.messagingMain = new MessagingMain(this.windowMain, this.menuMain);
|
||||
this.updaterMain = new UpdaterMain(this.i18nService, this.windowMain, 'directory-connector', () => {
|
||||
this.messagingService.send('checkingForUpdate');
|
||||
}, null, () => {
|
||||
this.messagingService.send('doneCheckingForUpdate');
|
||||
});
|
||||
this.messagingMain = new MessagingMain(this.windowMain, this.menuMain, this.updaterMain);
|
||||
this.messagingService = new ElectronMainMessagingService(this.windowMain, (message) => {
|
||||
this.messagingMain.onMessage(message);
|
||||
});
|
||||
@@ -66,6 +73,7 @@ export class Main {
|
||||
await this.i18nService.init(app.getLocale());
|
||||
this.menuMain.init();
|
||||
this.messagingMain.init();
|
||||
await this.updaterMain.init();
|
||||
}, (e: any) => {
|
||||
// tslint:disable-next-line
|
||||
console.error(e);
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
ipcMain,
|
||||
} from 'electron';
|
||||
|
||||
import { UpdaterMain } from 'jslib/electron/updater.main';
|
||||
import { WindowMain } from 'jslib/electron/window.main';
|
||||
|
||||
import { MenuMain } from './menu.main';
|
||||
@@ -12,15 +13,18 @@ const SyncCheckInterval = 60 * 1000; // 1 minute
|
||||
export class MessagingMain {
|
||||
private syncTimeout: NodeJS.Timer;
|
||||
|
||||
constructor(private windowMain: WindowMain, private menuMain: MenuMain) { }
|
||||
constructor(private windowMain: WindowMain, private menuMain: MenuMain,
|
||||
private updaterMain: UpdaterMain) { }
|
||||
|
||||
init() {
|
||||
this.scheduleNextSync();
|
||||
ipcMain.on('messagingService', async (event: any, message: any) => this.onMessage(message));
|
||||
}
|
||||
|
||||
onMessage(message: any) {
|
||||
switch (message.command) {
|
||||
case 'checkForUpdate':
|
||||
this.updaterMain.checkForUpdate(true);
|
||||
break;
|
||||
case 'scheduleNextDirSync':
|
||||
this.scheduleNextSync();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user