diff --git a/src/App.tsx b/src/App.tsx index 3f7d97e..45fbf04 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,6 +9,7 @@ import { } from "./components/ui/resizable"; import Sidebar from "./components/view/Sidebar"; import { ThemeProvider } from "next-themes"; +import Page from "./components/page/PageView"; export default function App() { const appRef = useRef(null); @@ -50,7 +51,7 @@ export default function App() { -
+
diff --git a/src/app/app.ts b/src/app/app.ts index 98eb5b2..a5faf56 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -6,6 +6,7 @@ import { base58 } from "@scure/base"; import axios from "axios"; import { Account, AccountsFile, getAccounts } from "@/lib/accounts"; +import { Page } from "@/lib/page"; ed.hashes.sha512 = sha512; @@ -22,11 +23,12 @@ ed.hashes.sha512 = sha512; * should stay a pure display of what `Enclave` exposes — it should not * reach into `EnclaveServer` or `EnclaveWebSocket` directly. */ -export default class Enclave { +export default class Enclave

{ public accounts?: AccountsFile; public server?: EnclaveServer; public serverList: ServerList; public forceRender: () => void; + public page?: P; public constructor() { this.serverList = {}; diff --git a/src/components/page/PageView.tsx b/src/components/page/PageView.tsx new file mode 100644 index 0000000..311fe5a --- /dev/null +++ b/src/components/page/PageView.tsx @@ -0,0 +1,24 @@ +import Enclave from "@/app/app"; +import ChannelPage from "./channel/ChannelPage"; +import { Channel } from "@/app/protocol"; + +export type ChannelPageProps = { + kind: "channel"; + channel: Channel; +}; + +export type Page = ChannelPageProps; + +export default function Page({ + appRef, +}: { + appRef: React.RefObject; +}) { + switch (appRef.current?.page?.kind) { + case "channel": + return ; + + default: + return null; + } +} diff --git a/src/components/page/channel/ChannelPage.tsx b/src/components/page/channel/ChannelPage.tsx new file mode 100644 index 0000000..35ef626 --- /dev/null +++ b/src/components/page/channel/ChannelPage.tsx @@ -0,0 +1,16 @@ +import Enclave from "@/app/app"; +import { ChannelPageProps } from "@/lib/page"; + +export default function ChannelPage({ + appRef, +}: { + appRef: React.RefObject | null>; +}) { + switch (appRef.current?.page?.channel.kind) { + case "text": + return ; + + default: + return null; + } +} diff --git a/src/components/page/channel/TextChannel.tsx b/src/components/page/channel/TextChannel.tsx new file mode 100644 index 0000000..e57dc4a --- /dev/null +++ b/src/components/page/channel/TextChannel.tsx @@ -0,0 +1,10 @@ +import Enclave from "@/app/app"; +import { ChannelPageProps } from "@/components/page/PageView"; + +export default function TextChannel({ + appRef, +}: { + appRef: React.RefObject | null>; +}) { + return

{appRef.current?.page?.channel.name}
; +}