Skip to content
Merged
Show file tree
Hide file tree
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

Large diffs are not rendered by default.

29 changes: 14 additions & 15 deletions client-dist/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>FreemanNotes</title>
<link rel="icon" href="/icons/darkicon.png" type="image/png" />
<link rel="manifest" href="/assets/manifest-DdfYsMAL.webmanifest" />
<script type="module" crossorigin src="/assets/index-C-10yejU.js"></script>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>FreemanNotes — Phase 1</title>
<link rel="icon" href="/icons/darkicon.png" type="image/png" />
<link rel="manifest" href="/assets/manifest-DdfYsMAL.webmanifest" />
<script type="module" crossorigin src="/assets/index-CIHictPt.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-zH6tZKqf.css">
</head>
<body>
<div id="root"></div>

</body>
</html>
</head>
<body>
<div id="root"></div>
</body>
</html>
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/MoveToCollectionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ export default function MoveToCollectionModal({
const data = await res.json();
const createdId = Number((data as any)?.collection?.id);
if (Number.isFinite(createdId)) {
try {
window.dispatchEvent(new CustomEvent('collections:changed', { detail: { invalidateAll: true, reason: 'create', id: createdId } }));
} catch {}
try { setCreatingName(''); } catch {}
setBusy(false);
await addTo(createdId);
Expand Down
27 changes: 27 additions & 0 deletions client/src/components/NoteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,33 @@ export default function NoteCard({
const fileRef = useRef<HTMLInputElement | null>(null);
const { token, user } = useAuth();

React.useEffect(() => {
const onCollectionsChanged = (ev: Event) => {
try {
const ce = ev as CustomEvent<any>;
const detail = ce?.detail || {};
if (detail?.invalidateAll) {
setCollectionPathById({});
return;
}
const ids = Array.isArray(detail?.ids) ? detail.ids : (Number.isFinite(Number(detail?.id)) ? [Number(detail.id)] : []);
if (!ids.length) return;
setCollectionPathById((prev) => {
const next = { ...prev };
for (const id of ids) {
try { delete (next as any)[Number(id)]; } catch {}
}
return next;
});
} catch {}
};

try { window.addEventListener('collections:changed', onCollectionsChanged as any); } catch {}
return () => {
try { window.removeEventListener('collections:changed', onCollectionsChanged as any); } catch {}
};
}, []);

const neededCollectionIdsKey = React.useMemo(() => {
try {
const ids = viewerCollections
Expand Down
12 changes: 12 additions & 0 deletions client/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ export default function Sidebar({
});
if (!res.ok) throw new Error(await res.text());
try { setNewCollectionName(''); } catch {}
// New collections can affect breadcrumb paths and descendant display.
try {
window.dispatchEvent(new CustomEvent('collections:changed', { detail: { invalidateAll: true, reason: 'create' } }));
} catch {}
await refreshCollections();
} catch (err) {
window.alert('Failed to create collection: ' + String(err));
Expand All @@ -237,6 +241,10 @@ export default function Sidebar({
body: JSON.stringify({ name: next }),
});
if (!res.ok) throw new Error(await res.text());
// Notify other UI surfaces (e.g., note collection chips) to invalidate any cached paths.
try {
window.dispatchEvent(new CustomEvent('collections:changed', { detail: { invalidateAll: true, reason: 'rename', id: Number(id) } }));
} catch {}
// Update stack display names if needed.
try {
const stack = Array.isArray(collectionStack) ? collectionStack : [];
Expand All @@ -260,6 +268,10 @@ export default function Sidebar({
try {
const res = await fetch(`/api/collections/${encodeURIComponent(String(id))}`, { method: 'DELETE', headers: { Authorization: `Bearer ${token}` } });
if (!res.ok) throw new Error(await res.text());
// Deleting can invalidate any cached breadcrumb paths for this subtree.
try {
window.dispatchEvent(new CustomEvent('collections:changed', { detail: { invalidateAll: true, reason: 'delete', id: Number(id) } }));
} catch {}
// If we deleted the current path (or an ancestor), pop back to root.
try {
const stack = Array.isArray(collectionStack) ? collectionStack : [];
Expand Down