Updated icons, new identification
This commit is contained in:
parent
00a1bee73e
commit
7adb2dee05
34 changed files with 331 additions and 402 deletions
|
|
@ -4,7 +4,6 @@ import { useLocation, useNavigate, useSearch } from "@tanstack/react-router";
|
|||
import { useCall } from "@tensamin/call/context";
|
||||
import Wrapper from "@tensamin/user/wrapper";
|
||||
import { Skeleton } from "@tensamin/ui/cmp/skeleton";
|
||||
import { useConversation } from "@/features/conversation/context";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
|
|
@ -14,16 +13,17 @@ import {
|
|||
import { displayCallId } from "@tensamin/call/utils";
|
||||
import { useState } from "react";
|
||||
import { SidebarTrigger, useSidebar } from "@tensamin/ui/cmp/sidebar";
|
||||
import { useTTP } from "@tensamin/ttp/context";
|
||||
|
||||
export default function Navbar({ forMobile }: { forMobile: boolean }) {
|
||||
const navigate = useNavigate();
|
||||
const { joinCall, state } = useCall();
|
||||
const { conversations } = useConversation();
|
||||
const { contacts } = useTTP();
|
||||
|
||||
const { pathname } = useLocation();
|
||||
const { id } = useSearch({ strict: false });
|
||||
|
||||
const currentCalls = id ? conversations?.[id]?.calls || [] : [];
|
||||
const currentCalls = id ? contacts?.[id]?.calls || [] : [];
|
||||
//const currentCalls = ["leck", "schleck", "und", "eck"];
|
||||
|
||||
const [selectOpen, setSelectOpen] = useState(false);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { Input } from "@tensamin/ui/cmp/input";
|
|||
import { Label } from "@tensamin/ui/cmp/label";
|
||||
import { useStorage } from "@tensamin/storage/context";
|
||||
import { log, toast } from "@tensamin/shared/log";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { Upload } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { z } from "zod";
|
||||
|
|
@ -55,7 +54,6 @@ function parseTuFileContent(rawFileContent: string): {
|
|||
export default function Form() {
|
||||
const uploadRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const { save } = useStorage();
|
||||
const navigate = useNavigate();
|
||||
|
||||
/**
|
||||
* Handles uploaded .tu files and stores resolved credentials.
|
||||
|
|
@ -73,16 +71,17 @@ export default function Form() {
|
|||
const raw = await file.text();
|
||||
const parsed = parseTuFileContent(raw);
|
||||
|
||||
await save("session_id", Date.now());
|
||||
await save("user_id", parsed.userId);
|
||||
await save("private_key", parsed.privateKey);
|
||||
|
||||
void navigate({ to: "/" });
|
||||
location.href = "/";
|
||||
} catch (error) {
|
||||
log(0, "Login", "red", error);
|
||||
toast("error", "Failed to load file");
|
||||
}
|
||||
},
|
||||
[navigate, save],
|
||||
[save],
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
@ -123,16 +122,17 @@ export default function Form() {
|
|||
|
||||
const user = parse.data;
|
||||
|
||||
await save("session_id", Date.now());
|
||||
await save("user_id", user.user_id);
|
||||
await save("private_key", inputParse.data.private_key);
|
||||
|
||||
navigate({ to: "/" });
|
||||
location.href = "/";
|
||||
} catch (error) {
|
||||
log(0, "Login", "red", error);
|
||||
toast("error", "Failed to fetch user data");
|
||||
}
|
||||
},
|
||||
[navigate, save],
|
||||
[save],
|
||||
);
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,102 +0,0 @@
|
|||
import { useTTP } from "@tensamin/ttp/context";
|
||||
import {
|
||||
createContext,
|
||||
useContext,
|
||||
useEffect,
|
||||
useState,
|
||||
type ReactNode,
|
||||
} from "react";
|
||||
|
||||
import { toast } from "@tensamin/shared/log";
|
||||
import type {
|
||||
Community,
|
||||
Conversation,
|
||||
} from "@tensamin/shared/features/conversation/schema";
|
||||
|
||||
interface contextValue {
|
||||
conversations: Conversation[] | null;
|
||||
communities: Community[] | null;
|
||||
}
|
||||
|
||||
const ConversationContext = createContext<contextValue | undefined>(undefined);
|
||||
|
||||
/**
|
||||
* Executes ConversationProvider.
|
||||
* @param props Parameter props.
|
||||
* @returns unknown.
|
||||
*/
|
||||
export default function ConversationProvider(props: { children: ReactNode }) {
|
||||
const [conversations, setConversations] = useState<Conversation[] | null>(
|
||||
null,
|
||||
);
|
||||
const [communities, setCommunities] = useState<Community[] | null>(null);
|
||||
|
||||
const { send } = useTTP();
|
||||
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
|
||||
send("get_conversations", {})
|
||||
.then((data) => {
|
||||
if (active) {
|
||||
setConversations(data.data.user_ids);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
setConversations([
|
||||
{
|
||||
last_message_at: 0,
|
||||
user_id: 0,
|
||||
},
|
||||
]);
|
||||
toast("error", "Failed to load conversations");
|
||||
});
|
||||
|
||||
send("get_communities", {})
|
||||
.then((data) => {
|
||||
if (active) {
|
||||
setCommunities(data.data.communities);
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
setCommunities([
|
||||
{
|
||||
community_address: "none",
|
||||
community_title: "Failed",
|
||||
position: "",
|
||||
},
|
||||
]);
|
||||
toast("error", "Failed to load communities");
|
||||
});
|
||||
|
||||
return () => {
|
||||
active = false;
|
||||
};
|
||||
}, [send]);
|
||||
|
||||
return (
|
||||
<ConversationContext.Provider
|
||||
value={{
|
||||
conversations,
|
||||
communities,
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
</ConversationContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes useConversation.
|
||||
* @param none This function has no parameters.
|
||||
* @returns contextValue.
|
||||
*/
|
||||
export function useConversation(): contextValue {
|
||||
const context = useContext(ConversationContext);
|
||||
if (!context) {
|
||||
throw new Error(
|
||||
"useConversation must be used within a ConversationProvider",
|
||||
);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from "react";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import { useConversation } from "../context";
|
||||
import { useTTP } from "@tensamin/ttp/context";
|
||||
|
||||
import Switch from "./switch";
|
||||
import ConversationModal from "../modal/conversation";
|
||||
|
|
@ -17,8 +17,8 @@ export default function List() {
|
|||
"conversations" | "communities"
|
||||
>("conversations");
|
||||
|
||||
const { conversations, communities } = useConversation();
|
||||
const items = category === "conversations" ? conversations : communities;
|
||||
const { contacts, communities } = useTTP();
|
||||
const items = category === "conversations" ? contacts : communities;
|
||||
|
||||
const scrollRef = React.useRef<HTMLDivElement | null>(null);
|
||||
|
||||
|
|
@ -66,14 +66,14 @@ export default function List() {
|
|||
}}
|
||||
>
|
||||
{category === "conversations" ? (
|
||||
conversations?.[virtualItem.index] ? (
|
||||
contacts?.[virtualItem.index] ? (
|
||||
<ConversationModal
|
||||
userId={conversations[virtualItem.index].user_id}
|
||||
userId={contacts[virtualItem.index].user_id}
|
||||
/>
|
||||
) : null
|
||||
) : communities?.[virtualItem.index] ? (
|
||||
<CommunityModal
|
||||
community={communities[virtualItem.index]}
|
||||
//community={communities[virtualItem.index]}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,10 +1,3 @@
|
|||
import type { Community } from "@tensamin/shared/features/conversation/schema";
|
||||
|
||||
/**
|
||||
* Executes CommunityModal.
|
||||
* @param props Parameter props.
|
||||
* @returns unknown.
|
||||
*/
|
||||
export default function CommunityModal(props: { community: Community }) {
|
||||
return <div>{props.community.community_title}</div>;
|
||||
export default function CommunityModal() {
|
||||
return <div>Not implemented</div>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@
|
|||
--chart-3: oklch(0.6 0.118 184.704);
|
||||
--chart-4: oklch(0.511 0.096 186.391);
|
||||
--chart-5: oklch(0.437 0.078 188.216);
|
||||
--sidebar: oklch(0.190 0 0);
|
||||
--sidebar: oklch(0.19 0 0);
|
||||
--sidebar-foreground: oklch(0.985 0 0);
|
||||
--sidebar-primary: oklch(0.704 0.14 182.503);
|
||||
--sidebar-primary-foreground: oklch(0.277 0.046 192.524);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import CallScreen from "@tensamin/call/screen";
|
|||
import Login from "@/routes/screens/login";
|
||||
import Signup from "@/routes/screens/signup";
|
||||
|
||||
import ConversationContext from "@/features/conversation/context";
|
||||
import ChatContext from "@tensamin/chat/context";
|
||||
import CallContext from "@tensamin/call/context";
|
||||
import SocketContext from "@tensamin/ttp/context";
|
||||
|
|
@ -57,11 +56,9 @@ function AppShell() {
|
|||
<SocketContext>
|
||||
<UserContext>
|
||||
<CallContext>
|
||||
<ConversationContext>
|
||||
<AppLayout>
|
||||
<Outlet />
|
||||
</AppLayout>
|
||||
</ConversationContext>
|
||||
<AppLayout>
|
||||
<Outlet />
|
||||
</AppLayout>
|
||||
</CallContext>
|
||||
</UserContext>
|
||||
</SocketContext>
|
||||
|
|
|
|||
Loading…
Reference in a new issue