mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-09 05:09:39 +00:00
Improved update check fail case
This commit is contained in:
@@ -59,9 +59,11 @@
|
||||
<div class="ui buttons">
|
||||
<button *ngIf="updateAvailable" class="ui labeled icon positive button" (click)="downloadUpdate()">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
||||
<button class="ui basic icon button" data-tooltip="Toggle developer tools" data-position="top right"
|
||||
(click)="toggleDevTools()">
|
||||
<i class="cog icon"></i>
|
||||
|
||||
@@ -15,8 +15,10 @@ export class SettingsComponent implements OnInit, AfterViewInit {
|
||||
loginAvailable = true
|
||||
loginClicked = false
|
||||
downloadUpdateText = 'Update available'
|
||||
retryUpdateText = 'Failed to check for update'
|
||||
updateDownloading = false
|
||||
updateDownloaded = false
|
||||
updateRetrying = false
|
||||
currentVersion = ''
|
||||
|
||||
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()
|
||||
this.cacheSize = Math.round(cacheSize / 1000000) + ' MB'
|
||||
this.electronService.receiveIPC('update-available', (result) => {
|
||||
this.updateAvailable = true
|
||||
this.downloadUpdateText = `Update available (${result.version})`
|
||||
this.updateAvailable = result != null
|
||||
this.updateRetrying = false
|
||||
if (this.updateAvailable) {
|
||||
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.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() {
|
||||
const toolsOpened = this.electronService.currentWindow.webContents.isDevToolsOpened()
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<div class="ui top menu">
|
||||
<a class="item" routerLinkActive="active" routerLink="/browse">Browse</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">
|
||||
<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.electronService.receiveIPC('update-available', () => {
|
||||
this.updateAvailable = true
|
||||
this.electronService.receiveIPC('update-available', (result) => {
|
||||
this.updateAvailable = result != null
|
||||
this.ref.detectChanges()
|
||||
})
|
||||
this.electronService.receiveIPC('update-error', () => {
|
||||
this.updateAvailable = null
|
||||
this.ref.detectChanges()
|
||||
})
|
||||
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.
|
||||
*/
|
||||
class UpdateChecker {
|
||||
class UpdateChecker implements IPCEmitHandler<'retry-update'> {
|
||||
event: 'retry-update' = 'retry-update'
|
||||
|
||||
/**
|
||||
* Check for an update.
|
||||
*/
|
||||
handler() {
|
||||
this.checkForUpdates()
|
||||
}
|
||||
|
||||
constructor() {
|
||||
autoUpdater.autoDownload = false
|
||||
@@ -23,11 +31,15 @@ class UpdateChecker {
|
||||
}
|
||||
|
||||
checkForUpdates() {
|
||||
autoUpdater.checkForUpdates()
|
||||
autoUpdater.checkForUpdates().catch(reason => {
|
||||
updateAvailable = null
|
||||
emitIPCEvent('update-error', reason)
|
||||
})
|
||||
}
|
||||
|
||||
private registerUpdaterListeners() {
|
||||
autoUpdater.on('error', (err: Error) => {
|
||||
updateAvailable = null
|
||||
emitIPCEvent('update-error', err)
|
||||
})
|
||||
|
||||
@@ -35,6 +47,11 @@ class UpdateChecker {
|
||||
updateAvailable = true
|
||||
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 { getSettingsHandler, setSettingsHandler } from '../ipc/SettingsHandler.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 { openURLHandler } from '../ipc/OpenURLHandler.ipc'
|
||||
|
||||
@@ -96,6 +96,7 @@ export function getIPCEmitHandlers(): IPCEmitHandler<keyof IPCEmitEvents>[] {
|
||||
downloadHandler,
|
||||
setSettingsHandler,
|
||||
downloadUpdateHandler,
|
||||
updateChecker,
|
||||
quitAndInstallHandler,
|
||||
openURLHandler
|
||||
]
|
||||
@@ -115,6 +116,7 @@ export type IPCEmitEvents = {
|
||||
'update-progress': UpdateProgress
|
||||
'update-downloaded': undefined
|
||||
'download-update': undefined
|
||||
'retry-update': undefined
|
||||
'quit-and-install': undefined
|
||||
'open-url': string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user