autosync toggle, configurable sync interval, 30-day session
- header Sync button now has a paired autosync toggle to its right — reads as one button with no inner seam (outer border only). Dot inside pulses once per actual sync (bursts on every backgroundSync / triggerSync / collab pollOnce via a new sync.pulse hook) so the user can see polls happen. Dot + data-autosync attribute persist the enabled state in localStorage; paused state stops both the CalDAV/relay background timer and the collab poll via a broadcast autosync.changed hook. - hover polish: Sync regains a full accent border (the missing inner edge re-appears only on its hover); the toggle fills with solid accent as hover treatment so the pair never shows a half-outline. - sync interval moved out of hardcode into a settings field under Settings → Relay: number input, 5s..3600s, default 15s (was 45s on caldav / 30s on collab). Changes broadcast via sync.interval.changed and restart both timers without reload. - session cookie lifetime raised to 30 days with matching gc_maxlifetime and SameSite=Lax (was 0 / Strict — some users got kicked to login on every reload when gc cleaned up the /tmp/sess file or a cross-link return blocked the cookie). - search button's kbd element was pushing the button ~3px taller than Sync; leading-none + tighter padding puts them on the same height. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
6cd00f9660
commit
b7f450e41f
6 files changed
+222
-12
No files matched your search
@@ -27,7 +27,13 @@ let collabByUid = new Map();
|
||||
// card_id (number) -> true for cards with foreign edits we haven't opened yet
|
||||
let unreadCards = new Set();
|
||||
let pollHandle = null;
|
||||
const POLL_INTERVAL_MS = 30000;
|
||||
// The core CalDAV/relay sync cadence (Settings → Relay → Sync frequency,
|
||||
// default 15s) also drives the collab poll. Users can dial up or down
|
||||
// without touching code. Defaults + clamp mirror the core helper.
|
||||
function getPollIntervalMs() {
|
||||
const v = parseInt(localStorage.getItem('hyprcrd-sync-interval-sec'));
|
||||
return (Number.isFinite(v) && v >= 5 ? v : 15) * 1000;
|
||||
}
|
||||
|
||||
// Phase 4: edit locks (now exclusive — server-enforced)
|
||||
// card_uid -> { bucket_uid, holder_username, expires_at }
|
||||
@@ -69,6 +75,7 @@ async function pollOnce() {
|
||||
if (document.getElementById('modal')?.classList.contains('open')) return;
|
||||
try {
|
||||
pollLocked = true;
|
||||
hyprcrd.hooks?.emit?.('sync.pulse');
|
||||
const res = await hyprcrd.api('api/collab-buckets/poll', { method: 'POST' });
|
||||
if (!res?.ok) return;
|
||||
if (res.self) window._collabSelf = res.self;
|
||||
@@ -166,12 +173,23 @@ function showQueuedToast(message) {
|
||||
|
||||
function startPolling() {
|
||||
stopPolling();
|
||||
pollHandle = setInterval(pollOnce, POLL_INTERVAL_MS);
|
||||
pollHandle = setInterval(pollOnce, getPollIntervalMs());
|
||||
}
|
||||
function stopPolling() {
|
||||
if (pollHandle) { clearInterval(pollHandle); pollHandle = null; }
|
||||
}
|
||||
|
||||
// Restart when the user changes the sync interval in settings.
|
||||
hyprcrd.hooks?.on?.('sync.interval.changed', () => {
|
||||
if (pollHandle) startPolling();
|
||||
});
|
||||
|
||||
// Pause / resume alongside the header autosync toggle.
|
||||
hyprcrd.hooks?.on?.('autosync.changed', (on) => {
|
||||
if (on) startPolling();
|
||||
else stopPolling();
|
||||
});
|
||||
|
||||
// ── Bucket bar decoration ─────────────────────────────────────────
|
||||
|
||||
/**
|
||||
@@ -974,7 +992,9 @@ async function init() {
|
||||
decorateBucketBar();
|
||||
decorateBoardLocks();
|
||||
decorateBoardUnread();
|
||||
startPolling();
|
||||
// Respect the header autosync toggle — if the user has paused it,
|
||||
// skip the recurring poll entirely. Hook above restarts when toggled.
|
||||
if (localStorage.getItem('hyprcrd-autosync-enabled') !== '0') startPolling();
|
||||
}
|
||||
|
||||
// Defer init until the CSRF token is live — `checkAuth()` sets it async on
|
||||
|
||||
Reference in new issue
Block a user