cleaning things up and renders and such and showing the thing
This commit is contained in:
@@ -172,8 +172,6 @@ async function getUserLines(req: Request, res: Response) {
|
|||||||
currentLineMemberForLine.userId.toString() === userInfo.userId
|
currentLineMemberForLine.userId.toString() === userInfo.userId
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(associatedLineMembersForLine);
|
|
||||||
|
|
||||||
if (userLineMember) {
|
if (userLineMember) {
|
||||||
// take out the current user from the "other" line members list now
|
// take out the current user from the "other" line members list now
|
||||||
|
|
||||||
|
|||||||
@@ -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 (
|
|
||||||
<div
|
|
||||||
key={masterConvo.id.toString()}
|
|
||||||
className={`flex flex-row items-center hover:bg-zinc-600 group py-4 px-2 cursor-pointer ${
|
|
||||||
isSelected ? "bg-zinc-600" : ""
|
|
||||||
} rounded`}
|
|
||||||
>
|
|
||||||
{/* <UserAvatarWithStatus user={contactDetail.otherUser} /> */}
|
|
||||||
|
|
||||||
<span className="text-white font-semibold ml-2">{masterConvo.name}</span>
|
|
||||||
<span className="text-white font-semibold ml-2">
|
|
||||||
{masterConvo.id.toString()}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
{/* <span className="ml-2">
|
|
||||||
<UserStatusText status={contactDetail.otherUser.status} />
|
|
||||||
</span> */}
|
|
||||||
|
|
||||||
{/* {speakingRooms.includes(contactDetail.relationship._id.toString()) ? (
|
|
||||||
<span className="ml-auto">speaking...</span>
|
|
||||||
) : null} */}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,47 +1,58 @@
|
|||||||
|
import { $desktopMode, $selectedLineId } from "../../../controller/recoil";
|
||||||
import { useCallback, useMemo } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
|
import { useRecoilState, useSetRecoilState } from "recoil";
|
||||||
|
|
||||||
import { Avatar } from "antd";
|
import { Avatar } from "antd";
|
||||||
import { FiSun } from "react-icons/fi";
|
import { FiSun } from "react-icons/fi";
|
||||||
import { ILineDetails } from "../../../pages/router/index";
|
import { ILineDetails } from "../../../pages/router/index";
|
||||||
import LineIcon from "../lineIcon";
|
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({
|
export default function LineRow({
|
||||||
lineDetails,
|
masterLineData,
|
||||||
onClick,
|
|
||||||
}: {
|
}: {
|
||||||
lineDetails: ILineDetails;
|
masterLineData: MasterLineData;
|
||||||
onClick: (lineId: string) => void;
|
|
||||||
}) {
|
}) {
|
||||||
|
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(() => {
|
const renderActivityIcon = useMemo(() => {
|
||||||
if (lineDetails.isUserBroadcastingHere)
|
// if there is someone or me broadcasting here
|
||||||
|
if (masterLineData.currentUserMember.lastVisitDate)
|
||||||
return <FiSun className="text-xs text-teal-500" />;
|
return <FiSun className="text-xs text-teal-500" />;
|
||||||
|
|
||||||
if (
|
// if there is new activity blocks for me
|
||||||
lineDetails.isSomeoneElseBroadcastingHere ||
|
if (masterLineData.currentUserMember.lastVisitDate)
|
||||||
lineDetails.profilePicsLiveBroadcasters?.length > 0
|
|
||||||
)
|
|
||||||
return <FiSun className="text-xs text-gray-800" />;
|
|
||||||
|
|
||||||
if (lineDetails.hasNewActivity)
|
|
||||||
return (
|
return (
|
||||||
<span className="h-2 w-2 rounded-full bg-slate-800 animate-pulse"></span>
|
<span className="h-2 w-2 rounded-full bg-slate-800 animate-pulse"></span>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (lineDetails.isUserToggleTunedIn)
|
|
||||||
return (
|
|
||||||
<span className="h-2 w-2 rounded-full bg-slate-200 animate-pulse"></span>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className="h-2 w-2 rounded-full bg-white animate-pulse"></span>
|
<span className="h-2 w-2 rounded-full bg-white animate-pulse"></span>
|
||||||
);
|
);
|
||||||
}, [lineDetails]);
|
}, [masterLineData]);
|
||||||
|
|
||||||
const renderRightActivity = useMemo(() => {
|
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 (
|
return (
|
||||||
<Avatar.Group
|
<Avatar.Group
|
||||||
key={`lineRowRightActivityGroup-${lineDetails.lineId}`}
|
key={`lineRowRightActivityGroup-${masterLineData.lineDetails._id.toString()}`}
|
||||||
maxCount={2}
|
maxCount={2}
|
||||||
maxPopoverTrigger="click"
|
maxPopoverTrigger="click"
|
||||||
size="small"
|
size="small"
|
||||||
@@ -53,10 +64,10 @@ export default function LineRow({
|
|||||||
}}
|
}}
|
||||||
className="shadow-lg"
|
className="shadow-lg"
|
||||||
>
|
>
|
||||||
{lineDetails.profilePicsLiveBroadcasters.map((avatarSrc, index) => (
|
{masterLineData.otherUserObjects?.map((otherUser, index) => (
|
||||||
<Avatar
|
<Avatar
|
||||||
key={`lineListActivitySection-${avatarSrc}-${index}`}
|
key={`lineListActivitySection-${otherUser._id.toString()}-${index}`}
|
||||||
src={avatarSrc}
|
src={otherUser.picture ?? ""}
|
||||||
shape="square"
|
shape="square"
|
||||||
size={"small"}
|
size={"small"}
|
||||||
/>
|
/>
|
||||||
@@ -64,24 +75,34 @@ export default function LineRow({
|
|||||||
</Avatar.Group>
|
</Avatar.Group>
|
||||||
);
|
);
|
||||||
|
|
||||||
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 (
|
return (
|
||||||
<span className={`text-gray-400 ml-auto text-xs font-semibold`}>
|
<span className={`text-gray-400 ml-auto text-xs font-semibold`}>
|
||||||
{lineDetails.timeAgo}
|
{masterLineData.currentUserMember.lastVisitDate}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={`text-gray-300 ml-auto text-xs `}>
|
<span className={`text-gray-300 ml-auto text-xs `}>
|
||||||
{lineDetails.timeAgo}
|
{masterLineData.currentUserMember.lastVisitDate}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}, [lineDetails]);
|
}, [masterLineData]);
|
||||||
|
|
||||||
const handleSelectLine = useCallback(
|
const profilePictures = useMemo(() => {
|
||||||
(e) => onClick(lineDetails.lineId),
|
const pictureSources: string[] = [];
|
||||||
[onClick, lineDetails]
|
|
||||||
);
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -93,16 +114,16 @@ export default function LineRow({
|
|||||||
{renderActivityIcon}
|
{renderActivityIcon}
|
||||||
|
|
||||||
<span className="flex flex-row gap-2 items-center justify-start text-slate-800">
|
<span className="flex flex-row gap-2 items-center justify-start text-slate-800">
|
||||||
{lineDetails.profilePictures && (
|
{profilePictures && <LineIcon sourceImages={profilePictures} />}
|
||||||
<LineIcon sourceImages={lineDetails.profilePictures} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
<h2
|
<h2
|
||||||
className={`text-inherit text-md truncate ${
|
className={`text-inherit text-md truncate ${
|
||||||
lineDetails.hasNewActivity ? "font-semibold" : ""
|
masterLineData.currentUserMember.lastVisitDate
|
||||||
|
? "font-semibold"
|
||||||
|
: ""
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{lineDetails.name}
|
{masterLineData.lineDetails.name}
|
||||||
</h2>
|
</h2>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import axios, { AxiosRequestConfig, AxiosResponse, Method } from "axios";
|
import axios, { AxiosRequestConfig, AxiosResponse, Method } from "axios";
|
||||||
|
|
||||||
import CreateLineRequest from "@nirvana/core/requests/createLine.request";
|
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 { Line } from "@nirvana/core/models/line.model";
|
||||||
import LoginResponse from "../../../core/responses/login.response";
|
import LoginResponse from "../../../core/responses/login.response";
|
||||||
import MasterLineData from "@nirvana/core/models/masterLineData.model";
|
import MasterLineData from "@nirvana/core/models/masterLineData.model";
|
||||||
@@ -82,7 +83,7 @@ async function userSearch(searchQuery: string): Promise<UserSearchResponse> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserLines(): Promise<NirvanaResponse<MasterLineData[]>> {
|
async function getUserLines(): Promise<NirvanaResponse<GetUserLinesResponse>> {
|
||||||
return await NirvanaApi.fetch(`/lines`, "GET", true);
|
return await NirvanaApi.fetch(`/lines`, "GET", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { $desktopMode, $selectedLineId } from "../../controller/recoil";
|
import { $desktopMode, $selectedLineId } from "../../controller/recoil";
|
||||||
|
import { Skeleton, Tooltip } from "antd";
|
||||||
import { useCallback, useMemo, useState } from "react";
|
import { useCallback, useMemo, useState } from "react";
|
||||||
|
|
||||||
import { FaPlus } from "react-icons/fa";
|
import { FaPlus } from "react-icons/fa";
|
||||||
@@ -7,8 +8,8 @@ import { ILineDetails } from "../router";
|
|||||||
import IconButton from "../../components/Button/IconButton/index";
|
import IconButton from "../../components/Button/IconButton/index";
|
||||||
import LineRow from "../../components/lines/lineRow.tsx/index";
|
import LineRow from "../../components/lines/lineRow.tsx/index";
|
||||||
import NewLineModal from "./newLine";
|
import NewLineModal from "./newLine";
|
||||||
import { Tooltip } from "antd";
|
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
|
import { useUserLines } from "../../controller/index";
|
||||||
|
|
||||||
export default function NirvanaTerminal({
|
export default function NirvanaTerminal({
|
||||||
allLines,
|
allLines,
|
||||||
@@ -20,6 +21,8 @@ export default function NirvanaTerminal({
|
|||||||
const setSelectedLineId = useSetRecoilState($selectedLineId);
|
const setSelectedLineId = useSetRecoilState($selectedLineId);
|
||||||
const setDesktopMode = useSetRecoilState($desktopMode);
|
const setDesktopMode = useSetRecoilState($desktopMode);
|
||||||
|
|
||||||
|
const { data: userLinesRes, isLoading } = useUserLines();
|
||||||
|
|
||||||
// todo: sort/order based on activity and activity date and currently broadcasting/live
|
// todo: sort/order based on activity and activity date and currently broadcasting/live
|
||||||
|
|
||||||
const toggleTunedLines = useMemo(
|
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 (
|
return (
|
||||||
<div className="flex flex-col bg-white w-[400px]">
|
<div className="flex flex-col bg-white w-[400px]">
|
||||||
{/* modal for creating new line */}
|
{/* modal for creating new line */}
|
||||||
@@ -73,28 +67,39 @@ export default function NirvanaTerminal({
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* list of all lines */}
|
{/* list of toggle tuned lines */}
|
||||||
<div className="flex flex-col mt-2">
|
<div className="flex flex-col mt-2">
|
||||||
{toggleTunedLines.map((line) => (
|
{/* {toggleTunedLines.map((line) => (
|
||||||
<LineRow
|
<LineRow
|
||||||
key={line.lineId}
|
key={line.lineId}
|
||||||
lineDetails={line}
|
lineDetails={line}
|
||||||
onClick={handleSelectLine}
|
onClick={handleSelectLine}
|
||||||
/>
|
/>
|
||||||
))}
|
))} */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* rest of the lines */}
|
{/* rest of the lines */}
|
||||||
|
|
||||||
<div className={"flex flex-col"}>
|
<div className={"flex flex-col"}>
|
||||||
{restLines.map((line) => (
|
{/* {restLines.map((line) => (
|
||||||
<LineRow
|
<LineRow
|
||||||
key={line.lineId}
|
key={line.lineId}
|
||||||
lineDetails={line}
|
lineDetails={line}
|
||||||
onClick={handleSelectLine}
|
onClick={handleSelectLine}
|
||||||
/>
|
/>
|
||||||
))}
|
))} */}
|
||||||
|
{isLoading ? (
|
||||||
|
<Skeleton />
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{userLinesRes?.data?.masterLines?.map((masterLineData) => (
|
||||||
|
<LineRow
|
||||||
|
key={`terminalListLines-${masterLineData.lineDetails._id.toString()}`}
|
||||||
|
masterLineData={masterLineData}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user