Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2377,26 +2377,33 @@ function sharedCTABanner() {
</div>`;
}

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() +
'<div class="done-page"><div class="done-empty">Shared profile not found.</div></div>';
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() +
'<div class="done-page"><div class="done-empty">Shared profile not found.</div></div>';
return;
}

if (data.theme) {
localStorage.setItem(THEME_KEY, data.theme);
applyTheme();
}

// Insert CTA before the app content
Expand All @@ -2410,6 +2417,11 @@ async function initSharedView() {

render();
ensureTick();

// Poll for live updates
setInterval(async () => {
if (await fetchSharedData()) { render(); }
}, 5000);
}

async function initSharedDonePage() {
Expand Down
Loading