putting avatars showing who is tuned in

This commit is contained in:
talksik
2022-05-10 11:00:17 -05:00
parent 95d3244a7f
commit 409a496ce4
2 changed files with 72 additions and 19 deletions
+72 -19
View File
@@ -1,12 +1,13 @@
import { $desktopMode, $selectedLineId } from "../../controller/recoil"; import { $desktopMode, $selectedLineId } from "../../controller/recoil";
import { Avatar, Skeleton, Tooltip } from "antd";
import { FiActivity, FiSettings, FiSun } from "react-icons/fi"; import { FiActivity, FiSettings, FiSun } from "react-icons/fi";
import { GlobalHotKeys, KeyMap } from "react-hotkeys"; import { GlobalHotKeys, KeyMap } from "react-hotkeys";
import { Skeleton, Tooltip } from "antd";
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { useGetUserDetails, useUserLines } from "../../controller/index"; import { useGetUserDetails, useUserLines } from "../../controller/index";
import { useRecoilState, useSetRecoilState } from "recoil"; import { useRecoilState, useSetRecoilState } from "recoil";
import { FaPlus } from "react-icons/fa"; import { FaPlus } from "react-icons/fa";
import LineIcon from "../../components/lines/lineIcon/index";
import { LineMemberState } from "@nirvana/core/models/line.model"; import { LineMemberState } from "@nirvana/core/models/line.model";
import LineRow from "../../components/lines/lineRow.tsx/index"; import LineRow from "../../components/lines/lineRow.tsx/index";
import MasterLineData from "@nirvana/core/models/masterLineData.model"; import MasterLineData from "@nirvana/core/models/masterLineData.model";
@@ -302,35 +303,81 @@ function LineDetailsTerminal({
[userDetails, selectedLine] [userDetails, selectedLine]
); );
// showing all tuned in members...they may not hear me since they might be doing something else
// but feeling of presentness
const profilePictures = useMemo(() => {
const pictureSources: string[] = [];
selectedLine.tunedInMemberIds?.forEach((tunedInMemberUserId) => {
// don't want to see my own picture
// TODO: don't show myself!?
if (tunedInMemberUserId === userDetails.user._id.toString()) {
pictureSources.push(userDetails.user?.picture);
return;
}
const otherUserObject = selectedLine.otherUserObjects?.find(
(userObj) => userObj._id.toString() === tunedInMemberUserId
);
if (otherUserObject?.picture)
pictureSources.push(otherUserObject.picture);
});
return pictureSources;
}, [selectedLine, userDetails]);
return ( return (
<div <div
className="flex flex-col flex-1 bg-gray-100 relative className="flex flex-col flex-1 bg-gray-100
border-l border-l-gray-200" border-l border-l-gray-200 relative"
> >
{/* controls */} {/* line details */}
<div <div
className="absolute bottom-0 p-4 shadow-2xl className="p-4 shadow-2xl
flex flex-row items-center gap-2 justify-end w-full" flex flex-row items-center gap-2 justify-end"
> >
<span className="mr-auto text-teal-800">{`${ {profilePictures && (
selectedLine?.tunedInMemberIds?.length ?? 0 <Avatar.Group
} on the line`}</span> maxCount={2}
maxPopoverTrigger="click"
size="default"
maxStyle={{
color: "#f56a00",
backgroundColor: "#fde3cf",
cursor: "pointer",
borderRadius: "0",
}}
className="shadow-lg"
>
{profilePictures?.map((avatarSrc, index) => (
<Avatar
key={`lineIcon-${avatarSrc}-${index}`}
src={avatarSrc}
shape="square"
size={"default"}
/>
))}
</Avatar.Group>
)}
<span className="mr-auto text-teal-800">{`on the line`}</span>
<button <button
className={`p-3 flex justify-center items-center hover:bg-gray-300 className={`p-2 flex justify-center items-center hover:bg-gray-300
transition-all hover:scale-105`} transition-all hover:scale-105`}
> >
<FiSettings className="text-gray-400 text-md" /> <FiSettings className="text-gray-400 text-sm" />
</button> </button>
{/* TODO: move to on hover of line row */} {/* TODO: move to on hover of line row */}
<Tooltip <Tooltip
placement="left"
title={`${ title={`${
isUserToggleTuned ? "click to untoggle" : "click to stay tuned in" isUserToggleTuned ? "click to untoggle" : "click to stay tuned in"
}`} }`}
> >
<button <button
className={`p-3 flex justify-center items-center shadow-lg className={`p-2 flex justify-center items-center shadow-lg
hover:scale-105 transition-all animate-pulse ${ hover:scale-105 transition-all animate-pulse ${
isUserToggleTuned ? "bg-gray-800 text-white" : "text-black" isUserToggleTuned ? "bg-gray-800 text-white" : "text-black"
}`} }`}
@@ -346,21 +393,27 @@ function LineDetailsTerminal({
) )
} }
> >
<FiActivity className="text-lg" /> <FiActivity className="text-md" />
</button> </button>
</Tooltip> </Tooltip>
</div>
<button {/* line details */}
className={`p-3 flex justify-center items-center shadow-lg <div></div>
{/* line timeline + present moment*/}
<div></div>
<button
className={`p-3 absolute right-3 bottom-3 flex justify-center items-center shadow-lg
hover:scale-105 transition-all ${ hover:scale-105 transition-all ${
isUserBroadcasting isUserBroadcasting
? "bg-teal-800 text-white" ? "bg-teal-800 text-white"
: "text-teal-800 border-teal-800 border" : "text-teal-800 border-teal-800 border"
}`} }`}
> >
<FiSun className="text-lg" /> <FiSun className="text-lg" />
</button> </button>
</div>
</div> </div>
); );
} }