mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-07-07 18:45:09 +00:00
Finalized auto-update system
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "bridge",
|
"name": "bridge",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"description": "A handy Clone Hero library management tool with built in chart searching and downloading.",
|
"description": "A Clone Hero library management tool with built in chart searching and downloading.",
|
||||||
"homepage": "https://github.com/Geomitron/Bridge",
|
"homepage": "https://github.com/Geomitron/Bridge",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
@@ -49,8 +49,8 @@
|
|||||||
<div class="bottom">
|
<div class="bottom">
|
||||||
<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 cloud download alternate icon"></i>Update available</button>
|
<i class="left alternate icon" [ngClass]="(updateDownloaded ? 'sync' : 'cloud download')"></i>{{downloadUpdateText}}</button>
|
||||||
<button id="versionNumberButton" class="ui basic disabled button">v0.0.0</button>
|
<button id="versionNumberButton" class="ui basic disabled button">{{currentVersion}}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="ui basic icon button" data-tooltip="Toggle developer tools" data-position="top right"
|
<button class="ui basic icon button" data-tooltip="Toggle developer tools" data-position="top right"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, ViewChild, ElementRef, AfterViewInit } from '@angular/core'
|
import { Component, OnInit, ViewChild, ElementRef, AfterViewInit, ChangeDetectorRef } from '@angular/core'
|
||||||
import { ElectronService } from 'src/app/core/services/electron.service'
|
import { ElectronService } from 'src/app/core/services/electron.service'
|
||||||
import { SettingsService } from 'src/app/core/services/settings.service'
|
import { SettingsService } from 'src/app/core/services/settings.service'
|
||||||
|
|
||||||
@@ -12,18 +12,29 @@ export class SettingsComponent implements OnInit, AfterViewInit {
|
|||||||
|
|
||||||
cacheSize = 'Calculating...'
|
cacheSize = 'Calculating...'
|
||||||
updateAvailable = false
|
updateAvailable = false
|
||||||
updateVersion: string = null
|
downloadUpdateText = 'Update available'
|
||||||
|
updateDownloading = false
|
||||||
|
updateDownloaded = false
|
||||||
|
currentVersion = ''
|
||||||
|
|
||||||
constructor(public settingsService: SettingsService, private electronService: ElectronService) { }
|
constructor(public settingsService: SettingsService, private electronService: ElectronService, private ref: ChangeDetectorRef) { }
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
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.updateVersion = result.version
|
|
||||||
this.updateAvailable = true
|
this.updateAvailable = true
|
||||||
|
this.downloadUpdateText = `Update available (${result.version})`
|
||||||
|
this.ref.detectChanges()
|
||||||
|
})
|
||||||
|
this.electronService.invoke('get-current-version', undefined).then(version => {
|
||||||
|
this.currentVersion = `v${version}`
|
||||||
|
this.ref.detectChanges()
|
||||||
|
})
|
||||||
|
this.electronService.invoke('get-update-available', undefined).then(isAvailable => {
|
||||||
|
this.updateAvailable = isAvailable
|
||||||
|
this.ref.detectChanges()
|
||||||
})
|
})
|
||||||
this.updateAvailable = await this.electronService.invoke('get-update-available', undefined)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
@@ -63,15 +74,22 @@ export class SettingsComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
downloadUpdate() {
|
downloadUpdate() {
|
||||||
this.electronService.sendIPC('download-update', undefined)
|
if (this.updateDownloaded) {
|
||||||
this.electronService.receiveIPC('update-progress', (result) => console.log(result.percent))
|
|
||||||
this.electronService.receiveIPC('update-downloaded', (result) => {
|
|
||||||
console.log(result)
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log('quit and install...')
|
|
||||||
this.electronService.sendIPC('quit-and-install', undefined)
|
this.electronService.sendIPC('quit-and-install', undefined)
|
||||||
}, 30000)
|
} else if (!this.updateDownloading) {
|
||||||
|
this.updateDownloading = true
|
||||||
|
this.electronService.sendIPC('download-update', undefined)
|
||||||
|
this.downloadUpdateText = 'Downloading... (0%)'
|
||||||
|
this.electronService.receiveIPC('update-progress', (result) => {
|
||||||
|
this.downloadUpdateText = `Downloading... (${result.percent.toFixed(0)}%)`
|
||||||
|
this.ref.detectChanges()
|
||||||
})
|
})
|
||||||
|
this.electronService.receiveIPC('update-downloaded', () => {
|
||||||
|
this.downloadUpdateText = 'Quit and install update'
|
||||||
|
this.updateDownloaded = true
|
||||||
|
this.ref.detectChanges()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleDevTools() {
|
toggleDevTools() {
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ export class ToolbarComponent implements OnInit {
|
|||||||
|
|
||||||
this.electronService.receiveIPC('update-available', () => {
|
this.electronService.receiveIPC('update-available', () => {
|
||||||
this.updateAvailable = true
|
this.updateAvailable = true
|
||||||
|
this.ref.detectChanges()
|
||||||
})
|
})
|
||||||
this.updateAvailable = await this.electronService.invoke('get-update-available', undefined)
|
this.updateAvailable = await this.electronService.invoke('get-update-available', undefined)
|
||||||
|
this.ref.detectChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
minimize() {
|
minimize() {
|
||||||
|
|||||||
Reference in New Issue
Block a user