diff --git a/src/Roux/Html.hs b/src/Roux/Html.hs index 625fa48..4dde796 100644 --- a/src/Roux/Html.hs +++ b/src/Roux/Html.hs @@ -351,12 +351,12 @@ sseRecipeJs = , "if (!el) return;" , "var currentRecipe = el.textContent;" , "var es = new EventSource('/events');" - , "var lastReload = 0;" + , "var lastReload = parseInt(sessionStorage.getItem('roux-last-reload') || '0', 10);" , "es.addEventListener('recipe-changed', function(e) {" , " if (e.data !== currentRecipe) return;" , " var now = Date.now();" - , " if (now - lastReload < 2000) return;" - , " lastReload = now;" + , " if (now - lastReload < 3000) return;" + , " sessionStorage.setItem('roux-last-reload', String(now));" , " location.reload();" , "});" , "})();" @@ -370,11 +370,11 @@ sseIndexJs = , "'use strict';" , "if (!window.EventSource) return;" , "var es = new EventSource('/events');" - , "var lastReload = 0;" + , "var lastReload = parseInt(sessionStorage.getItem('roux-last-reload') || '0', 10);" , "es.addEventListener('recipe-changed', function() {" , " var now = Date.now();" - , " if (now - lastReload < 2000) return;" - , " lastReload = now;" + , " if (now - lastReload < 3000) return;" + , " sessionStorage.setItem('roux-last-reload', String(now));" , " location.reload();" , "});" , "})();"