Update notifications
Removed the shit tone of check for updates, made it manual Redone the function in utils Logging for autoupdater implemented
This commit is contained in:
parent
a5e22d5f0d
commit
89e0d7c104
6 changed files with 79 additions and 24 deletions
|
@ -176,3 +176,10 @@ Update 19/2/2022 21:00 UTC
|
||||||
Update 25/02/2022 15:30 UTC
|
Update 25/02/2022 15:30 UTC
|
||||||
|
|
||||||
* `action.moveToTop`: Changed to `Move out of Folder` instead of `Move to top`
|
* `action.moveToTop`: Changed to `Move out of Folder` instead of `Move to top`
|
||||||
|
|
||||||
|
Update 27/02/2022 18:30 UTC
|
||||||
|
|
||||||
|
* `settings.notyf.updateCider.update-not-available`: Added for `en_US`
|
||||||
|
* `settings.notyf.updateCider.update-timeout`: Added for `en_US`
|
||||||
|
* `settings.notyf.updateCider.update-downloaded`: Added for `en_US`
|
||||||
|
* `settings.notyf.updateCider.update-error`: Added for `en_US`
|
|
@ -239,6 +239,10 @@
|
||||||
"settings.option.general.updateCider.branch.description": "Select the branch to update Cider to",
|
"settings.option.general.updateCider.branch.description": "Select the branch to update Cider to",
|
||||||
"settings.option.general.updateCider.branch.main": "Stable",
|
"settings.option.general.updateCider.branch.main": "Stable",
|
||||||
"settings.option.general.updateCider.branch.develop": "Development",
|
"settings.option.general.updateCider.branch.develop": "Development",
|
||||||
|
"settings.notyf.updateCider.update-not-available": "No update available",
|
||||||
|
"settings.notyf.updateCider.update-downloaded": "Update has been downloaded, restart to apply",
|
||||||
|
"settings.notyf.updateCider.update-error": "Error updating Cider",
|
||||||
|
"settings.notyf.updateCider.update-timeout": "Update timed out",
|
||||||
"settings.header.audio": "Audio",
|
"settings.header.audio": "Audio",
|
||||||
"settings.header.audio.description": "Adjust the audio settings for Cider.",
|
"settings.header.audio.description": "Adjust the audio settings for Cider.",
|
||||||
"settings.option.audio.volumeStep": "Volume Step",
|
"settings.option.audio.volumeStep": "Volume Step",
|
||||||
|
|
|
@ -973,27 +973,9 @@ export class BrowserWindow {
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('check-for-update', async (_event) => {
|
ipcMain.on('check-for-update', async (_event) => {
|
||||||
const branch = utils.getStoreValue('general.update_branch')
|
await utils.checkForUpdate();
|
||||||
let latestbranch = await fetch(`https://circleci.com/api/v1.1/project/gh/ciderapp/Cider/latest/artifacts?branch=${branch}&filter=successful`)
|
|
||||||
if (latestbranch.status != 200) {
|
|
||||||
console.log(`Error fetching latest artifact from the **${branch}** branch`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let latestbranchjson = await latestbranch.json()
|
|
||||||
let base_url = latestbranchjson[0].url
|
|
||||||
base_url = base_url.substring(0, base_url.lastIndexOf('/'))
|
|
||||||
|
|
||||||
const options: any = {
|
|
||||||
provider: 'generic',
|
|
||||||
url: `${base_url}`,
|
|
||||||
allowDowngrade: true,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Have to handle the auto updaters seperatly until we can support macOS. electron-builder limitation -q
|
|
||||||
if (process.platform === 'win32') await new NsisUpdater(options).checkForUpdatesAndNotify() //Windows
|
|
||||||
if (process.platform === 'linux') await new AppImageUpdater(options).checkForUpdatesAndNotify() //Linux
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('disable-update', (event) => {
|
ipcMain.on('disable-update', (event) => {
|
||||||
// Check if using app store builds so people don't get pissy wen button go bonk
|
// Check if using app store builds so people don't get pissy wen button go bonk
|
||||||
if (app.isPackaged && !process.mas || !process.windowsStore) {
|
if (app.isPackaged && !process.mas || !process.windowsStore) {
|
||||||
|
|
|
@ -3,6 +3,9 @@ import * as path from "path";
|
||||||
import {Store} from "./store";
|
import {Store} from "./store";
|
||||||
import {BrowserWindow as bw} from "./browserwindow";
|
import {BrowserWindow as bw} from "./browserwindow";
|
||||||
import {app} from "electron";
|
import {app} from "electron";
|
||||||
|
import fetch from "electron-fetch";
|
||||||
|
import {AppImageUpdater, NsisUpdater} from "electron-updater";
|
||||||
|
import * as log from "electron-log";
|
||||||
|
|
||||||
export class utils {
|
export class utils {
|
||||||
|
|
||||||
|
@ -107,4 +110,54 @@ export class utils {
|
||||||
bw.win.webContents.executeJavaScript("MusicKitInterop.previous()")
|
bw.win.webContents.executeJavaScript("MusicKitInterop.previous()")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the application for updates
|
||||||
|
*/
|
||||||
|
static async checkForUpdate(): Promise<void> {
|
||||||
|
|
||||||
|
// Get the artifacts
|
||||||
|
const response = await fetch(`https://circleci.com/api/v1.1/project/gh/ciderapp/Cider/latest/artifacts?branch=${utils.getStoreValue('general.update_branch')}&filter=successful`)
|
||||||
|
if (response.status != 200) {
|
||||||
|
bw.win.webContents.send('update-response', 'update-timeout')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the urls
|
||||||
|
const jsonResponse = await response.json()
|
||||||
|
let base_url = jsonResponse[0].url
|
||||||
|
base_url = base_url.substring(0, base_url.lastIndexOf('/'))
|
||||||
|
|
||||||
|
const options: any = {
|
||||||
|
provider: 'generic',
|
||||||
|
url: base_url,
|
||||||
|
allowDowngrade: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
let autoUpdater: any = null
|
||||||
|
if (process.platform === 'win32') { //Windows
|
||||||
|
autoUpdater = await new NsisUpdater(options)
|
||||||
|
} else {
|
||||||
|
autoUpdater = await new AppImageUpdater(options) //Linux and Mac (AppImages work on macOS btw)
|
||||||
|
}
|
||||||
|
|
||||||
|
autoUpdater.on('error', (error: any) => {
|
||||||
|
console.error(`[AutoUpdater] Error: ${error}`)
|
||||||
|
bw.win.webContents.send('update-response', "update-error")
|
||||||
|
})
|
||||||
|
|
||||||
|
autoUpdater.on('update-not-available', () => {
|
||||||
|
console.log('[AutoUpdater] Update not available.')
|
||||||
|
bw.win.webContents.send('update-response', "update-not-available");
|
||||||
|
})
|
||||||
|
|
||||||
|
autoUpdater.on('update-downloaded', () => {
|
||||||
|
console.log('[AutoUpdater] Update downloaded.')
|
||||||
|
bw.win.webContents.send('update-response', "update-downloaded");
|
||||||
|
})
|
||||||
|
|
||||||
|
log.transports.file.level = "debug"
|
||||||
|
autoUpdater.logger = log
|
||||||
|
await autoUpdater.checkForUpdate()
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -156,5 +156,3 @@ process.once('loaded', () => {
|
||||||
console.log("Setting ipcRenderer")
|
console.log("Setting ipcRenderer")
|
||||||
global.MusicKitInterop = MusicKitInterop;
|
global.MusicKitInterop = MusicKitInterop;
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcRenderer.send('check-for-update')
|
|
||||||
|
|
|
@ -64,7 +64,6 @@ const store = new Vuex.Store({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ipcRenderer.send('check-for-update')
|
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
el: "#app",
|
el: "#app",
|
||||||
store: store,
|
store: store,
|
||||||
|
@ -3950,6 +3949,18 @@ const app = new Vue({
|
||||||
},
|
},
|
||||||
checkForUpdate() {
|
checkForUpdate() {
|
||||||
ipcRenderer.send('check-for-update')
|
ipcRenderer.send('check-for-update')
|
||||||
|
ipcRenderer.on('update-response', (event, res) => {
|
||||||
|
if (res === "update-not-available") {
|
||||||
|
notyf.error(app.getLz(`settings.notyf.updateCider.${res}`))
|
||||||
|
} else if (res === "update-downloaded") {
|
||||||
|
notyf.success(app.getLz(`settings.notyf.updateCider.${res}`))
|
||||||
|
} else if (res === "update-error") {
|
||||||
|
notyf.error(app.getLz(`settings.notyf.updateCider.${res}`))
|
||||||
|
} else if (res === "update-timeout") {
|
||||||
|
notyf.error(app.getLz(`settings.notyf.updateCider.${res}`))
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue