[Perf/bugfix] Separate custom hooks and prevent re-render issues.

Config Page: Device Tab. threshold component. fix problem that the input component focused out when input something each time.
Set threshold data when started python.
This commit is contained in:
Sakamoto Shiina
2024-09-10 17:21:03 +09:00
parent 37989d5f7a
commit ac6b898a46
23 changed files with 514 additions and 443 deletions

View File

@@ -3,28 +3,25 @@ import {
useSpeakerVolume,
} from "@store";
import { useStdoutToPython } from "./useStdoutToPython";
import { useStdoutToPython } from "@logics/useStdoutToPython";
export const useVolume = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { updateMicVolume } = useMicVolume();
const { updateSpeakerVolume } = useSpeakerVolume();
// const asyncPending = () => new Promise(() => {});
return {
volumeCheckStart_Mic: () => asyncStdoutToPython("/controller/callback_enable_check_mic_threshold"),
volumeCheckStop_Mic: () => asyncStdoutToPython("/controller/callback_disable_check_mic_threshold"),
updateVolumeVariable_Mic: (payload) => {
updateMicVolume(payload.data);
updateMicVolume(payload);
},
volumeCheckStart_Speaker: () => asyncStdoutToPython("/controller/callback_enable_check_speaker_threshold"),
volumeCheckStop_Speaker: () => asyncStdoutToPython("/controller/callback_disable_check_speaker_threshold"),
updateVolumeVariable_Speaker: (payload) => {
updateSpeakerVolume(payload.data);
}
updateSpeakerVolume(payload);
},
};
};