Improved update check fail case

This commit is contained in:
Geomitron
2021-01-30 20:34:17 -05:00
parent f2aae10987
commit 9103d2c708
6 changed files with 58 additions and 9 deletions

View File

@@ -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>

View File

@@ -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()

View File

@@ -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>

View File

@@ -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)