Fix auto update
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
import { Base64Message } from './Model/Base64Message'
|
||||
import { DataSource, MqttSource } from './DataSource'
|
||||
import { UpdateInfo } from 'builder-util-runtime'
|
||||
import {
|
||||
AddMqttConnection,
|
||||
EventDispatcher,
|
||||
MqttMessage,
|
||||
addMqttConnectionEvent,
|
||||
backendEvents,
|
||||
checkForUpdates,
|
||||
makeConnectionMessageEvent,
|
||||
makeConnectionStateEvent,
|
||||
makePublishEvent,
|
||||
removeConnection,
|
||||
updateAvailable
|
||||
} from '../../events'
|
||||
|
||||
export class ConnectionManager {
|
||||
@@ -76,17 +72,3 @@ export class ConnectionManager {
|
||||
.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()
|
||||
|
||||
@@ -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> = {
|
||||
topic: 'app/update/available',
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { autoUpdater } from 'electron-updater'
|
||||
import { BuildInfo } from 'electron-telemetry/build/Model'
|
||||
import { UpdateInfo } from '../events'
|
||||
import { updateNotifier } from '../backend/src/index'
|
||||
|
||||
export function shouldAutoUpdate(build: BuildInfo) {
|
||||
return build.package !== 'portable'
|
||||
@@ -16,11 +15,9 @@ export function handleAutoUpdate() {
|
||||
console.log('could not update due to error')
|
||||
})
|
||||
|
||||
updateNotifier.onCheckUpdateRequest.subscribe(() => {
|
||||
try {
|
||||
autoUpdater.checkForUpdatesAndNotify()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
})
|
||||
try {
|
||||
autoUpdater.checkForUpdatesAndNotify()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user