diff --git a/packages/desktop/src/tree/protected/terminal/panels/MainPanel.tsx b/packages/desktop/src/tree/protected/terminal/panels/MainPanel.tsx index e2bc839..332915c 100644 --- a/packages/desktop/src/tree/protected/terminal/panels/MainPanel.tsx +++ b/packages/desktop/src/tree/protected/terminal/panels/MainPanel.tsx @@ -1,11 +1,25 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import useAuth from '../../../../providers/AuthProvider'; import useRealTimeRooms from '../../../../providers/RealTimeRoomProvider'; +import { LineMemberState } from '@nirvana/core/models/line.model'; +import LineIcon from '../../../../components/lineIcon'; +import { FiActivity, FiHeadphones, FiSettings, FiSun } from 'react-icons/fi'; +import { Avatar, Tooltip } from 'antd'; + export default function MainPanel() { const { user } = useAuth(); - const { roomsMap } = useRealTimeRooms(); + const { selectedLineId } = useRealTimeRooms(); + + // already won't see stuff for overlay only mode as per parent configuration + + // TODO: if there is stuff in search, show that first + + // if selected line, show line details + if (selectedLineId) return ; + + // else show the stale state return (
); } + +function LineDetails() { + const { user } = useAuth(); + + const { selectedLineId, roomsMap, handleUpdateLineMemberState } = useRealTimeRooms(); + + const selectedLine = useMemo(() => roomsMap[selectedLineId], [selectedLineId, roomsMap]); + + console.log('selected line', selectedLine); + + const isUserToggleTuned = useMemo( + () => selectedLine?.currentUserMember?.state === LineMemberState.TUNED, + [selectedLine], + ); + + // seeing if I am in the list of broadcasters + // the source of truth from the socket connections telling me if my clicking actually made a round trip + const isUserBroadcasting = useMemo( + () => selectedLine?.currentBroadcastersUserIds?.includes(user._id.toString()), + [user, selectedLine], + ); + + // showing all tuned in members...they may not hear me since they might be doing something else + // but feeling of presentness + const tunedProfiles = useMemo(() => { + const pictureSources: { name: string; pictureSrc: string }[] = []; + + selectedLine.tunedInMemberIds?.forEach((tunedInMemberUserId) => { + // don't want to see my own picture + // TODO: don't show myself!? + if (tunedInMemberUserId === user._id.toString()) { + pictureSources.push(); + + pictureSources.push({ + name: user.givenName, + pictureSrc: user.picture, + }); + return; + } + + const otherUserObject = selectedLine.otherUserObjects?.find( + (userObj) => userObj._id.toString() === tunedInMemberUserId, + ); + if (otherUserObject?.picture) + pictureSources.push({ + name: otherUserObject.givenName, + pictureSrc: otherUserObject.picture, + }); + }); + + return pictureSources; + }, [selectedLine, user]); + + // pics for the line icons + 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); + + selectedLine.otherUserObjects?.forEach((otherUser) => { + if (otherUser.picture) pictureSources.push(otherUser.picture); + }); + + return pictureSources; + }, [selectedLine, user]); + + return ( +
+ {/* line details */} +
+ {profilePictures && } + +
+ +

+ {selectedLine.lineDetails.name || selectedLine.otherUserObjects[0].givenName} +

+ + +
+ + + {`${ + selectedLine.otherMembers?.length + 1 ?? 0 + } members`} + + {`${ + selectedLine.tunedInMemberIds?.length ?? 0 + } in this room`} + +
+ + + + +
+ + {/* line timeline */} +
+ load more + + yesterday + +
+ {selectedLine.otherUserObjects.map((otherUser) => ( +
+ + {otherUser.givenName} + + {`${ + Math.floor(Math.random() * 10) + 1 + }:${Math.floor(Math.random() * 100) + 10}pm |`} + + {`${ + Math.floor(Math.random() * 60) + 1 + } seconds`} +
+ ))} + +
+ + {'Arjun Patel'} + + {`${ + Math.floor(Math.random() * 10) + 1 + }:${Math.floor(Math.random() * 100) + 10}pm |`} + + {`${ + Math.floor(Math.random() * 60) + 1 + } seconds`} +
+
+ + today + +
+ {selectedLine.otherUserObjects.map((otherUser) => ( + // TODO: show the shadow if it's unheard +
+ + {otherUser.name} + + {`${ + Math.floor(Math.random() * 10) + 1 + }:${Math.floor(Math.random() * 100) + 10}pm |`} + + {`${ + Math.floor(Math.random() * 60) + 1 + } seconds`} +
+ ))} +
+ + {/* live broadcasters */} + + + right now + +
+ {selectedLine.otherUserObjects.map((otherUser) => ( +
+ + {otherUser.name} + + + + +
+ ))} +
+
+ + +
+ ); +} diff --git a/packages/desktop/src/tree/protected/terminal/panels/SidePanel.tsx b/packages/desktop/src/tree/protected/terminal/panels/SidePanel.tsx index 96c5cda..a68afb2 100644 --- a/packages/desktop/src/tree/protected/terminal/panels/SidePanel.tsx +++ b/packages/desktop/src/tree/protected/terminal/panels/SidePanel.tsx @@ -23,7 +23,7 @@ export default function SidePanel() { const restLines: MasterLineData[] = []; masterLines.forEach((masterLine) => { - if (masterLine.currentUserMember.state === LineMemberState.TUNED) restLines.push(masterLine); + if (masterLine.currentUserMember.state === LineMemberState.TUNED) tunedLines.push(masterLine); else restLines.push(masterLine); });