diff --git a/error.html b/error.html new file mode 100644 index 00000000..1008bc87 --- /dev/null +++ b/error.html @@ -0,0 +1,50 @@ + + + + + Cannot load YouTube Music + + + + +
+

Cannot load YouTube Music… Internet disconnected?

+ Retry +
+ + diff --git a/index.js b/index.js index 873a1d9e..860e081b 100644 --- a/index.js +++ b/index.js @@ -72,6 +72,13 @@ function createMainWindow() { }); }); + win.webContents.on("did-fail-load", () => { + if (isDev) { + console.log("did fail load"); + } + win.webContents.loadFile(path.join(__dirname, "error.html")); + }); + win.webContents.on("did-navigate-in-page", () => { const url = win.webContents.getURL(); if (url.startsWith("https://music.youtube.com")) { diff --git a/preload.js b/preload.js index a0849cba..692b89dd 100644 --- a/preload.js +++ b/preload.js @@ -1,7 +1,9 @@ const path = require("path"); -const { getEnabledPlugins } = require("./store"); -const { fileExists } = require("./plugins/utils"); +const { getCurrentWindow } = require("electron").remote; + +const { getEnabledPlugins, store } = require("./store"); +const { fileExists } = require("./plugins/utils"); const plugins = getEnabledPlugins(); @@ -23,4 +25,8 @@ document.addEventListener("DOMContentLoaded", () => { run(); }); }); + + // Add action for reloading + global.reload = () => + getCurrentWindow().webContents.loadURL(store.get("url")); });