Skip to content

Commit 316c980

Browse files
AutoUpdate Display
- On launch the new app will be download and an overlay will be visible - If user clicks quit the application will close (need to make sure downloaded files are deleted)... unfortunately I can't find a way to ask the user if they want to download the files first... I'll look into a way of giving the user a notificiation for an update
1 parent 522d8a4 commit 316c980

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

src/autoUpdater.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
const updateOverlay_el = document.getElementById('updateOverlay');
2+
const startUpdateButton_el = document.getElementById('startUpdateButton');
3+
const quitUpdateButton_el = document.getElementById('quitUpdateButton');
4+
const updateControlDiv_el = document.getElementById('updateControlDiv');
5+
16
api.autoUpdaterCallback((status) => {
27
console.log(status);
8+
if (status === 'Update Available'){
9+
updateOverlay_el.style.display = 'flex';
10+
}
11+
if (status === 'Update Downloaded'){
12+
updateControlDiv_el.style.display = 'grid';
13+
}
14+
});
15+
16+
startUpdateButton_el.addEventListener('click', () => {
17+
api.restartAndUpdate();
18+
});
19+
20+
quitUpdateButton_el.addEventListener('click', () => {
21+
api.closeApp();
322
});

src/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
88
</head>
99
<body>
10+
<div id="updateOverlay" class="overlay" style="display: none;">
11+
<div class="stop-container" style="text-align: center;">
12+
<div style="display: grid">
13+
<h2>Update Available!</h2>
14+
</div>
15+
<div id="updateControlDiv" style="display: none; grid-template-columns: 1fr 1fr; grid-gap: 5px;">
16+
<button id="startUpdateButton" class="input-button">Update</button>
17+
<button id="quitUpdateButton" class="input-button">Quit</button>
18+
</div>
19+
</div>
20+
</div>
21+
22+
1023
<div id="loopbackOverlay" class="overlay" style="display: none;">
1124
<div class="loopback-container" style="text-align: center;">
1225
<div style="display: grid">

src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const createWindow = () => {
5252
owner: 'programmingKyle',
5353
repo: 'zerocraft-sync',
5454
});
55-
autoUpdater.checkForUpdates();
55+
autoUpdater.checkForUpdatesAndNotify();
5656
}
5757
});
5858
};
@@ -89,7 +89,11 @@ autoUpdater.on('update-not-available', () => {
8989

9090
autoUpdater.on('update-downloaded', () => {
9191
mainWindow.webContents.send('auto-updater-callback', 'Update Downloaded');
92-
ensureSafeQuitAndInstall()
92+
//ensureSafeQuitAndInstall();
93+
});
94+
95+
ipcMain.handle('restart-and-update', () => {
96+
ensureSafeQuitAndInstall();
9397
});
9498

9599
function ensureSafeQuitAndInstall() {

src/preload.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ contextBridge.exposeInMainWorld('api', {
2727
callback(status);
2828
});
2929
},
30+
31+
restartAndUpdate: () => ipcRenderer.invoke('restart-and-update'),
3032
});

0 commit comments

Comments
 (0)