incomplete, not sure of priority of this

This commit is contained in:
talksik
2022-05-09 07:51:34 -05:00
parent c8b460bcbb
commit d849e58049
3 changed files with 59 additions and 1 deletions
@@ -1,4 +1,4 @@
import { $jwtToken, $selectedLineId } from "./recoil";
import { $desktopMode, $jwtToken, $selectedLineId } from "./recoil";
import {
ConnectToLineRequest,
ServerRequestChannels,
@@ -388,12 +388,29 @@ export function LineDataProvider({ children }) {
// persistent store of lines
// ?just do simple synchronous axios/fetch in useEffect and manage isLoading ourselves?
const { data: basicUserLinesData } = useUserLines();
const desktopMode = useRecoilValue($desktopMode);
// ! passing in the same data of the query passes reference so changes that happen in socketHandler impact react query cache
const { linesMap, ...handlers } = useSocketHandler(
basicUserLinesData?.data?.masterLines
);
// if we go into flow state
// emit flow state message to all of my rooms
// persist it in my user object
// and then disconnect
useEffect(() => {
return () => {
if (desktopMode === "flowState" && $ws) {
console.log(
"SOCKETS | telling all of my connected rooms that I am unplugging"
);
$ws.emit(ServerRequestChannels.GOING_INTO_FLOW_STATE);
}
};
}, [desktopMode, $ws]);
// avoid children rendering if they don't have the ws to make individual calls with
if (!$ws) {
return <span>attempting to connect you for the here and now...</span>;