handling flow state better from overlay
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import { Button, Container, Typography } from '@mui/material';
|
import { Button, Container, Typography } from '@mui/material';
|
||||||
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
import React, { useCallback, useContext, useEffect, useState } from 'react';
|
||||||
import { Socket, io } from 'socket.io-client';
|
import { Socket, io } from 'socket.io-client';
|
||||||
|
import { useMount, useUnmount } from 'react-use';
|
||||||
|
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import useAuth from './AuthProvider';
|
import useAuth from './AuthProvider';
|
||||||
import { useUnmount } from 'react-use';
|
|
||||||
|
|
||||||
interface ISocketProvider {
|
interface ISocketProvider {
|
||||||
$ws: Socket;
|
$ws: Socket;
|
||||||
@@ -63,9 +63,9 @@ export function SocketProvider({ children }: { children: React.ReactNode }) {
|
|||||||
set$ws(socketConnection);
|
set$ws(socketConnection);
|
||||||
}, [initiateSocketStabilityListeners, jwtToken, set$ws]);
|
}, [initiateSocketStabilityListeners, jwtToken, set$ws]);
|
||||||
|
|
||||||
useEffect(() => {
|
useMount(() => {
|
||||||
connect();
|
connect();
|
||||||
}, [connect]);
|
});
|
||||||
|
|
||||||
useUnmount(() => {
|
useUnmount(() => {
|
||||||
$ws?.disconnect();
|
$ws?.disconnect();
|
||||||
|
|||||||
@@ -52,6 +52,16 @@ export default function FooterControls() {
|
|||||||
|
|
||||||
const [openUserSettings, setOpenUserSettings] = useState<boolean>(false);
|
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(
|
const handleClickProfile = useCallback(
|
||||||
(event: React.MouseEvent<HTMLElement>) => {
|
(event: React.MouseEvent<HTMLElement>) => {
|
||||||
if (desktopMode === 'overlayOnly') {
|
if (desktopMode === 'overlayOnly') {
|
||||||
@@ -137,7 +147,7 @@ export default function FooterControls() {
|
|||||||
|
|
||||||
<Divider orientation="horizontal" flexItem />
|
<Divider orientation="horizontal" flexItem />
|
||||||
|
|
||||||
<Button size={'small'} color={'secondary'} variant="text" onClick={handleFlowState}>
|
<Button size={'small'} color={'secondary'} variant="text" onClick={handleTurnOnFlowState}>
|
||||||
flow
|
flow
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user