handling flow state better from overlay

This commit is contained in:
talksik
2022-06-25 12:30:40 -05:00
parent 4556578a20
commit 9bc2e186fd
2 changed files with 14 additions and 4 deletions
@@ -1,10 +1,10 @@
import { Button, Container, Typography } from '@mui/material';
import React, { useCallback, useContext, useEffect, useState } from 'react';
import { Socket, io } from 'socket.io-client';
import { useMount, useUnmount } from 'react-use';
import toast from 'react-hot-toast';
import useAuth from './AuthProvider';
import { useUnmount } from 'react-use';
interface ISocketProvider {
$ws: Socket;
@@ -63,9 +63,9 @@ export function SocketProvider({ children }: { children: React.ReactNode }) {
set$ws(socketConnection);
}, [initiateSocketStabilityListeners, jwtToken, set$ws]);
useEffect(() => {
useMount(() => {
connect();
}, [connect]);
});
useUnmount(() => {
$ws?.disconnect();
+11 -1
View File
@@ -52,6 +52,16 @@ export default function FooterControls() {
const [openUserSettings, setOpenUserSettings] = useState<boolean>(false);
const handleTurnOnFlowState = useCallback(() => {
// when in overlay mode, we need to toggle main app and then go into flow state
if (desktopMode === 'overlayOnly') {
handleToggleDesktopMode();
}
handleFlowState();
}, [handleFlowState, desktopMode, handleToggleDesktopMode]);
const handleClickProfile = useCallback(
(event: React.MouseEvent<HTMLElement>) => {
if (desktopMode === 'overlayOnly') {
@@ -137,7 +147,7 @@ export default function FooterControls() {
<Divider orientation="horizontal" flexItem />
<Button size={'small'} color={'secondary'} variant="text" onClick={handleFlowState}>
<Button size={'small'} color={'secondary'} variant="text" onClick={handleTurnOnFlowState}>
flow
</Button>