fix call preferences not persisting
This commit is contained in:
2 files changed
+16
-7
No files matched your search
@@ -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<RectCords>();
|
||||
|
||||
const handleOpenMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user