prop only changing with new object...should have knowne

This commit is contained in:
talksik
2022-05-07 13:31:30 -05:00
parent d8ece9eb51
commit a41753b574
5 changed files with 17 additions and 15 deletions
-2
View File
@@ -131,8 +131,6 @@ export class LineService {
updateSet updateSet
); );
console.log(updateRes);
return updateRes; return updateRes;
} }
+3 -3
View File
@@ -123,10 +123,10 @@ export default function InitializeWs(io: any) {
LineMemberState.TUNED LineMemberState.TUNED
); );
} else { } else {
// just updates the await LineService.updateLineMemberState(
await LineService.updateLineMemberVisitDate(
req.lineId, req.lineId,
userInfo.userId userInfo.userId,
LineMemberState.INBOX
); );
} }
@@ -344,10 +344,12 @@ export function LineDataProvider({ children }) {
// ?just do simple synchronous axios/fetch in useEffect and manage isLoading ourselves? // ?just do simple synchronous axios/fetch in useEffect and manage isLoading ourselves?
const { data: basicUserLinesData } = useUserLines(); const { data: basicUserLinesData } = useUserLines();
// ! passing in the same data of the query passes reference so changes that happen in socketHandler impact react query cache
const { linesMap, ...handlers } = useSocketHandler( const { linesMap, ...handlers } = useSocketHandler(
basicUserLinesData?.data?.masterLines basicUserLinesData?.data?.masterLines
); );
// avoid children rendering if they don't have the ws to make individual calls with
if (!$ws) { if (!$ws) {
return <span>attempting to connect you for the here and now...</span>; return <span>attempting to connect you for the here and now...</span>;
} }
@@ -21,7 +21,7 @@ export default function LineDetailsTerminal({
const isUserToggleTuned = useMemo( const isUserToggleTuned = useMemo(
() => selectedLine?.currentUserMember?.state === LineMemberState.TUNED, () => selectedLine?.currentUserMember?.state === LineMemberState.TUNED,
[selectedLine.currentUserMember] [selectedLine]
); );
// seeing if I am in the list of broadcasters // seeing if I am in the list of broadcasters
@@ -34,10 +34,6 @@ export default function LineDetailsTerminal({
[userDetails, selectedLine] [userDetails, selectedLine]
); );
useEffect(() => {
console.log(selectedLine?.currentUserMember);
}, [selectedLine]);
return ( return (
<> <>
<div className="flex flex-col flex-1 bg-gray-100 items-stretch justify-start relative border-l border-l-gray-100"> <div className="flex flex-col flex-1 bg-gray-100 items-stretch justify-start relative border-l border-l-gray-100">
@@ -88,7 +84,15 @@ export default function LineDetailsTerminal({
isUserToggleTuned ? "bg-gray-800 text-white" : "text-black" isUserToggleTuned ? "bg-gray-800 text-white" : "text-black"
}`} }`}
onClick={() => onClick={() =>
handleTuneToLine(selectedLine.lineDetails._id.toString(), true) isUserToggleTuned
? handleTuneToLine(
selectedLine.lineDetails._id.toString(),
false
)
: handleTuneToLine(
selectedLine.lineDetails._id.toString(),
true
)
} }
> >
<FiActivity className="text-lg" /> <FiActivity className="text-lg" />
@@ -30,7 +30,7 @@ export default function NirvanaTerminal() {
useEffect(() => { useEffect(() => {
console.log("change/update in lines map"); console.log("change/update in lines map");
console.log(linesMap); // console.log(linesMap);
}, [linesMap]); }, [linesMap]);
const allLines: MasterLineData[] = useMemo(() => { const allLines: MasterLineData[] = useMemo(() => {
@@ -114,8 +114,6 @@ export default function NirvanaTerminal() {
const foundSelectedLine = linesMap[selectedLineId]; const foundSelectedLine = linesMap[selectedLineId];
console.log(foundSelectedLine);
// on mount of this, we want to temporarily tune into the line if we are not already tuned in...which would happen if we toggle tuned in // on mount of this, we want to temporarily tune into the line if we are not already tuned in...which would happen if we toggle tuned in
if ( if (
!foundSelectedLine.tunedInMemberIds?.includes( !foundSelectedLine.tunedInMemberIds?.includes(
@@ -125,7 +123,7 @@ export default function NirvanaTerminal() {
handleTuneToLine(selectedLineId, false); handleTuneToLine(selectedLineId, false);
} }
return foundSelectedLine; return { ...foundSelectedLine };
} }
return undefined; return undefined;