jt-workspace-dashboard 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/dashboard.js +19 -5
  2. package/package.json +1 -1
package/dist/dashboard.js CHANGED
@@ -8,7 +8,7 @@
8
8
  const BASE_LABELS = Object.assign({today: "In progress", ready: "Paused", waiting: "Waiting", later: "Later", handoff: "Handoff", meeting: "Ask", question: "Question"}, CFG.labels || {});
9
9
  let LABELS = BASE_LABELS; // per workspace: BASE_LABELS + workspace.labels
10
10
  const OWNER_NAME = String(CFG.ownerName || "").slice(0, 40);
11
- const VERSION = "0.1.4";
11
+ const VERSION = "0.1.5";
12
12
 
13
13
  /* ---------- page skeleton ---------- */
14
14
  document.title = CFG.title || "Dashboard";
@@ -71,8 +71,12 @@
71
71
  dayData = calStored && calStored.date === isoDay(new Date()) ? calStored : null;
72
72
  statusDoc = null; renderStatus(); watchStatus();
73
73
  render();
74
- loadTasks(); loadCalendar();
74
+ if(!items.length && db){ readDbCache(w.id).then(list => { if(list && w === WS && !cache[w.id] && !items.length){ items = list; render(); } }); }
75
+ clearTimeout(slowTimer);
76
+ if(!items.length && mcp) slowTimer = setTimeout(() => { if(!items.length && w === WS) setStatus("Loading your to-dos…"); }, 1500);
77
+ if(mcp){ loadTasks(); loadCalendar(); }
75
78
  }
79
+ let slowTimer = null;
76
80
  function renderSwitcher(){
77
81
  const box = $("wsSwitch"); box.replaceChildren(); box.hidden = WORKSPACES.length < 2;
78
82
  WORKSPACES.forEach(w => { const b = el("button", null, w.name || w.id); b.type = "button"; b.setAttribute("aria-pressed", String(w === WS)); b.onclick = () => { if(w !== WS){ closeDrawer(); applyWorkspace(w); } }; box.append(b); });
@@ -105,7 +109,17 @@
105
109
  let db = null, mcp = null, items = [], canWrite = true, undoState = null, toastTimer = null, refreshTimer = null;
106
110
  const cache = {};
107
111
  const CACHE_V = 1;
108
- function saveCache(wsId, list){ try { localStorage.setItem("dash.cache." + wsId, JSON.stringify({v: CACHE_V, t: Date.now(), items: list})); } catch(_){} }
112
+ const lastSaved = {};
113
+ function saveCache(wsId, list){
114
+ const body = JSON.stringify(list);
115
+ if(lastSaved[wsId] === body) return; lastSaved[wsId] = body;
116
+ try { localStorage.setItem("dash.cache." + wsId, JSON.stringify({v: CACHE_V, t: Date.now(), items: list})); } catch(_){}
117
+ if(db && body.length < 400000){ try { db.doc("cache/" + wsId).set({v: CACHE_V, t: Date.now(), items: body}).catch(() => {}); } catch(_){} }
118
+ }
119
+ async function readDbCache(wsId){
120
+ if(!db) return null;
121
+ try { const sn = await db.doc("cache/" + wsId).get(); const c = sn && sn.exists ? sn.data() : null; return c && c.v === CACHE_V ? JSON.parse(c.items) : null; } catch(_){ return null; }
122
+ }
109
123
  function readCache(wsId){ try { const c = JSON.parse(localStorage.getItem("dash.cache." + wsId) || "null"); return c && c.v === CACHE_V && Array.isArray(c.items) ? c : null; } catch(_){ return null; } }
110
124
  const seenMap = store("pd.seen", {}), orderMap = store("pd.order", {});
111
125
  function saveSeen(id, t){ seenMap[id] = t; save("pd.seen", seenMap); }
@@ -751,11 +765,11 @@
751
765
  /* ---------- start ---------- */
752
766
  WS = pickInitial();
753
767
  setView(view); setActiveOnly(activeOnly);
768
+ applyWorkspace(WS); // paint the last known tasks right away, before the connectors are ready
754
769
  (async () => {
755
770
  const use = n => (window.claude && window.claude.use) ? window.claude.use(n).catch(() => null) : Promise.resolve(null);
756
771
  [db, mcp] = await Promise.all([use("db"), use("mcp")]);
757
- if(!mcp){ canWrite = false; applyWorkspace(WS); $("refreshed").textContent = "Open this page in Claude to see your dashboard."; return; }
758
- if(!cache[WS.id] && !readCache(WS.id)) setStatus("Loading your to-dos…");
772
+ if(!mcp){ canWrite = false; render(); $("refreshed").textContent = "Open this page in Claude to see your dashboard."; return; }
759
773
  applyWorkspace(WS);
760
774
  setInterval(loadTasks, 120000);
761
775
  let calDay = new Date().toDateString();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jt-workspace-dashboard",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Shared code for Jeremy's Claude dashboards: a Todoist + Google Calendar consolidator with workspaces.",
5
5
  "main": "dist/dashboard.js",
6
6
  "files": [