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