From 7888227ec9e5f2116a6481605b81fa20602b21a7 Mon Sep 17 00:00:00 2001 From: WolverinDEV Date: Sun, 1 Sep 2019 21:18:54 +0200 Subject: [PATCH] Making it running for Windows (Part 1) --- github | 2 +- modules/core/app-updater/index.ts | 4 ++-- modules/core/main.ts | 16 ++++++++-------- modules/core/ui-loader/loader.ts | 4 ++-- modules/crash_handler/index.ts | 2 ++ modules/renderer/index.ts | 18 ++++++------------ package.json | 12 ++++++------ 7 files changed, 27 insertions(+), 31 deletions(-) diff --git a/github b/github index 2dd1f60..06391c6 160000 --- a/github +++ b/github @@ -1 +1 @@ -Subproject commit 2dd1f60e8d034a68bbca9afe294070c8a83caa9e +Subproject commit 06391c6cdd772c2f83c1387960f7224f7cd9f514 diff --git a/modules/core/app-updater/index.ts b/modules/core/app-updater/index.ts index 464614e..6c93388 100644 --- a/modules/core/app-updater/index.ts +++ b/modules/core/app-updater/index.ts @@ -834,8 +834,8 @@ async function check_update(channel: string) { "\n" + "Current version: " + (await current_version()).toString() + "\n" + "Target version: " + version.version.toString() - } as MessageBoxOptions, result => { - if(result == 0) { + } as MessageBoxOptions).then(result => { + if(result.response == 0) { execute_graphical(channel, false).then(() => { update_question_open = false; }); diff --git a/modules/core/main.ts b/modules/core/main.ts index 825de35..e04595c 100644 --- a/modules/core/main.ts +++ b/modules/core/main.ts @@ -13,23 +13,23 @@ import {open_preview} from "./url-preview"; async function execute_app() { /* legacy, will be removed soon */ if(process_args.has_value("update-failed")) { - const result = electron.dialog.showMessageBox({ + const result = await electron.dialog.showMessageBox({ type: "error", message: "Failed to execute update:\n" + process_args.value("update-failed"), title: "Update failed!", buttons: ["retry", "ignore"] } as MessageBoxOptions); - if(result == 0) + if(result.response == 0) if(await app_updater.execute_graphical(await app_updater.selected_channel(), false)) return; } else if(process_args.has_value("update-succeed")) { - const result = electron.dialog.showMessageBox({ + const result = await electron.dialog.showMessageBox({ type: "info", message: "Update successfully installed!\nShould we launch TeaClient?", title: "Update succeeded!", buttons: ["yes", "no"] } as MessageBoxOptions); - if(result != 0) { + if(result.response != 0) { electron.app.exit(0); return; //Not really required here! } @@ -141,14 +141,14 @@ async function execute_app() { callback: async () => true }); - const result = await new Promise(resolve => electron.dialog.showMessageBox({ + const result = await electron.dialog.showMessageBox({ type: type, message: message, title: title, buttons: buttons.map(e => e.key) - } as MessageBoxOptions, resolve)); - if(buttons[result].callback) { - if(await buttons[result].callback()) + } as MessageBoxOptions); + if(buttons[result.response].callback) { + if(await buttons[result.response].callback()) return; } } diff --git a/modules/core/ui-loader/loader.ts b/modules/core/ui-loader/loader.ts index d49841a..b97d77b 100644 --- a/modules/core/ui-loader/loader.ts +++ b/modules/core/ui-loader/loader.ts @@ -436,7 +436,7 @@ export async function load_files(channel: string, static_cb: (message: string, i if(ui_vers.newer_than(await current_version())) { const local_available = cache && cache.local_index ? ui_pack_exists(cache.local_index) : undefined; - const result = electron.dialog.showMessageBox({ + const result = await electron.dialog.showMessageBox({ type: "question", message: "Local client is outdated.\n" + @@ -445,7 +445,7 @@ export async function load_files(channel: string, static_cb: (message: string, i title: "Client outdated!", buttons: ["yes", local_available ? "ignore and use last possible (" + cache.local_index.version + ")" : "close client"] } as MessageBoxOptions); - if(result == 0) { + if(result.response == 0) { await execute_graphical(channel, true); throw "client outdated"; } else { diff --git a/modules/crash_handler/index.ts b/modules/crash_handler/index.ts index 8c69744..7d67d7a 100644 --- a/modules/crash_handler/index.ts +++ b/modules/crash_handler/index.ts @@ -68,6 +68,8 @@ export function handle_crash_callback(args: string[]) { app.on('window-all-closed', () => { process.exit(0); }); + + crash_window.focus(); }); } diff --git a/modules/renderer/index.ts b/modules/renderer/index.ts index 39969cb..4c174bd 100644 --- a/modules/renderer/index.ts +++ b/modules/renderer/index.ts @@ -82,18 +82,12 @@ export const initialize = async () => { if(process_args.has_value(Arguments.DUMMY_CRASH_RENDERER)) crash_handler.handler.crash(); if(!process_args.has_flag(Arguments.DEBUG)) { - window.open_connected_question = () => { - return new Promise(resolve => { - remote.dialog.showMessageBox(remote.getCurrentWindow(), { - type: 'question', - buttons: ['Yes', 'No'], - title: 'Confirm', - message: 'Are you really sure?\nYou\'re still connected!' - }, choice => { - resolve(choice === 0); - }); - }); - }; + window.open_connected_question = () => remote.dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'question', + buttons: ['Yes', 'No'], + title: 'Confirm', + message: 'Are you really sure?\nYou\'re still connected!' + }).then(result => result.response === 0); } }, priority: 110 diff --git a/package.json b/package.json index ec488e0..a67986a 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "@types/ejs": "^2.6.3", "@types/electron-packager": "8.7.2", "@types/fs-extra": "^8.0.0", - "@types/jquery": "^3.3.30", + "@types/jquery": "^3.3.31", "@types/request": "^2.48.2", "@types/request-promise": "^4.1.44", "@types/tar-stream": "^1.6.1", @@ -36,8 +36,8 @@ "electron-packager": "8.7.2", "nodemon": "^1.19.1", "platform-dependent-modules": "0.0.14", - "sass": "^1.22.7", - "typescript": "^3.5.3" + "sass": "^1.22.10", + "typescript": "^3.6.2" }, "dependencies": { "@types/minimist": "^1.2.0", @@ -50,7 +50,7 @@ "electron": "6.0.7", "electron-installer-windows": "^1.1.1", "electron-navigation": "^1.5.8", - "electron-rebuild": "^1.8.5", + "electron-rebuild": "^1.8.6", "electron-winstaller": "^2.7.0", "electron-wix-msi": "^2.1.1", "extend": "^3.0.2", @@ -60,11 +60,11 @@ "jquery": "^3.4.1", "json-stringify-safe": "^5.0.1", "jsprim": "^2.0.0", - "jsrender": "^1.0.3", + "jsrender": "^1.0.4", "nan": "^2.14.0", "node-ssh": "^6.0.0", "only": "0.0.2", - "psl": "^1.2.0", + "psl": "^1.3.0", "pure-uuid": "^1.5.7", "rc": "^1.2.8", "rcedit": "^1.1.2",