mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 06:09:39 +00:00
Improved update check fail case
This commit is contained in:
@@ -59,6 +59,8 @@
|
|||||||
<div class="ui buttons">
|
<div class="ui buttons">
|
||||||
<button *ngIf="updateAvailable" class="ui labeled icon positive button" (click)="downloadUpdate()">
|
<button *ngIf="updateAvailable" class="ui labeled icon positive button" (click)="downloadUpdate()">
|
||||||
<i class="left alternate icon" [ngClass]="(updateDownloaded ? 'sync' : 'cloud download')"></i>{{downloadUpdateText}}</button>
|
<i class="left alternate icon" [ngClass]="(updateDownloaded ? 'sync' : 'cloud download')"></i>{{downloadUpdateText}}</button>
|
||||||
|
<button *ngIf="updateAvailable === null" class="ui labeled yellow icon button" [class.disabled]="updateRetrying" (click)="retryUpdate()">
|
||||||
|
<i class="left alternate sync alternate icon" [class.loading]="updateRetrying"></i>{{retryUpdateText}}</button>
|
||||||
<button id="versionNumberButton" class="ui basic disabled button">{{currentVersion}}</button>
|
<button id="versionNumberButton" class="ui basic disabled button">{{currentVersion}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ export class SettingsComponent implements OnInit, AfterViewInit {
|
|||||||
loginAvailable = true
|
loginAvailable = true
|
||||||
loginClicked = false
|
loginClicked = false
|
||||||
downloadUpdateText = 'Update available'
|
downloadUpdateText = 'Update available'
|
||||||
|
retryUpdateText = 'Failed to check for update'
|
||||||
updateDownloading = false
|
updateDownloading = false
|
||||||
updateDownloaded = false
|
updateDownloaded = false
|
||||||
|
updateRetrying = false
|
||||||
currentVersion = ''
|
currentVersion = ''
|
||||||
|
|
||||||
constructor(public settingsService: SettingsService, private electronService: ElectronService, private ref: ChangeDetectorRef) { }
|
constructor(public settingsService: SettingsService, private electronService: ElectronService, private ref: ChangeDetectorRef) { }
|
||||||
@@ -25,8 +27,17 @@ export class SettingsComponent implements OnInit, AfterViewInit {
|
|||||||
const cacheSize = await this.settingsService.getCacheSize()
|
const cacheSize = await this.settingsService.getCacheSize()
|
||||||
this.cacheSize = Math.round(cacheSize / 1000000) + ' MB'
|
this.cacheSize = Math.round(cacheSize / 1000000) + ' MB'
|
||||||
this.electronService.receiveIPC('update-available', (result) => {
|
this.electronService.receiveIPC('update-available', (result) => {
|
||||||
this.updateAvailable = true
|
this.updateAvailable = result != null
|
||||||
|
this.updateRetrying = false
|
||||||
|
if (this.updateAvailable) {
|
||||||
this.downloadUpdateText = `Update available (${result.version})`
|
this.downloadUpdateText = `Update available (${result.version})`
|
||||||
|
}
|
||||||
|
this.ref.detectChanges()
|
||||||
|
})
|
||||||
|
this.electronService.receiveIPC('update-error', () => {
|
||||||
|
this.updateAvailable = null
|
||||||
|
this.updateRetrying = false
|
||||||
|
this.retryUpdateText = 'Failed to check for update'
|
||||||
this.ref.detectChanges()
|
this.ref.detectChanges()
|
||||||
})
|
})
|
||||||
this.electronService.invoke('get-current-version', undefined).then(version => {
|
this.electronService.invoke('get-current-version', undefined).then(version => {
|
||||||
@@ -111,6 +122,15 @@ export class SettingsComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retryUpdate() {
|
||||||
|
if (this.updateRetrying == false) {
|
||||||
|
this.updateRetrying = true
|
||||||
|
this.retryUpdateText = 'Retrying...'
|
||||||
|
this.ref.detectChanges()
|
||||||
|
this.electronService.sendIPC('retry-update', undefined)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
toggleDevTools() {
|
toggleDevTools() {
|
||||||
const toolsOpened = this.electronService.currentWindow.webContents.isDevToolsOpened()
|
const toolsOpened = this.electronService.currentWindow.webContents.isDevToolsOpened()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
<div class="ui top menu">
|
<div class="ui top menu">
|
||||||
<a class="item" routerLinkActive="active" routerLink="/browse">Browse</a>
|
<a class="item" routerLinkActive="active" routerLink="/browse">Browse</a>
|
||||||
<a class="item" routerLinkActive="active" routerLink="/library">Library</a>
|
<a class="item" routerLinkActive="active" routerLink="/library">Library</a>
|
||||||
<a class="item" routerLinkActive="active" routerLink="/settings"><i *ngIf="updateAvailable" class="teal small circle icon"></i>Settings</a>
|
<a class="item" routerLinkActive="active" routerLink="/settings">
|
||||||
|
<i *ngIf="updateAvailable" class="teal small circle icon"></i>
|
||||||
|
<i *ngIf="updateAvailable === null" class="small yellow exclamation triangle icon"></i>
|
||||||
|
Settings
|
||||||
|
</a>
|
||||||
|
|
||||||
<div class="right menu">
|
<div class="right menu">
|
||||||
<a class="item traffic-light" (click)="minimize()"><i class="minus icon"></i></a>
|
<a class="item traffic-light" (click)="minimize()"><i class="minus icon"></i></a>
|
||||||
|
|||||||
@@ -24,8 +24,12 @@ export class ToolbarComponent implements OnInit {
|
|||||||
this.ref.detectChanges()
|
this.ref.detectChanges()
|
||||||
})
|
})
|
||||||
|
|
||||||
this.electronService.receiveIPC('update-available', () => {
|
this.electronService.receiveIPC('update-available', (result) => {
|
||||||
this.updateAvailable = true
|
this.updateAvailable = result != null
|
||||||
|
this.ref.detectChanges()
|
||||||
|
})
|
||||||
|
this.electronService.receiveIPC('update-error', () => {
|
||||||
|
this.updateAvailable = null
|
||||||
this.ref.detectChanges()
|
this.ref.detectChanges()
|
||||||
})
|
})
|
||||||
this.updateAvailable = await this.electronService.invoke('get-update-available', undefined)
|
this.updateAvailable = await this.electronService.invoke('get-update-available', undefined)
|
||||||
|
|||||||
@@ -14,7 +14,15 @@ let updateAvailable = false
|
|||||||
/**
|
/**
|
||||||
* Checks for updates when the program is launched.
|
* Checks for updates when the program is launched.
|
||||||
*/
|
*/
|
||||||
class UpdateChecker {
|
class UpdateChecker implements IPCEmitHandler<'retry-update'> {
|
||||||
|
event: 'retry-update' = 'retry-update'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for an update.
|
||||||
|
*/
|
||||||
|
handler() {
|
||||||
|
this.checkForUpdates()
|
||||||
|
}
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
autoUpdater.autoDownload = false
|
autoUpdater.autoDownload = false
|
||||||
@@ -23,11 +31,15 @@ class UpdateChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkForUpdates() {
|
checkForUpdates() {
|
||||||
autoUpdater.checkForUpdates()
|
autoUpdater.checkForUpdates().catch(reason => {
|
||||||
|
updateAvailable = null
|
||||||
|
emitIPCEvent('update-error', reason)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private registerUpdaterListeners() {
|
private registerUpdaterListeners() {
|
||||||
autoUpdater.on('error', (err: Error) => {
|
autoUpdater.on('error', (err: Error) => {
|
||||||
|
updateAvailable = null
|
||||||
emitIPCEvent('update-error', err)
|
emitIPCEvent('update-error', err)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -35,6 +47,11 @@ class UpdateChecker {
|
|||||||
updateAvailable = true
|
updateAvailable = true
|
||||||
emitIPCEvent('update-available', info)
|
emitIPCEvent('update-available', info)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
autoUpdater.on('update-not-available', (info: UpdateInfo) => {
|
||||||
|
updateAvailable = false
|
||||||
|
emitIPCEvent('update-available', null)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { Settings } from './Settings'
|
|||||||
import { batchSongDetailsHandler } from '../ipc/browse/BatchSongDetailsHandler.ipc'
|
import { batchSongDetailsHandler } from '../ipc/browse/BatchSongDetailsHandler.ipc'
|
||||||
import { getSettingsHandler, setSettingsHandler } from '../ipc/SettingsHandler.ipc'
|
import { getSettingsHandler, setSettingsHandler } from '../ipc/SettingsHandler.ipc'
|
||||||
import { googleLoginHandler, getAuthStatusHandler, googleLogoutHandler } from '../ipc/google/GoogleLoginHandler.ipc'
|
import { googleLoginHandler, getAuthStatusHandler, googleLogoutHandler } from '../ipc/google/GoogleLoginHandler.ipc'
|
||||||
import { UpdateProgress, getCurrentVersionHandler, downloadUpdateHandler, quitAndInstallHandler, getUpdateAvailableHandler } from '../ipc/UpdateHandler.ipc'
|
import { updateChecker, UpdateProgress, getCurrentVersionHandler, downloadUpdateHandler, quitAndInstallHandler, getUpdateAvailableHandler } from '../ipc/UpdateHandler.ipc'
|
||||||
import { UpdateInfo } from 'electron-updater'
|
import { UpdateInfo } from 'electron-updater'
|
||||||
import { openURLHandler } from '../ipc/OpenURLHandler.ipc'
|
import { openURLHandler } from '../ipc/OpenURLHandler.ipc'
|
||||||
|
|
||||||
@@ -96,6 +96,7 @@ export function getIPCEmitHandlers(): IPCEmitHandler<keyof IPCEmitEvents>[] {
|
|||||||
downloadHandler,
|
downloadHandler,
|
||||||
setSettingsHandler,
|
setSettingsHandler,
|
||||||
downloadUpdateHandler,
|
downloadUpdateHandler,
|
||||||
|
updateChecker,
|
||||||
quitAndInstallHandler,
|
quitAndInstallHandler,
|
||||||
openURLHandler
|
openURLHandler
|
||||||
]
|
]
|
||||||
@@ -115,6 +116,7 @@ export type IPCEmitEvents = {
|
|||||||
'update-progress': UpdateProgress
|
'update-progress': UpdateProgress
|
||||||
'update-downloaded': undefined
|
'update-downloaded': undefined
|
||||||
'download-update': undefined
|
'download-update': undefined
|
||||||
|
'retry-update': undefined
|
||||||
'quit-and-install': undefined
|
'quit-and-install': undefined
|
||||||
'open-url': string
|
'open-url': string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user