diff --git a/.changeset/fix_call_preferences.md b/.changeset/fix_call_preferences.md new file mode 100644 index 000000000..b089563a1 --- /dev/null +++ b/.changeset/fix_call_preferences.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix call preferences not persisting. diff --git a/src/app/features/call/CallControls.tsx b/src/app/features/call/CallControls.tsx index 4688ce8a7..6643069c5 100644 --- a/src/app/features/call/CallControls.tsx +++ b/src/app/features/call/CallControls.tsx @@ -1,4 +1,4 @@ -import { MouseEventHandler, useCallback, useRef, useState } from 'react'; +import { MouseEventHandler, useCallback, useEffect, useRef, useState } from 'react'; import { Box, Button, @@ -15,7 +15,13 @@ import { toRem, } from 'folds'; import FocusTrap from 'focus-trap-react'; -import { SequenceCard } from '../../components/sequence-card'; +import { SequenceCard } from '$components/sequence-card'; +import { CallEmbed, useCallControlState } from '$plugins/call'; +import { stopPropagation } from '$utils/keyboard'; +import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; +import { useRoom } from '$hooks/useRoom'; +import { ScreenSize, useScreenSizeContext } from '$hooks/useScreenSize'; +import { useCallPreferences } from '$state/hooks/callPreferences'; import * as css from './styles.css'; import { ChatButton, @@ -25,11 +31,6 @@ import { SoundButton, VideoButton, } from './Controls'; -import { CallEmbed, useCallControlState } from '../../plugins/call'; -import { stopPropagation } from '../../utils/keyboard'; -import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback'; -import { useRoom } from '../../hooks/useRoom'; -import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize'; type CallControlsProps = { callEmbed: CallEmbed; @@ -45,6 +46,12 @@ export function CallControls({ callEmbed }: CallControlsProps) { callEmbed.control ); + const { setPreferences } = useCallPreferences(); + + useEffect(() => { + setPreferences({ microphone, video, sound }); + }, [microphone, video, sound, setPreferences]); + const [cords, setCords] = useState(); const handleOpenMenu: MouseEventHandler = (evt) => { diff --git a/src/app/state/hooks/callPreferences.ts b/src/app/state/hooks/callPreferences.ts index 829ed4b43..d02700f05 100644 --- a/src/app/state/hooks/callPreferences.ts +++ b/src/app/state/hooks/callPreferences.ts @@ -18,6 +18,7 @@ export const useCallPreferences = (): CallPreferences & { toggleMicrophone: () => void; toggleVideo: () => void; toggleSound: () => void; + setPreferences: (prefs: CallPreferences) => void; } => { const callPrefAtom = useCallPreferencesAtom(); const [pref, setPref] = useAtom(callPrefAtom); @@ -57,5 +58,6 @@ export const useCallPreferences = (): CallPreferences & { toggleMicrophone, toggleVideo, toggleSound, + setPreferences: setPref, }; };