From f1101953567d4ba7aeedfac3af596bf48a7a4ce3 Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 20 Mar 2022 20:03:29 -0400 Subject: [PATCH] better display of status and all separately --- .../components/User/userAvatarWithStatus.tsx | 36 +++++++++++++++ .../src/components/User/userStatusText.tsx | 16 +++++++ .../src/pages/Home/conversations/index.tsx | 45 ++++++++++++++----- .../desktop/src/pages/Home/header/index.tsx | 14 +++--- 4 files changed, 90 insertions(+), 21 deletions(-) create mode 100644 packages/desktop/src/components/User/userAvatarWithStatus.tsx create mode 100644 packages/desktop/src/components/User/userStatusText.tsx diff --git a/packages/desktop/src/components/User/userAvatarWithStatus.tsx b/packages/desktop/src/components/User/userAvatarWithStatus.tsx new file mode 100644 index 0000000..92aab57 --- /dev/null +++ b/packages/desktop/src/components/User/userAvatarWithStatus.tsx @@ -0,0 +1,36 @@ +import { User, UserStatus } from "@nirvana/core/models"; + +export default function UserAvatarWithStatus(props: { user: User }) { + return ( + + + + + + ); +} + +export function UserStatusBubble(props: { status: UserStatus }) { + switch (props.status) { + case UserStatus.ONLINE: + return ( + + ); + case UserStatus.OFFLINE: + return ( + + ); + case UserStatus.FLOW_STATE: + return ( + + ); + default: + return ( + + ); + } +} diff --git a/packages/desktop/src/components/User/userStatusText.tsx b/packages/desktop/src/components/User/userStatusText.tsx new file mode 100644 index 0000000..571957e --- /dev/null +++ b/packages/desktop/src/components/User/userStatusText.tsx @@ -0,0 +1,16 @@ +import { UserStatus } from "@nirvana/core/models"; + +export default function UserStatusText(props: { status: UserStatus }) { + switch (props.status) { + case UserStatus.ONLINE: + return ONLINE; + case UserStatus.OFFLINE: + return <>; + case UserStatus.FLOW_STATE: + return ( + FLOW STATE + ); + default: + return <>; + } +} diff --git a/packages/desktop/src/pages/Home/conversations/index.tsx b/packages/desktop/src/pages/Home/conversations/index.tsx index 117d879..67068ad 100644 --- a/packages/desktop/src/pages/Home/conversations/index.tsx +++ b/packages/desktop/src/pages/Home/conversations/index.tsx @@ -1,23 +1,32 @@ import { Add, LinkRounded } from "@mui/icons-material"; +import { $selectedConversation } from "../../../controller/recoil"; import { Avatar } from "antd"; import { FaVolumeUp } from "react-icons/fa"; import SkeletonLoader from "../../../components/loading/skeleton"; +import UserAvatarWithStatus from "../../../components/User/userAvatarWithStatus"; +import UserStatusText from "../../../components/User/userStatusText"; import { useGetAllContactBasicDetails } from "../../../controller"; +import { useRecoilState } from "recoil"; export default function Conversations() { const { data: contactDetailsListResponse, isLoading } = useGetAllContactBasicDetails(); + const [selectedConvo, setSelectedConvo] = useRecoilState( + $selectedConversation + ); - /** Data we need: have this huge data store client side to be able to access - * for now, need a simple list of contacts - * - first list is the live/pinned - * - second list is the pending invites, out going or incoming? or this on a separate page? - * - third list is just the rest of my contacts - * - * web sockets for all of my active contacts - * - actually play messages if pinned contact for me - */ + // todo: show conversations with activity/new content for me first...then the rest of the contacts + + const selectContact = async (googleUserId: string) => { + // if this person is already selected, unselect + if (selectedConvo === googleUserId) { + setSelectedConvo(null); + return; + } + + setSelectedConvo(googleUserId); + }; return ( <> @@ -48,16 +57,28 @@ export default function Conversations() { {isLoading ? : null}
+ + + Inbox + + + {contactDetailsListResponse?.contactsDetails.map((contactDetail) => { return ( -
- +
selectContact(contactDetail.otherUser.googleId)} + className="flex flex-row items-center hover:bg-slate-600 group border-t border-t-slate-500 + py-4 px-2 cursor-pointer" + > + {contactDetail.otherUser.name} - {contactDetail.otherUser.status} + + + speaking...
diff --git a/packages/desktop/src/pages/Home/header/index.tsx b/packages/desktop/src/pages/Home/header/index.tsx index b31988c..fbb93db 100644 --- a/packages/desktop/src/pages/Home/header/index.tsx +++ b/packages/desktop/src/pages/Home/header/index.tsx @@ -5,6 +5,7 @@ import { useRecoilState, useSetRecoilState } from "recoil"; import { GlobalHotKeys } from "react-hotkeys"; import { STORE_ITEMS } from "../../../electron/constants"; +import UserAvatarWithStatus from "../../../components/User/userAvatarWithStatus"; import { useGetUserDetails } from "../../../controller/index"; import { useRef } from "react"; @@ -48,7 +49,7 @@ export default function Header() { <> -
+
setSearchQuery(e.target.value)} /> - - - cannot find - + +