diff --git a/jslib b/jslib index c3dad8fd..2032e142 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit c3dad8fd1ae862476ccc417b4d33eecd3edd61a9 +Subproject commit 2032e14285ac3d4b2f3e9e310ad19ca1dd40c525 diff --git a/package-lock.json b/package-lock.json index 7e05e753..265830e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3889,8 +3889,7 @@ "jsbn": { "version": "0.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "json-schema": { "version": "0.2.3", diff --git a/src/app/tabs/more.component.html b/src/app/tabs/more.component.html index 628da21c..7bafb290 100644 --- a/src/app/tabs/more.component.html +++ b/src/app/tabs/more.component.html @@ -8,8 +8,9 @@
{{'version' | i18n : version}}
© 8bit Solutions LLC 2015-{{year}}

- diff --git a/src/app/tabs/more.component.ts b/src/app/tabs/more.component.ts index af2e7848..bebf5871 100644 --- a/src/app/tabs/more.component.ts +++ b/src/app/tabs/more.component.ts @@ -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( diff --git a/src/main.ts b/src/main.ts index 67a4a095..df4eca2b 100644 --- a/src/main.ts +++ b/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); diff --git a/src/main/messaging.main.ts b/src/main/messaging.main.ts index dd48e5b0..39dda6e7 100644 --- a/src/main/messaging.main.ts +++ b/src/main/messaging.main.ts @@ -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;