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

Commit a31e54b

Browse files
committed
[:star:] Auto Updater fix (I hope)
1 parent 1cf0fca commit a31e54b

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

main/background.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ if (isProd) {
4646
(async () => {
4747
await app.whenReady();
4848

49-
if(isProd) {
50-
autoUpdater.checkForUpdates()
51-
setInterval(() => {
52-
autoUpdater.checkForUpdates()
53-
}, 1000*60*5)
54-
}
55-
5649
const splashWindow = createWindow('splash', {
5750
width: 400,
5851
height: 500,
@@ -73,6 +66,16 @@ if (isProd) {
7366

7467
mainWindow.loadURL(renderPage("main"))
7568

69+
if(isProd) {
70+
autoUpdater.on("update-available", (info: UpdateInfo) => {
71+
setTimeout(() => {
72+
if(mainWindow) mainWindow.webContents.send('new-update', info.version)
73+
}, 6000)
74+
})
75+
76+
autoUpdater.checkForUpdatesAndNotify()
77+
}
78+
7679
setInterval(() => {
7780
if (mainWindow) mainWindow.webContents.send('update-version', app.getVersion())
7881
}, 5000)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"private": true,
33
"name": "lock-pass",
44
"description": "A simple password manager",
5-
"version": "1.1.1",
5+
"version": "1.1.2",
66
"author": "Nemika Hajbour <nemika@bytestobits.dev>",
77
"repository": {
88
"type": "git",

renderer/pages/main.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default () => {
3030
const [passValue, setPassValue] = useState(undefined)
3131
const [passList, setPassList] = useState({})
3232
const [showPass, setShowPass] = useState(false)
33+
const [outdated, setOutdated] = useState(false)
3334
const [version, setVersion] = useState("")
3435

3536
const [firstFetch, setFirstFetch] = useState(false)
@@ -46,6 +47,11 @@ export default () => {
4647
setPasswords()
4748
electron.ipcRenderer.on('update-version', (event, ver) => {
4849
setVersion(ver)
50+
if (outdated) setVersion(`${ver} (outdated)`)
51+
})
52+
53+
electron.ipcRenderer.on('new-update', (event, ver) => {
54+
setOutdated(true)
4955
})
5056
}
5157

0 commit comments

Comments
 (0)