Added update ipc handler

This commit is contained in:
Geomitron
2020-05-21 14:17:51 -04:00
parent 64701e4909
commit 9e0d332a1a
7 changed files with 128 additions and 27 deletions

View File

@@ -2,7 +2,7 @@
<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">Settings</a>
<a class="item" routerLinkActive="active" routerLink="/about">About</a>
<a class="item" routerLinkActive="active" routerLink="/about"><i class="teal small circle icon"></i>About</a>
<div class="right menu">
<a class="item traffic-light" (click)="minimize()"><i class="minus icon"></i></a>

View File

@@ -1,22 +1,5 @@
import { Component, OnInit, ChangeDetectorRef } from '@angular/core'
import { ElectronService } from '../../core/services/electron.service'
// import { autoUpdater, UpdateInfo } from 'electron-updater'
// autoUpdater.autoDownload = false
// autoUpdater.on('error', (err) => {})
// autoUpdater.on('checking-for-update', () => {})
// autoUpdater.on('update-available', (info: UpdateInfo) => {})
// autoUpdater.on('update-not-available', () => {})
// autoUpdater.on('download-progress', (progress) => {
// console.log(progress.bytesPerSecond, progress.percent, progress.transferred, progress.total)
// })
// autoUpdater.on('update-downloaded', (info: UpdateInfo) => {})
// autoUpdater.currentVersion // TODO: display this in the corner or on the about page?
// autoUpdater.logger = null
// autoUpdater.checkForUpdates()
// autoUpdater.downloadUpdate()
// autoUpdater.quitAndInstall(false) // By default; autoUpdater installs a downloaded update on the next program restart
// TODO: check for updates on initialization; show a button indicating a new version can be downloaded
@Component({
selector: 'app-toolbar',
@@ -26,6 +9,7 @@ import { ElectronService } from '../../core/services/electron.service'
export class ToolbarComponent implements OnInit {
isMaximized: boolean
updateAvailable = false
constructor(private electronService: ElectronService, private ref: ChangeDetectorRef) { }
@@ -39,6 +23,10 @@ export class ToolbarComponent implements OnInit {
this.isMaximized = true
this.ref.detectChanges()
})
this.electronService.receiveIPC('update-available', () => {
this.updateAvailable = true
})
}
minimize() {

View File

@@ -33,7 +33,6 @@ export class DownloadService {
const thisDownloadIndex = this.downloads.findIndex(download => download.versionID == result.versionID)
if (thisDownloadIndex == -1) {
this.downloads.push(result)
// TODO: this.downloads.sort(downloadSorter)
} else {
this.downloads[thisDownloadIndex] = result
}