diff --git a/packages/api/routes/line.ts b/packages/api/routes/line.ts index 18823a5..dd81cf5 100644 --- a/packages/api/routes/line.ts +++ b/packages/api/routes/line.ts @@ -172,8 +172,6 @@ async function getUserLines(req: Request, res: Response) { currentLineMemberForLine.userId.toString() === userInfo.userId ); - console.log(associatedLineMembersForLine); - if (userLineMember) { // take out the current user from the "other" line members list now diff --git a/packages/desktop/src/components/conversation/basicRow.tsx b/packages/desktop/src/components/conversation/basicRow.tsx deleted file mode 100644 index b08b3b5..0000000 --- a/packages/desktop/src/components/conversation/basicRow.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import MasterConversation from "@nirvana/core/models/masterLineData.model"; -import UserStatusText from "../User/userStatusText"; -export default function BasicConversationRow({ - masterConvo, -}: { - masterConvo: MasterConversation; -}) { - // fetch more data for this conversation like all of the members for it - // if there is new content for current user - // lastActiveDate - - const isSelected = false; - - return ( -
- {/* */} - - {masterConvo.name} - - {masterConvo.id.toString()} - - - {/* - - */} - - {/* {speakingRooms.includes(contactDetail.relationship._id.toString()) ? ( - speaking... - ) : null} */} -
- ); -} diff --git a/packages/desktop/src/components/lines/lineRow.tsx/index.tsx b/packages/desktop/src/components/lines/lineRow.tsx/index.tsx index c8a7cb5..01d9e17 100644 --- a/packages/desktop/src/components/lines/lineRow.tsx/index.tsx +++ b/packages/desktop/src/components/lines/lineRow.tsx/index.tsx @@ -1,47 +1,58 @@ +import { $desktopMode, $selectedLineId } from "../../../controller/recoil"; import { useCallback, useMemo } from "react"; +import { useRecoilState, useSetRecoilState } from "recoil"; import { Avatar } from "antd"; import { FiSun } from "react-icons/fi"; import { ILineDetails } from "../../../pages/router/index"; import LineIcon from "../lineIcon"; +import MasterLineData from "@nirvana/core/models/masterLineData.model"; +import { useGetUserDetails } from "../../../controller/index"; + +// todo: send a much more comprehensive master line object? or just add properties to the +// masterLineData object so that we don't have different models to maintain between client and server export default function LineRow({ - lineDetails, - onClick, + masterLineData, }: { - lineDetails: ILineDetails; - onClick: (lineId: string) => void; + masterLineData: MasterLineData; }) { + const [selectedLineId, setSelectedLineId] = useRecoilState($selectedLineId); + const { data: userData } = useGetUserDetails(); + + const setDesktopMode = useSetRecoilState($desktopMode); + + /** show user line details */ + const handleSelectLine = useCallback(() => { + setSelectedLineId(masterLineData.lineDetails._id.toString()); + setDesktopMode("terminalDetails"); + }, [setSelectedLineId, setDesktopMode, masterLineData]); + + /** + * TODO: slowly add to this and fix based on added features + * */ const renderActivityIcon = useMemo(() => { - if (lineDetails.isUserBroadcastingHere) + // if there is someone or me broadcasting here + if (masterLineData.currentUserMember.lastVisitDate) return ; - if ( - lineDetails.isSomeoneElseBroadcastingHere || - lineDetails.profilePicsLiveBroadcasters?.length > 0 - ) - return ; - - if (lineDetails.hasNewActivity) + // if there is new activity blocks for me + if (masterLineData.currentUserMember.lastVisitDate) return ( ); - if (lineDetails.isUserToggleTunedIn) - return ( - - ); - return ( ); - }, [lineDetails]); + }, [masterLineData]); const renderRightActivity = useMemo(() => { - if (lineDetails.profilePicsLiveBroadcasters?.length) + // TODO: this should be the list of broadcasters, not members...change once we have that + if (masterLineData.otherUserObjects?.length) return ( - {lineDetails.profilePicsLiveBroadcasters.map((avatarSrc, index) => ( + {masterLineData.otherUserObjects?.map((otherUser, index) => ( @@ -64,24 +75,34 @@ export default function LineRow({ ); - if (lineDetails.hasNewActivity) + // if there is new activity/black dot, then show relative time as little bolder? or too much? + + // TODO: add moment for relative time of activity + if (masterLineData.currentUserMember.lastVisitDate) return ( - {lineDetails.timeAgo} + {masterLineData.currentUserMember.lastVisitDate} ); return ( - {lineDetails.timeAgo} + {masterLineData.currentUserMember.lastVisitDate} ); - }, [lineDetails]); + }, [masterLineData]); - const handleSelectLine = useCallback( - (e) => onClick(lineDetails.lineId), - [onClick, lineDetails] - ); + const profilePictures = useMemo(() => { + const pictureSources: string[] = []; + + if (userData?.user?.picture) pictureSources.push(userData.user.picture); + + masterLineData.otherUserObjects?.forEach((otherUser) => { + if (otherUser.picture) pictureSources.push(otherUser.picture); + }); + + return pictureSources; + }, [masterLineData, userData]); return (
- {lineDetails.profilePictures && ( - - )} + {profilePictures && }

