Skip to content

Commit 5a1d7fb

Browse files
committed
Display error/retry in case of failure
1 parent 1527523 commit 5a1d7fb

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

error.html

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>Cannot load YouTube Music</title>
6+
<style>
7+
body {
8+
background: #000;
9+
}
10+
11+
.container {
12+
margin: 0;
13+
font-family: Roboto, Arial, sans-serif;
14+
font-size: 20px;
15+
font-weight: 500;
16+
color: rgba(255, 255, 255, 0.5);
17+
position: absolute;
18+
top: 50%;
19+
left: 50%;
20+
margin-right: -50%;
21+
transform: translate(-50%, -50%);
22+
text-align: center;
23+
}
24+
25+
.button {
26+
background: #065fd4;
27+
overflow: hidden;
28+
text-overflow: ellipsis;
29+
white-space: nowrap;
30+
color: white;
31+
font: inherit;
32+
text-transform: uppercase;
33+
text-decoration: none;
34+
border-radius: 2px;
35+
font-size: 16px;
36+
font-weight: normal;
37+
text-align: center;
38+
padding: 8px 22px;
39+
display: inline-block;
40+
}
41+
</style>
42+
</head>
43+
44+
<body>
45+
<div class="container">
46+
<p>Cannot load YouTube Music… Internet disconnected?</p>
47+
<a href="#" class="button" onclick="reload()">Retry</a>
48+
</div>
49+
</body>
50+
</html>

index.js

+7
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ function createMainWindow() {
7272
});
7373
});
7474

75+
win.webContents.on("did-fail-load", () => {
76+
if (isDev) {
77+
console.log("did fail load");
78+
}
79+
win.webContents.loadFile(path.join(__dirname, "error.html"));
80+
});
81+
7582
win.webContents.on("did-navigate-in-page", () => {
7683
const url = win.webContents.getURL();
7784
if (url.startsWith("https://music.youtube.com")) {

preload.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
const path = require("path");
22

3-
const { getEnabledPlugins } = require("./store");
4-
const { fileExists } = require("./plugins/utils");
3+
const { getCurrentWindow } = require("electron").remote;
4+
5+
const { getEnabledPlugins, store } = require("./store");
6+
const { fileExists } = require("./plugins/utils");
57

68
const plugins = getEnabledPlugins();
79

@@ -23,4 +25,8 @@ document.addEventListener("DOMContentLoaded", () => {
2325
run();
2426
});
2527
});
28+
29+
// Add action for reloading
30+
global.reload = () =>
31+
getCurrentWindow().webContents.loadURL(store.get("url"));
2632
});

0 commit comments

Comments
 (0)