mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
add unresponsive listener
This commit is contained in:
44
index.js
44
index.js
@ -2,6 +2,7 @@
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
const electron = require("electron");
|
const electron = require("electron");
|
||||||
|
const { dialog } = require("electron");
|
||||||
const is = require("electron-is");
|
const is = require("electron-is");
|
||||||
const unhandled = require("electron-unhandled");
|
const unhandled = require("electron-unhandled");
|
||||||
const { autoUpdater } = require("electron-updater");
|
const { autoUpdater } = require("electron-updater");
|
||||||
@ -144,7 +145,11 @@ function createMainWindow() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
win.webContents.on("render-process-gone", (event, webContents, details) => {
|
||||||
|
showUnresponsiveDialog(win, details);
|
||||||
|
});
|
||||||
|
|
||||||
win.once("ready-to-show", () => {
|
win.once("ready-to-show", () => {
|
||||||
if (config.get("options.appVisible")) {
|
if (config.get("options.appVisible")) {
|
||||||
win.show();
|
win.show();
|
||||||
@ -154,13 +159,7 @@ function createMainWindow() {
|
|||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
||||||
let createdWindow = false;
|
app.once("browser-window-created", (event, win) => {
|
||||||
app.on("browser-window-created", (event, win) => {
|
|
||||||
//Ensures listeners are registered only once
|
|
||||||
if (createdWindow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
createdWindow = true;
|
|
||||||
loadPlugins(win);
|
loadPlugins(win);
|
||||||
|
|
||||||
win.webContents.on("did-fail-load", (
|
win.webContents.on("did-fail-load", (
|
||||||
@ -325,3 +324,32 @@ app.on("ready", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function showUnresponsiveDialog(win, details) {
|
||||||
|
if (!!details) {
|
||||||
|
console.log("Unresponsive Error!\n"+JSON.stringify(details, null, "\t"))
|
||||||
|
}
|
||||||
|
dialog.showMessageBox(win, {
|
||||||
|
type: "error",
|
||||||
|
title: "Window Unresponsive",
|
||||||
|
message: "The Application is Unresponsive",
|
||||||
|
details: "We are sorry for the inconveniance! please choose what to do with the application:",
|
||||||
|
buttons: ["Wait", "Relaunch", "Quit"],
|
||||||
|
cancelId: 0
|
||||||
|
}).then( response => {
|
||||||
|
switch (response) {
|
||||||
|
case 1: //if relaunch - relaunch+exit
|
||||||
|
app.relaunch();
|
||||||
|
case 2:
|
||||||
|
app.exit();
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
//maybe set a timer and afterwards check responsivness and call function again if failed
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports.aDialog = showUnresponsiveDialog;
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,6 @@ const config = require("../../config");
|
|||||||
const { setApplicationMenu } = require("../../menu");
|
const { setApplicationMenu } = require("../../menu");
|
||||||
const { injectCSS } = require("../utils");
|
const { injectCSS } = require("../utils");
|
||||||
|
|
||||||
//check that menu doesn't get created twice
|
|
||||||
let calledReadyToShow = false;
|
|
||||||
//tracks menu visibility
|
//tracks menu visibility
|
||||||
let visible = true;
|
let visible = true;
|
||||||
// win hook for fixing menu
|
// win hook for fixing menu
|
||||||
@ -30,13 +28,7 @@ module.exports = (winImport) => {
|
|||||||
// css for custom scrollbar + disable drag area(was causing bugs)
|
// css for custom scrollbar + disable drag area(was causing bugs)
|
||||||
injectCSS(win.webContents, path.join(__dirname, "style.css"));
|
injectCSS(win.webContents, path.join(__dirname, "style.css"));
|
||||||
|
|
||||||
win.on("ready-to-show", () => {
|
win.once("ready-to-show", () => {
|
||||||
// (apparently ready-to-show is called twice)
|
|
||||||
if (calledReadyToShow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
calledReadyToShow = true;
|
|
||||||
|
|
||||||
setApplicationMenu(win);
|
setApplicationMenu(win);
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
fileExists(songInfoProviderPath, require(songInfoProviderPath));
|
fileExists(songInfoProviderPath, require(songInfoProviderPath));
|
||||||
|
|
||||||
// inject front logger
|
// inject front logger
|
||||||
const loggerPath = path.join(__dirname, "providers", "logger.js")
|
const loggerPath = path.join(__dirname, "providers", "frontLogger.js")
|
||||||
fileExists(loggerPath, require(loggerPath));
|
fileExists(loggerPath, require(loggerPath));
|
||||||
|
|
||||||
// Add action for reloading
|
// Add action for reloading
|
||||||
|
|||||||
@ -3,7 +3,7 @@ const { ipcRenderer } = require("electron");
|
|||||||
function logToString(log) {
|
function logToString(log) {
|
||||||
let string = (typeof log === "string") ? log : log.toString();
|
let string = (typeof log === "string") ? log : log.toString();
|
||||||
if (!string || string.includes("[object Object]")) {
|
if (!string || string.includes("[object Object]")) {
|
||||||
string = JSON.stringify(log);
|
string = JSON.stringify(log, null, "\t");
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user