Skip to content

Commit

Permalink
(fix): Auto updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Aktindo committed Apr 17, 2024
1 parent 36affe5 commit 6064ef1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions client/electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ app.on("ready", () => {
autoUpdater.checkForUpdatesAndNotify();
});

ipcMain.on("restart_app", () => {
autoUpdater.quitAndInstall()
})

autoUpdater.on("update-available", (info) => {
win.webContents.send(
"update_available",
Expand Down
14 changes: 13 additions & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const AppComp: React.FC = () => {
const location = useLocation();
const [updateModalVisible, setUpdateModalVisible] = React.useState(false);
const [updateMessage, setUpdateMessage] = useState("");
const [updateDownloaded, setUpdateDownloaded] = useState(false)

const [verificationModalVisible, setVerificationModalVisible] =
React.useState(false);
Expand All @@ -45,13 +46,17 @@ const AppComp: React.FC = () => {
//#endregion

useEffect(() => {
setUpdateModalVisible(false);

ipcRenderer.on("update_available", (e, msg) => {
setUpdateMessage(msg);
setUpdateModalVisible(true);
});

ipcRenderer.on("update_downloaded", (e, msg) => {
setUpdateModalVisible(false);
setUpdateMessage(msg)
setUpdateModalVisible(true);
setUpdateDownloaded(true);
});

ipcRenderer.on("verification-success", (e, msg) => {
Expand Down Expand Up @@ -107,6 +112,13 @@ const AppComp: React.FC = () => {
<Progress isIndeterminate size="sm" />
</div>
</ModalBody>
{updateDownloaded &&
<ModalFooter>
<Button color="success" onPress={() => ipcRenderer.send("restart_app")}>
Restart
</Button>
</ModalFooter> }

</>
)}
</ModalContent>
Expand Down

0 comments on commit 6064ef1

Please sign in to comment.