Skip to content
This repository was archived by the owner on Jul 14, 2023. It is now read-only.

Commit 7ae665d

Browse files
authored
Merge pull request #122 from education/catchUpdaterErrors
Catch Errors on Updater
2 parents c9d37fd + 7a4d3f0 commit 7ae665d

2 files changed

Lines changed: 31 additions & 26 deletions

File tree

app/main-process/letsMove.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const log = require("electron-log")
55
const Store = require("electron-store")
66

77
export const moveToApplicationsFolder = () => {
8-
if (!app.isInApplicationsFolder() && !isDev && shouldRemindUser()) {
8+
if (!app.isInApplicationsFolder() && !isDev && !userOptedOut()) {
99
dialog.showMessageBox({
1010
type: "question",
1111
buttons: ["Move to Applications", "Do Not Move"],
@@ -26,18 +26,18 @@ export const moveToApplicationsFolder = () => {
2626

2727
if (checkboxChecked) {
2828
// Don't remind user again
29-
setReminder(false)
29+
optOutReminder()
3030
}
3131
})
3232
}
3333
}
3434

35-
const shouldRemindUser = () => {
35+
const userOptedOut = () => {
3636
const store = new Store()
37-
return !store.get("classroom-assistant-move-to-app-folder")
37+
return store.get("classroom-assistant-opt-out-move")
3838
}
3939

40-
const setReminder = (value) => {
40+
const optOutReminder = () => {
4141
const store = new Store()
42-
store.set("classroom-assistant-move-to-app-folder", !value)
42+
store.set("classroom-assistant-opt-out-move", true)
4343
}

app/main-process/updater.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,38 @@ module.exports = {
2222
start (app, interval) {
2323
log.info("starting auto-updater")
2424
const platform = os.platform() + "_" + os.arch()
25-
autoUpdater.setFeedURL(`${UPDATES_SERVER_URL}/update/${platform}/${app.getVersion()}`)
2625

27-
// Fire callbacks on events for notification purposes
28-
autoUpdater.on("error", (err) => {
29-
log.error(err)
30-
})
26+
try {
27+
autoUpdater.setFeedURL(`${UPDATES_SERVER_URL}/update/${platform}/${app.getVersion()}`)
3128

32-
autoUpdater.on("update-downloaded", (releaseNotes, releaseName) => {
33-
log.info("Application update downloaded")
29+
// Fire callbacks on events for notification purposes
30+
autoUpdater.on("error", (err) => {
31+
log.error(err)
32+
})
33+
34+
autoUpdater.on("update-downloaded", (releaseNotes, releaseName) => {
35+
log.info("Application update downloaded")
3436

35-
const updateDialogOpts = {
36-
type: "info",
37-
buttons: ["Restart", "Later"],
38-
title: "Application Update",
39-
message: "An update for this Classroom Assistant has been downloaded. Please restart the application to apply the updates."
40-
}
37+
const updateDialogOpts = {
38+
type: "info",
39+
buttons: ["Restart", "Later"],
40+
title: "Application Update",
41+
message: "An update for this Classroom Assistant has been downloaded. Please restart the application to apply the updates."
42+
}
4143

42-
dialog.showMessageBox(updateDialogOpts, (response) => {
43-
if (response === 0) autoUpdater.quitAndInstall()
44+
dialog.showMessageBox(updateDialogOpts, (response) => {
45+
if (response === 0) autoUpdater.quitAndInstall()
46+
})
4447
})
45-
})
4648

47-
log.info("checking for updates..")
48-
autoUpdater.checkForUpdates()
49-
setInterval(() => {
5049
log.info("checking for updates..")
5150
autoUpdater.checkForUpdates()
52-
}, interval)
51+
setInterval(() => {
52+
log.info("checking for updates..")
53+
autoUpdater.checkForUpdates()
54+
}, interval)
55+
} catch (err) {
56+
log.warn(`Failed to initialize updater ${err}`)
57+
}
5358
}
5459
}

0 commit comments

Comments
 (0)