Sync immediately on app window focus

This commit is contained in:
Adrian Gruntkowski 2025-11-09 12:48:03 +01:00
parent 2e0d7d044b
commit 8d12c66141
2 changed files with 8 additions and 7 deletions

View file

@ -54,7 +54,6 @@
</form> </form>
<div id="notifications-pane" class="hidden"> <div id="notifications-pane" class="hidden">
<!-- Hidden for now, until push notifications are implemented -->
<button id="enable-notifications" class="hidden"> <button id="enable-notifications" class="hidden">
Enable notifications Enable notifications
</button> </button>

View file

@ -54,6 +54,8 @@ const sync = async () => {
Notes.saveStorage(); Notes.saveStorage();
}; };
window.addEventListener("focus", sync);
if (isLoggedIn) { if (isLoggedIn) {
setInterval(sync, 5000); setInterval(sync, 5000);
} }
@ -76,7 +78,7 @@ if (!isLoggedIn) {
if (notificationsAvailable()) { if (notificationsAvailable()) {
document.querySelector("#notifications-pane").classList.remove("hidden"); document.querySelector("#notifications-pane").classList.remove("hidden");
const notificationsButton = document.querySelector("#enable-notifications"); const notificationsButton = document.querySelector("#enable-notifications");
const notificationsTestButton = document.querySelector("#test-notifications"); // const notificationsTestButton = document.querySelector("#test-notifications");
if (!notificationsEnabled()) { if (!notificationsEnabled()) {
notificationsButton.classList.remove("hidden"); notificationsButton.classList.remove("hidden");
@ -85,11 +87,11 @@ if (notificationsAvailable()) {
}); });
} }
notificationsTestButton.addEventListener("click", () => { // notificationsTestButton.addEventListener("click", () => {
setTimeout(() => { // setTimeout(() => {
sendNotification("reminder", "This is a test reminder!"); // sendNotification("reminder", "This is a test reminder!");
}, 8000); // }, 8000);
}); // });
} }
// Search // Search