From 741afdeaa98c718648003d592f9586aea3c613fc Mon Sep 17 00:00:00 2001 From: Alois Date: Sun, 5 Apr 2026 12:15:15 +0200 Subject: [PATCH] Formatted, updated convs & comms list to not depend on each other, updated legal & login screen for better mobile support --- apps/web/src/components/screens/login/form.tsx | 15 ++++++++++----- apps/web/src/components/sidebar.tsx | 16 +++++++++++++++- apps/web/src/features/conversation/list/body.tsx | 15 ++++++--------- apps/web/src/features/legal/screen.tsx | 11 +++++++++-- apps/web/src/routes/app/home.tsx | 9 +++++++++ apps/web/src/routes/screens/login.tsx | 4 ++-- packages/chat/src/context.tsx | 2 +- packages/chat/src/screen.tsx | 2 +- packages/ui/src/lib/utils.ts | 2 +- 9 files changed, 54 insertions(+), 22 deletions(-) diff --git a/apps/web/src/components/screens/login/form.tsx b/apps/web/src/components/screens/login/form.tsx index 5cba5c0..32b2235 100644 --- a/apps/web/src/components/screens/login/form.tsx +++ b/apps/web/src/components/screens/login/form.tsx @@ -107,18 +107,23 @@ export default function Form() { const response = await fetch( `https://omega.tensamin.net/api/get/id/${inputParse.data.username}`, ); - const data = await response.json(); - const parse = fetchedUser.safeParse(data); + const rawData = await response.arrayBuffer(); + + const bytes = new Uint8Array(rawData); + const jsonString = new TextDecoder().decode(bytes); + const data = JSON.parse(jsonString); + + const parse = fetchedUser.shape.data.safeParse(data); if (!parse.success) { - log(0, "Login", "red", "Invalid response from server"); + log(0, "Login", "red", "Invalid response from server", parse.error); toast("error", "Invalid response from server"); return; } const user = parse.data; - await save("user_id", user.data.user_id); + await save("user_id", user.user_id); await save("private_key", inputParse.data.private_key); navigate({ to: "/" }); @@ -131,7 +136,7 @@ export default function Form() { ); return ( -
+
uploadRef.current?.click()} className="flex flex-col gap-3 cursor-pointer w-55 aspect-square bg-input/13 hover:bg-input/30 transition-all duration-300 ease-in-out border-3 items-center justify-center rounded-lg" diff --git a/apps/web/src/components/sidebar.tsx b/apps/web/src/components/sidebar.tsx index fab9543..16a4080 100644 --- a/apps/web/src/components/sidebar.tsx +++ b/apps/web/src/components/sidebar.tsx @@ -7,8 +7,12 @@ import List from "@/features/conversation/list/body"; import { Sidebar as SidebarRoot, SidebarContent, + SidebarFooter, } from "@tensamin/ui/cmp/sidebar"; import { isTauri } from "@tauri-apps/api/core"; +import { useIsMobile } from "@tensamin/ui/utils"; +import { MobileNavbar } from "./navbar"; +import { useLocation } from "@tanstack/react-router"; /** * Renders the conversation sidebar with account summary and conversation list. @@ -17,14 +21,19 @@ import { isTauri } from "@tauri-apps/api/core"; export default function Sidebar() { const [userId, setUserId] = React.useState(undefined); const { load } = useStorage(); + const isMobile = useIsMobile(); React.useEffect(() => { load("user_id").then(setUserId); }, [load]); + const location = useLocation(); + return ( - +
+ {isMobile && location.pathname === "/chat" && ( + + + + )} ); } diff --git a/apps/web/src/features/conversation/list/body.tsx b/apps/web/src/features/conversation/list/body.tsx index 0fec3c6..b552c7e 100644 --- a/apps/web/src/features/conversation/list/body.tsx +++ b/apps/web/src/features/conversation/list/body.tsx @@ -18,14 +18,12 @@ export default function List() { >("conversations"); const { conversations, communities } = useConversation(); + const items = category === "conversations" ? conversations : communities; const scrollRef = React.useRef(null); const virtualizer = useVirtualizer({ - count: - category === "conversations" - ? conversations?.length || 0 - : communities?.length || 0, + count: items?.length || 0, estimateSize: () => 60, getScrollElement: () => scrollRef.current, }); @@ -38,7 +36,7 @@ export default function List() { id="conversation-list" className="overflow-y-auto flex-1 h-full" > - {communities === null || conversations === null ? ( + {items === null ? (

@@ -52,8 +50,7 @@ export default function List() { height: `${virtualizer.getTotalSize()}px`, }} > - {communities && - conversations && + {items && virtualizer.getVirtualItems().map((virtualItem) => { const itemKey = `${category}-${virtualItem.index}`; @@ -69,12 +66,12 @@ export default function List() { }} > {category === "conversations" ? ( - conversations[virtualItem.index] ? ( + conversations?.[virtualItem.index] ? ( ) : null - ) : communities[virtualItem.index] ? ( + ) : communities?.[virtualItem.index] ? ( diff --git a/apps/web/src/features/legal/screen.tsx b/apps/web/src/features/legal/screen.tsx index 0a3643f..44c69c9 100644 --- a/apps/web/src/features/legal/screen.tsx +++ b/apps/web/src/features/legal/screen.tsx @@ -162,7 +162,7 @@ export default function Screen(props: { children: React.ReactNode }) { } return ( -

+

Privacy Policy & ToS @@ -173,11 +173,13 @@ export default function Screen(props: { children: React.ReactNode }) {
void; @@ -236,11 +240,14 @@ export function BigCheckbox({ return (
- +
); } diff --git a/apps/web/src/routes/app/home.tsx b/apps/web/src/routes/app/home.tsx index 8c757b3..dd45a57 100644 --- a/apps/web/src/routes/app/home.tsx +++ b/apps/web/src/routes/app/home.tsx @@ -15,9 +15,12 @@ import { useTTP } from "@tensamin/ttp/context"; import { useState } from "react"; import { Loader2 } from "lucide-react"; import { isTauri } from "@tauri-apps/api/core"; +import { useStorage } from "@tensamin/storage/context"; // The page export default function Page() { + const { clear } = useStorage(); + return (
@@ -25,6 +28,12 @@ export default function Page() { +
); } diff --git a/apps/web/src/routes/screens/login.tsx b/apps/web/src/routes/screens/login.tsx index 25fcccd..84b5d44 100644 --- a/apps/web/src/routes/screens/login.tsx +++ b/apps/web/src/routes/screens/login.tsx @@ -11,8 +11,8 @@ export default function Page() {
-

- Don't have an account yet? Click here to get help setting up an +

+ Don't have an account yet?{"\n"}Click here to get help setting up an Iota.

diff --git a/packages/chat/src/context.tsx b/packages/chat/src/context.tsx index e977105..283d574 100644 --- a/packages/chat/src/context.tsx +++ b/packages/chat/src/context.tsx @@ -223,7 +223,7 @@ export default function Provider(props: { children: ReactNode }) { { expected: userIdValue, received: nextState.chat_partner_id, - } + }, ); return; } diff --git a/packages/chat/src/screen.tsx b/packages/chat/src/screen.tsx index d4da8a1..fb09096 100644 --- a/packages/chat/src/screen.tsx +++ b/packages/chat/src/screen.tsx @@ -171,7 +171,7 @@ export default function Screen() { const host = scrollRef.current; if (!host || !el) return; - host.style.maxHeight = `calc(100vh - ${el.scrollHeight + 50}px)`; + host.style.maxHeight = `calc(100vh - ${el.scrollHeight + 50}px - env(safe-area-inset-bottom) - env(safe-area-inset-top))`; }, []); // Render diff --git a/packages/ui/src/lib/utils.ts b/packages/ui/src/lib/utils.ts index e6e6edb..fcd28e3 100644 --- a/packages/ui/src/lib/utils.ts +++ b/packages/ui/src/lib/utils.ts @@ -11,4 +11,4 @@ export function cn(...inputs: ClassValue[]) { } import { useIsMobile } from "../hooks/use-mobile"; -export { useIsMobile }; \ No newline at end of file +export { useIsMobile };