mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-24 23:49:33 +01:00
fix: clear timeout on any update status change
This commit is contained in:
@@ -9,29 +9,32 @@ export default function useAutoUpdater() {
|
||||
const [status, setStatus] = useState();
|
||||
|
||||
useEffect(() => {
|
||||
function checkingForUpdate() {
|
||||
setStatus({ type: "checking" });
|
||||
|
||||
function changeStatus(status) {
|
||||
clearTimeout(checkingForUpdateTimeout);
|
||||
setStatus(status);
|
||||
}
|
||||
|
||||
function checkingForUpdate() {
|
||||
changeStatus({ type: "checking" });
|
||||
checkingForUpdateTimeout = setTimeout(() => {
|
||||
setStatus({ type: "updated" });
|
||||
changeStatus({ type: "updated" });
|
||||
}, 10000);
|
||||
}
|
||||
|
||||
function updateAvailable(info) {
|
||||
setStatus({ type: "available", version: info.version });
|
||||
changeStatus({ type: "available", version: info.version });
|
||||
}
|
||||
|
||||
function updateNotAvailable(info) {
|
||||
setStatus({ type: "updated" });
|
||||
changeStatus({ type: "updated" });
|
||||
}
|
||||
|
||||
function updateDownloadCompleted(info) {
|
||||
setStatus({ type: "completed", version: info.version });
|
||||
changeStatus({ type: "completed", version: info.version });
|
||||
}
|
||||
|
||||
function updateDownloadProgress(progressInfo) {
|
||||
setStatus({ type: "downloading", progress: progressInfo.percent });
|
||||
changeStatus({ type: "downloading", progress: progressInfo.percent });
|
||||
}
|
||||
|
||||
ElectronEventManager.subscribe(EVENTS.checkingForUpdate, checkingForUpdate);
|
||||
|
||||
Reference in New Issue
Block a user