diff --git a/src/mixer/state.ts b/src/mixer/state.ts index a455376..50bfa00 100644 --- a/src/mixer/state.ts +++ b/src/mixer/state.ts @@ -64,7 +64,7 @@ interface MicState { openError: null | MicErrorEnum; volume: number; gain: number; - id:string; + id: string | null; } interface MixerState { @@ -124,7 +124,7 @@ const mixerState = createSlice({ volume: 1, gain: 1, openError: null, - id: "None" + id: null } } as MixerState, reducers: { @@ -168,9 +168,9 @@ const mixerState = createSlice({ setMicError(state, action: PayloadAction) { state.mic.openError = action.payload; }, - micOpen(state, micID) { + micOpen(state, action) { state.mic.open = true; - state.mic.id = micID.payload; + state.mic.id = action.payload; }, setMicLevels( state, diff --git a/src/showplanner/index.tsx b/src/showplanner/index.tsx index 8760d22..43d5224 100644 --- a/src/showplanner/index.tsx +++ b/src/showplanner/index.tsx @@ -291,21 +291,18 @@ function LibraryColumn() { function MicControl() { const state = useSelector((state: RootState) => state.mixer.mic); - const [gotMicList, setGotMicList] = useState(false); - const dummylist: MediaDeviceInfo[] = [] - const [micList, setMicList] = useState(dummylist); + const [micList, setMicList] = useState([]); const dispatch = useDispatch(); - const [micSource, setMicSource] = useState("None") + const [nextMicSource, setNextMicSource] = useState("None") // next mic source const [lock, setLock] = useState(false) - if (gotMicList == false){ + useEffect(()=>{ navigator.mediaDevices.enumerateDevices() .then((devices)=>{ setMicList(reduceToInputs(devices)) - setGotMicList(true) }) .catch(() => {console.log("Could not fetch devices");}) - } + }, []) function reduceToInputs(devices:MediaDeviceInfo[]){ var temp: MediaDeviceInfo[] = [] @@ -323,8 +320,8 @@ function MicControl() {

Microphone

@@ -335,8 +332,8 @@ function MicControl() {