Fix auto update

This commit is contained in:
Thomas Nordquist
2019-05-02 08:40:56 +02:00
parent 4f624cc130
commit a411d21133
3 changed files with 5 additions and 30 deletions

View File

@@ -1,18 +1,14 @@
import { Base64Message } from './Model/Base64Message' import { Base64Message } from './Model/Base64Message'
import { DataSource, MqttSource } from './DataSource' import { DataSource, MqttSource } from './DataSource'
import { UpdateInfo } from 'builder-util-runtime'
import { import {
AddMqttConnection, AddMqttConnection,
EventDispatcher,
MqttMessage, MqttMessage,
addMqttConnectionEvent, addMqttConnectionEvent,
backendEvents, backendEvents,
checkForUpdates,
makeConnectionMessageEvent, makeConnectionMessageEvent,
makeConnectionStateEvent, makeConnectionStateEvent,
makePublishEvent, makePublishEvent,
removeConnection, removeConnection,
updateAvailable
} from '../../events' } from '../../events'
export class ConnectionManager { export class ConnectionManager {
@@ -76,17 +72,3 @@ export class ConnectionManager {
.forEach(conenctionId => this.removeConnection(conenctionId)) .forEach(conenctionId => this.removeConnection(conenctionId))
} }
} }
class UpdateNotifier {
public onCheckUpdateRequest = new EventDispatcher<void, UpdateNotifier>()
constructor() {
backendEvents.subscribe(checkForUpdates, () => {
this.onCheckUpdateRequest.dispatch()
})
}
public notify(updateInfo: UpdateInfo) {
backendEvents.emit(updateAvailable, updateInfo)
}
}
export const updateNotifier = new UpdateNotifier()

View File

@@ -28,10 +28,6 @@ export function makeConnectionStateEvent(connectionId: string): Event<DataSource
} }
} }
export const checkForUpdates: Event<void> = {
topic: 'app/update/check',
}
export const updateAvailable: Event<UpdateInfo> = { export const updateAvailable: Event<UpdateInfo> = {
topic: 'app/update/available', topic: 'app/update/available',
} }

View File

@@ -1,7 +1,6 @@
import { autoUpdater } from 'electron-updater' import { autoUpdater } from 'electron-updater'
import { BuildInfo } from 'electron-telemetry/build/Model' import { BuildInfo } from 'electron-telemetry/build/Model'
import { UpdateInfo } from '../events' import { UpdateInfo } from '../events'
import { updateNotifier } from '../backend/src/index'
export function shouldAutoUpdate(build: BuildInfo) { export function shouldAutoUpdate(build: BuildInfo) {
return build.package !== 'portable' return build.package !== 'portable'
@@ -16,11 +15,9 @@ export function handleAutoUpdate() {
console.log('could not update due to error') console.log('could not update due to error')
}) })
updateNotifier.onCheckUpdateRequest.subscribe(() => {
try { try {
autoUpdater.checkForUpdatesAndNotify() autoUpdater.checkForUpdatesAndNotify()
} catch (error) { } catch (error) {
console.error(error) console.error(error)
} }
})
} }