diff --git a/src/app/app.ts b/src/app/app.ts index a5faf56..476962c 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -6,7 +6,7 @@ import { base58 } from "@scure/base"; import axios from "axios"; import { Account, AccountsFile, getAccounts } from "@/lib/accounts"; -import { Page } from "@/lib/page"; +import { Page } from "@/components/page/PageView"; ed.hashes.sha512 = sha512; diff --git a/src/components/page/channel/ChannelPage.tsx b/src/components/page/channel/ChannelPage.tsx index 35ef626..0287f87 100644 --- a/src/components/page/channel/ChannelPage.tsx +++ b/src/components/page/channel/ChannelPage.tsx @@ -1,5 +1,5 @@ import Enclave from "@/app/app"; -import { ChannelPageProps } from "@/lib/page"; +import { ChannelPageProps } from "@/components/page/PageView"; export default function ChannelPage({ appRef, diff --git a/src/components/view/Sidebar.tsx b/src/components/view/Sidebar.tsx index 5c959f5..eb0c94d 100644 --- a/src/components/view/Sidebar.tsx +++ b/src/components/view/Sidebar.tsx @@ -3,6 +3,7 @@ import { Channel, ChannelKind } from "@/app/protocol"; import { ChevronDown, ChevronUp, HashIcon } from "lucide-react"; import { useState } from "react"; import AccountCard from "./AccountCard"; +import { cn } from "@/lib/utils"; export function ChannelIcon({ kind }: { kind: ChannelKind["kind"] }) { switch (kind) { @@ -13,7 +14,13 @@ export function ChannelIcon({ kind }: { kind: ChannelKind["kind"] }) { } } -export function RenderCategory({ channel }: { channel: Channel }) { +export function RenderCategory({ + appRef, + channel, +}: { + appRef: React.RefObject; + channel: Channel; +}) { if (channel.kind !== "category") return null; const [open, setOpen] = useState(true); @@ -33,19 +40,41 @@ export function RenderCategory({ channel }: { channel: Channel }) { {open && (
- +
)} ); } -export function RenderChannels({ channels }: { channels: Channel[] }) { +export function RenderChannels({ + appRef, + channels, +}: { + appRef: React.RefObject; + channels: Channel[]; +}) { return channels.map((channel) => channel.kind === "category" ? ( - + ) : ( -
+
{ + if (!appRef.current) { + console.error("AppRef is not initialized yet"); + return; + } + + appRef.current.page = { kind: "channel", channel }; + + appRef.current.forceRender(); + }} + > {channel.name}
@@ -67,7 +96,10 @@ export default function Sidebar({
- +
)}