Skip to content

Commit

Permalink
feat: add a toast to notify about new updates
Browse files Browse the repository at this point in the history
  • Loading branch information
wuzi committed May 20, 2021
1 parent c4617a9 commit e35ef6b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ function App() {
}
});

ipcRenderer.send("check-for-updates");
ipcRenderer.on("update-available", () => {
toast("There's a new update available, check our github releases page.", { type: "warning" });
});

check();
dispatch(fetchFiles(userDataPath));
}, []);
Expand Down
20 changes: 19 additions & 1 deletion src/ipc/main/ipcApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
import { app, ipcMain } from "electron";
import { app, ipcMain, net } from "electron";
import { version } from "../../../package.json";

ipcMain.on("getPath", (event, arg) => {
event.returnValue = app.getPath(arg);
});

ipcMain.on("check-for-updates", (event) => {
const request = net.request("https://api.github.com/repos/devsfy/wiregui/releases/latest");
request.on("response", (response) => {
response.on("data", (chunk) => {
if (response.statusCode !== 200) {
return;
}

const body = JSON.parse(chunk.toString());
if (body.tag_name !== version) {
event.reply("update-available");
}
});
});
request.end();
});

0 comments on commit e35ef6b

Please sign in to comment.