From e73bf2ddec328d451c5ac32e36a9827e026e4af1 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Sat, 20 Jan 2024 18:59:12 -0800 Subject: [PATCH] Call: persist all 3 settings --- src/apps/call/AppCall.tsx | 8 ++-- src/apps/call/Contacts.tsx | 55 ++++++++++++--------------- src/apps/call/Telephone.tsx | 13 +++++-- src/apps/call/state/store-app-call.ts | 24 +++++++----- 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/src/apps/call/AppCall.tsx b/src/apps/call/AppCall.tsx index 23182332c..5d250e1b6 100644 --- a/src/apps/call/AppCall.tsx +++ b/src/apps/call/AppCall.tsx @@ -8,7 +8,7 @@ import { useRouterQuery } from '~/common/app.routes'; import { CallWizard } from './CallWizard'; import { Contacts } from './Contacts'; import { Telephone } from './Telephone'; -import { useCallToggleGrayUI } from './state/store-app-call'; +import { useAppCallStore } from './state/store-app-call'; /** @@ -28,7 +28,7 @@ export function AppCall() { const [callIntent, setCallIntent] = React.useState(null); // external state - const { callGrayUI } = useCallToggleGrayUI(); + const grayUI = useAppCallStore(state => state.grayUI); const query = useRouterQuery>(); @@ -48,8 +48,8 @@ export function AppCall() { return ( void }) { - // state - const [hideConversations, setHideConversations] = React.useState(false); - const [hideSupport, setHideSupport] = React.useState(false); - // external state + const { + grayUI, toggleGrayUI, + showConversations, toggleShowConversations, + showSupport, toggleShowSupport, + } = useAppCallStore(); const { personas } = useMockPersonas(); - const { callGrayUI, callToggleGrayUI } = useCallToggleGrayUI(); const conversationsByPersona = useConversationsByPersona(); // pluggable UI - const menuItems = React.useMemo(() => { + const menuItems = React.useMemo(() => <> - const handleConversationsToggle = () => setHideConversations(on => !on); + + Conversations + + - const handleSupportToggle = () => setHideSupport(on => !on); + + Support + + - return <> + + Grayed UI + + - - Conversations - - - - - Support - - - - - Grayed UI - - - - ; - }, [callGrayUI, callToggleGrayUI, hideConversations, hideSupport]); + , [grayUI, showConversations, showSupport, toggleGrayUI, toggleShowConversations, toggleShowSupport]); usePluggableOptimaLayout(null, null, menuItems, 'CallUI'); @@ -325,16 +318,16 @@ export function Contacts(props: { setCallIntent: (intent: AppCallIntent) => void , )} - {!hideSupport && } + {showSupport && } - {!hideSupport && diff --git a/src/apps/call/Telephone.tsx b/src/apps/call/Telephone.tsx index 5b7bf2d2c..fa07b01a8 100644 --- a/src/apps/call/Telephone.tsx +++ b/src/apps/call/Telephone.tsx @@ -1,11 +1,10 @@ import * as React from 'react'; import { shallow } from 'zustand/shallow'; -import { Box, Card, ListItemDecorator, MenuItem, Switch, Typography } from '@mui/joy'; +import { Box, Card, ListDivider, ListItemDecorator, MenuItem, Switch, Typography } from '@mui/joy'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import CallEndIcon from '@mui/icons-material/CallEnd'; import CallIcon from '@mui/icons-material/Call'; -import ChatOutlinedIcon from '@mui/icons-material/ChatOutlined'; import MicIcon from '@mui/icons-material/Mic'; import MicNoneIcon from '@mui/icons-material/MicNone'; import RecordVoiceOverIcon from '@mui/icons-material/RecordVoiceOver'; @@ -29,6 +28,7 @@ import { CallAvatar } from './components/CallAvatar'; import { CallButton } from './components/CallButton'; import { CallMessage } from './components/CallMessage'; import { CallStatus } from './components/CallStatus'; +import { useAppCallStore } from './state/store-app-call'; function CallMenuItems(props: { @@ -39,6 +39,7 @@ function CallMenuItems(props: { }) { // external state + const { grayUI, toggleGrayUI } = useAppCallStore(); const { voicesDropdown } = useElevenLabsVoiceDropdown(false, !props.override); const handlePushToTalkToggle = () => props.setPushToTalk(!props.pushToTalk); @@ -64,8 +65,14 @@ function CallMenuItems(props: { {voicesDropdown} + + + + Grayed UI + + + - Voice Calls Feedback diff --git a/src/apps/call/state/store-app-call.ts b/src/apps/call/state/store-app-call.ts index 9679f24ad..f81bed9f6 100644 --- a/src/apps/call/state/store-app-call.ts +++ b/src/apps/call/state/store-app-call.ts @@ -1,29 +1,35 @@ import { create } from 'zustand'; import { persist } from 'zustand/middleware'; -import { shallow } from 'zustand/shallow'; // Call settings interface AppCallStore { + grayUI: boolean; toggleGrayUI: () => void; + + showConversations: boolean; + toggleShowConversations: () => void; + + showSupport: boolean; + toggleShowSupport: () => void; + } -const useAppCallStore = create()(persist( +export const useAppCallStore = create()(persist( (_set, _get) => ({ grayUI: false, toggleGrayUI: () => _set(state => ({ grayUI: !state.grayUI })), + showConversations: true, + toggleShowConversations: () => _set(state => ({ showConversations: !state.showConversations })), + + showSupport: true, + toggleShowSupport: () => _set(state => ({ showSupport: !state.showSupport })), + }), { name: 'app-app-call', }, )); - - -export const useCallToggleGrayUI = () => - useAppCallStore(state => ({ - callGrayUI: state.grayUI, - callToggleGrayUI: () => state.toggleGrayUI(), - }), shallow);