Browse Source

wire up updater

pull/7/head
Kyle Spearrin 8 years ago
parent
commit
a0025e933a
  1. 2
      jslib
  2. 3
      package-lock.json
  3. 5
      src/app/tabs/more.component.html
  4. 37
      src/app/tabs/more.component.ts
  5. 10
      src/main.ts
  6. 8
      src/main/messaging.main.ts

2
jslib

@ -1 +1 @@ @@ -1 +1 @@
Subproject commit c3dad8fd1ae862476ccc417b4d33eecd3edd61a9
Subproject commit 2032e14285ac3d4b2f3e9e310ad19ca1dd40c525

3
package-lock.json generated

@ -3889,8 +3889,7 @@ @@ -3889,8 +3889,7 @@
"jsbn": {
"version": "0.1.1",
"bundled": true,
"dev": true,
"optional": true
"dev": true
},
"json-schema": {
"version": "0.2.3",

5
src/app/tabs/more.component.html

@ -8,8 +8,9 @@ @@ -8,8 +8,9 @@
<br /> {{'version' | i18n : version}}
<br /> &copy; 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>

37
src/app/tabs/more.component.ts

@ -1,15 +1,23 @@ @@ -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'; @@ -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

@ -9,6 +9,7 @@ import { KeytarStorageListener } from 'jslib/electron/keytarStorageListener'; @@ -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 { @@ -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 { @@ -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 { @@ -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);

8
src/main/messaging.main.ts

@ -3,6 +3,7 @@ import { @@ -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 @@ -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;

Loading…
Cancel
Save