diff --git a/static/app.js b/static/app.js
index 60ac6de..4652fe4 100644
--- a/static/app.js
+++ b/static/app.js
@@ -2377,26 +2377,33 @@ function sharedCTABanner() {
`;
}
-async function initSharedView() {
- document.body.classList.add('shared-view');
- document.getElementById('auth-screen').style.display = 'none';
- document.getElementById('guest-banner').style.display = 'none';
-
+async function fetchSharedData() {
try {
const r = await fetch(`/shared/${SHARED_TOKEN}/data`);
- if (!r.ok) {
- document.getElementById('app').innerHTML = sharedCTABanner() +
- '
Shared profile not found.
';
- return;
- }
+ if (!r.ok) return false;
data = await r.json();
ensureDataShape();
- if (data.theme) {
- localStorage.setItem(THEME_KEY, data.theme);
- applyTheme();
- }
+ return true;
} catch {
- data = { tasks: [], later: [], projects: [] };
+ return false;
+ }
+}
+
+async function initSharedView() {
+ document.body.classList.add('shared-view');
+ document.getElementById('auth-screen').style.display = 'none';
+ document.getElementById('guest-banner').style.display = 'none';
+
+ const ok = await fetchSharedData();
+ if (!ok) {
+ document.getElementById('app').innerHTML = sharedCTABanner() +
+ 'Shared profile not found.
';
+ return;
+ }
+
+ if (data.theme) {
+ localStorage.setItem(THEME_KEY, data.theme);
+ applyTheme();
}
// Insert CTA before the app content
@@ -2410,6 +2417,11 @@ async function initSharedView() {
render();
ensureTick();
+
+ // Poll for live updates
+ setInterval(async () => {
+ if (await fetchSharedData()) { render(); }
+ }, 5000);
}
async function initSharedDonePage() {