diff options
| author | Dhravya Shah <[email protected]> | 2024-07-26 10:59:55 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-07-26 10:59:55 -0500 |
| commit | 1707103fdacb7b4fa5660ae6220f3bb1515fe435 (patch) | |
| tree | 9612d77531a8fa844f36ce610a4e7e26434714e7 | |
| parent | Merge pull request #140 from supermemoryai/kush/experimental-thread (diff) | |
| parent | Fix Spaces Breadcrumb (diff) | |
| download | supermemory-1707103fdacb7b4fa5660ae6220f3bb1515fe435.tar.xz supermemory-1707103fdacb7b4fa5660ae6220f3bb1515fe435.zip | |
Merge pull request #171 from JedPattersonn/jed/fix-breadcrumb
| -rw-r--r-- | apps/web/app/(dash)/(memories)/content.tsx | 15 | ||||
| -rw-r--r-- | apps/web/app/(dash)/header/autoBreadCrumbs.tsx | 27 |
2 files changed, 31 insertions, 11 deletions
diff --git a/apps/web/app/(dash)/(memories)/content.tsx b/apps/web/app/(dash)/(memories)/content.tsx index fea4477a..1e0bc5ca 100644 --- a/apps/web/app/(dash)/(memories)/content.tsx +++ b/apps/web/app/(dash)/(memories)/content.tsx @@ -33,6 +33,7 @@ import { addUserToSpace, deleteItem, moveItem } from "@/app/actions/doers"; import { toast } from "sonner"; import { Input } from "@repo/ui/shadcn/input"; import { motion } from "framer-motion"; +import { useSearchParams } from "next/navigation"; export function MemoriesPage({ memoriesAndSpaces, @@ -45,7 +46,19 @@ export function MemoriesPage({ currentSpace?: StoredSpace; usersWithAccess?: string[]; }) { - const [filter, setFilter] = useState("All"); + const searchParams = useSearchParams(); + + const tab = searchParams.get("tab"); + + const initialFilter = useMemo(() => { + if (tab === "spaces") return "Spaces"; + if (tab === "pages") return "Pages"; + if (tab === "notes") return "Notes"; + if (tab === "tweet") return "Tweet"; + return "All"; + }, [tab]); + + const [filter, setFilter] = useState(initialFilter); // Sort Both memories and spaces by their savedAt and createdAt dates respectfully. // The output should be just one single list of items diff --git a/apps/web/app/(dash)/header/autoBreadCrumbs.tsx b/apps/web/app/(dash)/header/autoBreadCrumbs.tsx index 671464ff..632daa61 100644 --- a/apps/web/app/(dash)/header/autoBreadCrumbs.tsx +++ b/apps/web/app/(dash)/header/autoBreadCrumbs.tsx @@ -27,16 +27,23 @@ function AutoBreadCrumbs() { {pathname .split("/") .filter(Boolean) - .map((path, idx, paths) => ( - <> - <BreadcrumbItem key={path + idx}> - <BreadcrumbLink href={`/${paths.slice(0, idx + 1).join("/")}`}> - {path.charAt(0).toUpperCase() + path.slice(1)} - </BreadcrumbLink> - </BreadcrumbItem> - <BreadcrumbSeparator hidden={idx === paths.length - 1} /> - </> - ))} + .map((path, idx, paths) => { + const isSpacePath = path === "space"; + const href = isSpacePath + ? `/memories?tab=spaces` + : `/${paths.slice(0, idx + 1).join("/")}`; + + return ( + <React.Fragment key={path + idx}> + <BreadcrumbItem> + <BreadcrumbLink href={href}> + {path.charAt(0).toUpperCase() + path.slice(1)} + </BreadcrumbLink> + </BreadcrumbItem> + <BreadcrumbSeparator hidden={idx === paths.length - 1} /> + </React.Fragment> + ); + })} </BreadcrumbList> </Breadcrumb> ); |