diff --git a/src/views/repo.tsx b/src/views/repo.tsx index af78642..27347bf 100644 --- a/src/views/repo.tsx +++ b/src/views/repo.tsx @@ -195,6 +195,25 @@ export const RepoView = () => { const [repo] = createResource(fetchRepo); + const toggleCollapsed = (authority: string) => { + setNsids((prev) => ({ + ...prev!, + [authority]: { ...prev![authority], hidden: !prev![authority].hidden }, + })); + }; + + const collapseAll = () => { + setNsids((prev) => + Object.fromEntries(Object.entries(prev!).map(([k, v]) => [k, { ...v, hidden: true }])), + ); + }; + + const expandAll = () => { + setNsids((prev) => + Object.fromEntries(Object.entries(prev!).map(([k, v]) => [k, { ...v, hidden: false }])), + ); + }; + const validateHandles = async () => { for (const alias of didDoc()?.alsoKnownAs ?? []) { if (alias.startsWith("at://")) @@ -429,7 +448,7 @@ export const RepoView = () => { -
+
No collections found.} @@ -446,11 +465,12 @@ export const RepoView = () => { > {(authority) => { const isHighlighted = () => location.hash === `#collections:${authority}`; + const isCollapsed = () => nsids()?.[authority].hidden ?? false; return (
{ )} /> -
- - filter() ? `${authority}.${nsid}`.includes(filter()!) : true, - )} + toggleCollapsed(authority)} + > + + {authority}. + + * + + ({nsids()?.[authority].nsids.length}) + + + } + > +
+ + filter() ? `${authority}.${nsid}`.includes(filter()!) : true, + )} + > + {(nsid, index) => ( + + + {authority}. + + {nsid} + + )} + +
+
+ +
+ {isCollapsed() ? "expand" : "collapse"} + +
); }} @@ -749,9 +796,9 @@ export const RepoView = () => {
-
+
{ const input = e.currentTarget.querySelector("input"); if (e.target !== input) input?.focus(); @@ -776,6 +823,20 @@ export const RepoView = () => {
+
+ + +