-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Notification on disconnect & rework offline page
- Loading branch information
1 parent
159f569
commit 4d217ac
Showing
4 changed files
with
76 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { ipcRenderer } = require('electron'); | ||
|
||
const times = [5, 10, 30, 60]; | ||
let index = 0; | ||
let counter = times[index]; | ||
let timeout; | ||
const retryText = document.getElementById('retry-text'); | ||
const retryButton = document.getElementById('retry-button'); | ||
|
||
function resetCounter() { | ||
retryButton.disabled = false; | ||
if(index < times.length - 1) { | ||
index++; | ||
} | ||
counter = times[index]; | ||
count(); | ||
} | ||
|
||
function liveCheck() { | ||
retryButton.disabled = true; | ||
retryText.innerHTML = 'Retrying...'; | ||
ipcRenderer.send('liveCheck'); | ||
// setTimeout(resetCounter, 2000); | ||
} | ||
|
||
function count() { | ||
if(counter > 0) { | ||
retryText.innerHTML = `Retrying in ${counter} seconds`; | ||
timeout = setTimeout(() => { | ||
counter--; | ||
count(); | ||
}, 1000); | ||
} else { | ||
liveCheck(); | ||
} | ||
} | ||
|
||
ipcRenderer.on('offline', resetCounter); | ||
retryButton.addEventListener('click', () => { | ||
clearTimeout(timeout); | ||
liveCheck(); | ||
}); | ||
count(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters