diff --git a/main.js b/main.js index 432ab79..f14a9dc 100644 --- a/main.js +++ b/main.js @@ -373,6 +373,9 @@ const commandHandler = (channel, cmd, info) => { config.updateMultipleKeys(info); settwin.close(); break; + case 'sett-forceupg': + updateWorker.postMessage({ act: 'run-check', force: true, notify: true }); + break; default: console.error('Unhandled command: ', cmd); @@ -584,6 +587,10 @@ const main = (userdir = __dirname) => { win.send('warnmsg', { hidden: false, type: 'text', id: 'upd-nobin', text: '{$tr:updater.warns.noemu}', trparams: msg, buttons: ['{$tr:buttons.ye}', '{$tr:buttons.ig}', '{$tr:buttons.cl}'] }); break; + case 'noupd': + genericWarnMsg('{$tr:updater.warns.noupd}', true); + break; + case 'progress': win.send('warnmsg-upd', { id: 'upd-progr', progress: msg.value }); break; diff --git a/services/updater.js b/services/updater.js index ebcacd2..3027ba4 100644 --- a/services/updater.js +++ b/services/updater.js @@ -76,7 +76,9 @@ const loadJSON = (url, headers = undefined) => }); }); -const triggerCheck = async (force) => { +const noupdNotify = () => parentPort.postMessage({ resp: 'noupd' }); + +const triggerCheck = async ({ force, notify }) => { const binpath = searchBinary(); let currver = 'v.0.0'; @@ -128,7 +130,7 @@ const triggerCheck = async (force) => { } else { throw new Error('No assets in the latest release!'); } - } + } else if (notify) noupdNotify(); } else { throw new Error(`REST /releases failed: ${resp.message}`); } @@ -139,7 +141,7 @@ const triggerCheck = async (force) => { return; } - const resp = await loadJSON('https://api.github.com/repos/SysRay/psOff_public/actions/runs?per_page=1&branch=features&status=completed'); + const resp = await loadJSON('https://api.github.com/repos/SysRay/psOff_public/actions/runs?per_page=1&branch=features&status=success'); if (resp.total_count > 0) { const run = resp.workflow_runs[0]; const newver = run.id; @@ -147,7 +149,7 @@ const triggerCheck = async (force) => { if (newver != currver) { newverinfo.url = '_' + run.artifacts_url; newverinfo.tag = newver.toString(); - } + } else if (notify) noupdNotify(); } else { throw new Error(`REST /actions failed: ${resp.message}`); } @@ -172,6 +174,8 @@ const download = async (url, version, headers = undefined) => { } return download(art.archive_download_url, version, headers); + } else if (resp.total_count === 0) { + throw new Error('No artifacts were generated for this run!'); } throw new Error(`REST /artifacts failed: ${resp.message}`); @@ -268,7 +272,7 @@ const commandHandler = async (msg) => { case 'run-check': validateEmulatorPath(); - await triggerCheck(msg.force); + await triggerCheck(msg); break; case 'download': diff --git a/webroot/js/settings.js b/webroot/js/settings.js index c28a936..cd1c668 100644 --- a/webroot/js/settings.js +++ b/webroot/js/settings.js @@ -351,45 +351,55 @@ window._onLangReady = (() => { }); wrapper.on('click', ({ target }) => { - const elemid = target.dataset.setpathto; - if (!elemid) return; - window.electronAPI.selectFolder().then((path) => { - const elem = document.getElementById(elemid); - elem.value = path; - elem.dispatchEvent(new Event('input', { bubbles: true })); - }); - }, true); + switch (target.id) { + case 'gsd-add': { + const path = $('#gsd-path').value; + if (!path) return; - $('#gsd-add').on('click', () => { - const path = $('#gsd-path').value; - if (!path) return; + if (modified_cfg[1].scan_dirs === undefined) { + modified_cfg[1].scan_dirs = Object.assign({}, saved_cfg[1].scan_dirs); + } - if (modified_cfg[1].scan_dirs === undefined) { - modified_cfg[1].scan_dirs = Object.assign({}, saved_cfg[1].scan_dirs); - } + modified_cfg[1].scan_dirs[path] = ($('#gsd-depth').selectedIndex + 1); + refillScanDirs(modified_cfg); + } break; - modified_cfg[1].scan_dirs[path] = ($('#gsd-depth').selectedIndex + 1); - refillScanDirs(modified_cfg); - }); + case 'gsd-remove': { + const path = $('#gsd-path').value; + if (!path) return; - $('#gsd-remove').on('click', () => { - const path = $('#gsd-path').value; - if (!path) return; + if (modified_cfg[1].scan_dirs === undefined) { + modified_cfg[1].scan_dirs = Object.assign({}, saved_cfg[1].scan_dirs); + } - if (modified_cfg[1].scan_dirs === undefined) { - modified_cfg[1].scan_dirs = Object.assign({}, saved_cfg[1].scan_dirs); + /** + * If we want _isSimilar to return valid result then this object + * should not change its size and loose keys, so delete is not an + * option there. Making object's value undefined has no side effects + * as it seems. JSON will not save undefined keys, but it's still there + * for _isSimilar. + */ + modified_cfg[1].scan_dirs[path] = undefined; + refillScanDirs(modified_cfg); + } break; + + case 'forceupd': { + window.electronAPI.sendCommand('sett-forceupg'); + window.close(); + } break; + + default: { + const elemid = target.dataset.setpathto; + if (!elemid) return; + window.electronAPI.selectFolder().then((path) => { + const elem = document.getElementById(elemid); + elem.value = path; + elem.dispatchEvent(new Event('input', { bubbles: true })); + }); + } break; } - /** - * If we want _isSimilar to return valid result then this object - * should not change its size and loose keys, so delete is not an - * option there. Making object's value undefined has no side effects - * as it seems. JSON will not save undefined keys, but it's still there - * for _isSimilar. - */ - modified_cfg[1].scan_dirs[path] = undefined; - refillScanDirs(modified_cfg); - }); + }, true); gsd.on('change', ({ target }) => { $('#gsd-path').value = target.options[target.selectedIndex].dataset.folder; diff --git a/webroot/js/warnmsg.js b/webroot/js/warnmsg.js index 4358683..265e889 100644 --- a/webroot/js/warnmsg.js +++ b/webroot/js/warnmsg.js @@ -7,6 +7,7 @@ const wrap = $('#wrapper'); if (data.hidden) { + if (data.id !== warn.dataset.wid) return; wrap.dataset.ready = 1; warn.dataset.active = 0; return; diff --git a/webroot/langs/en.json b/webroot/langs/en.json index fc19ca8..45b751a 100644 --- a/webroot/langs/en.json +++ b/webroot/langs/en.json @@ -23,6 +23,7 @@ "monthly": "Monthly" } }, + "updforce": "Force update check", "doubleclick": "Doubleclick will run the game", "drpc": "Enable Discord Rich Presence", "gsd": { @@ -105,7 +106,8 @@ "warns": { "newver": "New version of psOff emulator is available! Do you want to download it? (Installed: {currver}, New: {newver})", "noemu": "Looks like you have no psOff emulator installed. Would you like the launcher to download the latest release ({latest})?", - "downproc": "Downloading the emulator binaries, hang tight..." + "downproc": "Downloading the emulator binaries, hang tight...", + "noupd": "You're already using the latest emulator version!" }, "errors": { "checkfail": "Failed to check updates for your psOff installation: {error}", diff --git a/webroot/langs/ru.json b/webroot/langs/ru.json index bffe0a4..b8af2ff 100644 --- a/webroot/langs/ru.json +++ b/webroot/langs/ru.json @@ -23,6 +23,7 @@ "monthly": "Ежемесячно" } }, + "updforce": "Принудительная проверка обновлений", "doubleclick": "Двойное нажатие запускает игру", "drpc": "Включить Discord Rich Presence", "gsd": { @@ -92,7 +93,8 @@ "warns": { "newver": "Доступна новая версия эмулятора psOff! Хотите скачать её? (Установлена: {currver}, Новая: {newver})", "noemu": "Похоже, что у вас не установлен эмулятор psOff. Хотите скачать последний релиз ({latest})?", - "downproc": "Скачиваю эмулятор..." + "downproc": "Скачиваю эмулятор...", + "noupd": "Последняя версия уже установлена!" }, "errors": { "checkfail": "Не удалось проверить обновления: {error}", diff --git a/webroot/settings.html b/webroot/settings.html index 7625a65..20f51f7 100644 --- a/webroot/settings.html +++ b/webroot/settings.html @@ -46,6 +46,9 @@ +