2020-05-19 11:21:12 +02:00
|
|
|
const {ipcRenderer, remote, shell} = require('electron');
|
2020-05-19 10:54:00 +02:00
|
|
|
|
|
|
|
let currentVersion;
|
|
|
|
let updateStatus;
|
2020-05-19 11:21:12 +02:00
|
|
|
let updateInfo;
|
|
|
|
let updateButton;
|
2020-05-19 10:54:00 +02:00
|
|
|
|
|
|
|
ipcRenderer.on('current-version', (e, version) => {
|
|
|
|
currentVersion.innerText = `Version: ${version.version}`;
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcRenderer.on('updateStatus', (e, available, version) => {
|
2020-05-19 11:21:12 +02:00
|
|
|
console.log(available, version);
|
|
|
|
updateInfo = version;
|
2020-05-19 10:54:00 +02:00
|
|
|
if (available) {
|
2020-05-19 11:21:12 +02:00
|
|
|
updateStatus.innerHTML = 'A new update is available!';
|
|
|
|
updateButton.classList.remove('hidden');
|
2020-05-19 10:54:00 +02:00
|
|
|
} else {
|
|
|
|
updateStatus.innerText = 'Tabs is up to date.';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function save() {
|
|
|
|
const formData = new FormData(document.querySelector('form'));
|
|
|
|
remote.getCurrentWindow().close();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
|
|
currentVersion = document.getElementById('current-version');
|
|
|
|
updateStatus = document.getElementById('update-status');
|
2020-05-19 11:21:12 +02:00
|
|
|
updateButton = document.getElementById('download-button');
|
|
|
|
updateButton.addEventListener('click', () => {
|
2020-05-19 11:46:34 +02:00
|
|
|
shell.openExternal(`https://github.com/ArisuOngaku/tabs/releases/download/v${updateInfo.version}/${updateInfo.path}`)
|
2020-05-19 11:21:12 +02:00
|
|
|
.catch(console.error);
|
|
|
|
});
|
2020-05-19 10:54:00 +02:00
|
|
|
|
|
|
|
ipcRenderer.send('syncSettings');
|
|
|
|
ipcRenderer.send('checkForUpdates');
|
|
|
|
});
|