Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit 9c20ee6

Browse files
TetrabyteTetrabyte
authored andcommitted
Error if the update failed
1 parent aece5b2 commit 9c20ee6

File tree

3 files changed

+40
-16
lines changed

3 files changed

+40
-16
lines changed

src/main/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ app.on("activate", () => {
5858
});
5959

6060
app.updateDownloaded = false;
61+
app.updateFailed = false;
6162

6263
autoUpdater.on("update-available", info => {
6364
app.updateDownloading = true;
@@ -66,7 +67,13 @@ autoUpdater.on("update-available", info => {
6667

6768
autoUpdater.on("update-downloaded", info => {
6869
app.updateDownloaded = true;
69-
autoUpdater.quitAndInstall();
70+
71+
try {
72+
autoUpdater.quitAndInstall();
73+
} catch (error) {
74+
console.error('Updated failed', error);
75+
app.updateFailed = true;
76+
}
7077
});
7178

7279
app.reloadApp = () => {

src/renderer/components/Alerts.vue

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="alerts_container">
33
<div v-for="a in alerts" :key="a.id">
4-
<div :class="a.theme" class="alert">{{ a.message }}</div>
4+
<div :class="a.theme" class="alert" @click="(a.link ? open(a.link): null)" v-html="a.message"></div>
55
</div>
66

77
<!-- <div v-bind:class="{ 'show-alert': alert, 'text-danger': hasError }" class="alert">
@@ -20,39 +20,43 @@ export default {
2020
};
2121
},
2222
mounted() {
23-
this.$root.$on("alert", (type, message) => {
24-
this[type](message);
23+
this.$root.$on("alert", (type, message, link) => {
24+
this[type](message, link);
2525
});
2626
},
2727
methods: {
28-
createAlert: function(theme, message) {
29-
if (this.alerts.filter(alert => alert.message === message).length > 0) {
28+
createAlert: function(theme, message, link) {
29+
if (this.alerts.filter(alert => alert.message === message).length <= 0) {
3030
var alertObject = {
3131
id: Math.random(),
3232
message: message,
33-
theme: theme
33+
theme: theme,
34+
link: link
3435
};
3536
this.alerts.push(alertObject);
3637
var vm = this;
3738
setTimeout(function(e) {
3839
vm.alerts.shift();
39-
}, 4000);
40+
}, (link ? 12000 : 4000));
4041
}
4142
},
42-
success: function(message) {
43-
this.createAlert("success fadeout", message);
43+
success: function(message, link) {
44+
this.createAlert("success fadeout", message, link);
4445
},
45-
error: function(message) {
46-
this.createAlert("error fadeout", message);
46+
error: function(message, link) {
47+
this.createAlert("error fadeout", message, link);
4748
},
48-
info: function(message) {
49-
this.createAlert("info fadeout", message);
49+
info: function(message, link) {
50+
this.createAlert("info fadeout", message, link);
51+
},
52+
open(link) {
53+
this.$electron.shell.openExternal(link);
5054
}
5155
}
5256
};
5357
</script>
5458

55-
<style scoped>
59+
<style scoped lang="scss">
5660
.alerts_container {
5761
position: absolute;
5862
bottom: 0px;

src/renderer/components/LandingPage.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ export default {
157157
return {
158158
monkey: 1,
159159
currentFilter: false,
160-
updateDownloading: false
160+
updateDownloading: false,
161+
updateFailed: false
161162
};
162163
},
163164
mounted() {
@@ -173,6 +174,18 @@ export default {
173174
this.updateReady = remote.app.updateDownloaded;
174175
clearInterval(interval);
175176
}
177+
if (remote.app.updateFailed) {
178+
this.updateReady = remote.app.updateFailed;
179+
this.updateFailed = remote.app.updateFailed;
180+
this.$root.$emit(
181+
"alert",
182+
"error",
183+
"Unable to install update automatically, you can download it manually by clicking here",
184+
"https://jamiepine.com/cachemonkey"
185+
);
186+
187+
clearInterval(interval);
188+
}
176189
}, 30000);
177190
},
178191
methods: {

0 commit comments

Comments
 (0)