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({ masterLineData, }: { 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 there is someone or me broadcasting here // if (masterLineData.currentUserMember.lastVisitDate) return ; // if there is new activity blocks for me if (masterLineData.currentUserMember.lastVisitDate) return ( ); return ( ); }, [masterLineData]); const renderRightActivity = useMemo(() => { // TODO: this should be the list of broadcasters, not members...change once we have that if (masterLineData.otherUserObjects?.length) return ( {masterLineData.otherUserObjects?.map((otherUser, index) => ( ))} ); // 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 ( {masterLineData.currentUserMember.lastVisitDate} ); return ( {masterLineData.currentUserMember.lastVisitDate} ); }, [masterLineData]); const profilePictures = useMemo(() => { const pictureSources: string[] = []; // ?don't add in my image as that's useless contextually? // 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 (
{/* status dot */} {renderActivityIcon} {profilePictures && }

{masterLineData.lineDetails.name}

{renderRightActivity}
); }