- {lineDetails.name} + {masterLineData.lineDetails.name}

diff --git a/packages/desktop/src/controller/nirvanaApi.ts b/packages/desktop/src/controller/nirvanaApi.ts index 6d94b19..b871844 100644 --- a/packages/desktop/src/controller/nirvanaApi.ts +++ b/packages/desktop/src/controller/nirvanaApi.ts @@ -1,6 +1,7 @@ import axios, { AxiosRequestConfig, AxiosResponse, Method } from "axios"; import CreateLineRequest from "@nirvana/core/requests/createLine.request"; +import GetUserLinesResponse from "@nirvana/core/responses/getUserLines.response"; import { Line } from "@nirvana/core/models/line.model"; import LoginResponse from "../../../core/responses/login.response"; import MasterLineData from "@nirvana/core/models/masterLineData.model"; @@ -82,7 +83,7 @@ async function userSearch(searchQuery: string): Promise { ); } -async function getUserLines(): Promise> { +async function getUserLines(): Promise> { return await NirvanaApi.fetch(`/lines`, "GET", true); } diff --git a/packages/desktop/src/pages/terminal/index.tsx b/packages/desktop/src/pages/terminal/index.tsx index 79525d3..ca23353 100644 --- a/packages/desktop/src/pages/terminal/index.tsx +++ b/packages/desktop/src/pages/terminal/index.tsx @@ -1,4 +1,5 @@ import { $desktopMode, $selectedLineId } from "../../controller/recoil"; +import { Skeleton, Tooltip } from "antd"; import { useCallback, useMemo, useState } from "react"; import { FaPlus } from "react-icons/fa"; @@ -7,8 +8,8 @@ import { ILineDetails } from "../router"; import IconButton from "../../components/Button/IconButton/index"; import LineRow from "../../components/lines/lineRow.tsx/index"; import NewLineModal from "./newLine"; -import { Tooltip } from "antd"; import { useSetRecoilState } from "recoil"; +import { useUserLines } from "../../controller/index"; export default function NirvanaTerminal({ allLines, @@ -20,6 +21,8 @@ export default function NirvanaTerminal({ const setSelectedLineId = useSetRecoilState($selectedLineId); const setDesktopMode = useSetRecoilState($desktopMode); + const { data: userLinesRes, isLoading } = useUserLines(); + // todo: sort/order based on activity and activity date and currently broadcasting/live const toggleTunedLines = useMemo( @@ -32,15 +35,6 @@ export default function NirvanaTerminal({ [] ); - /** show user line details */ - const handleSelectLine = useCallback( - (lineId: string) => { - setSelectedLineId(lineId); - setDesktopMode("terminalDetails"); - }, - [setSelectedLineId, setDesktopMode] - ); - return (
{/* modal for creating new line */} @@ -73,28 +67,39 @@ export default function NirvanaTerminal({
- {/* list of all lines */} + {/* list of toggle tuned lines */}
- {toggleTunedLines.map((line) => ( + {/* {toggleTunedLines.map((line) => ( - ))} + ))} */}
{/* rest of the lines */} -
- {restLines.map((line) => ( - - ))} + {/* {restLines.map((line) => ( + + ))} */} + {isLoading ? ( + + ) : ( + <> + {userLinesRes?.data?.masterLines?.map((masterLineData) => ( + + ))} + + )}
);