From cc13cb09627934896fddaa9a2857256b7cf101dd Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Fri, 15 Sep 2023 13:31:44 +0200 Subject: [PATCH] feat(web): alert after one hour of inactivity --- main.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.js b/main.js index 68fca63..c2554e6 100644 --- a/main.js +++ b/main.js @@ -26,6 +26,7 @@ var codelanguages = ["xml", "js", "sql"]; var currentnote = null; var fileindex = 0; var workerid = null; +var inactivityid = null; var backup = ""; var localdata = null; var saved = true; @@ -1877,6 +1878,11 @@ function postpone() }); } +function inactivityalert() +{ + alert("Last save was one hour ago. Should you refresh?"); +} + async function save() { clearTimeout(workerid); @@ -1949,6 +1955,8 @@ async function save() { console.log("...data saved on server"); saved = true; + clearTimeout(inactivityid); + inactivityid = setTimeout(inactivityalert, 60 * 60 * 1000); }) .catch(remotecallfailed) .finally(() =>