[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:
17
src-ui/logics/configs/useSpeakerThreshold.js
Normal file
17
src-ui/logics/configs/useSpeakerThreshold.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useSpeakerThreshold as useStoreSpeakerThreshold } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSpeakerThreshold = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { updateSpeakerThreshold, currentSpeakerThreshold } = useStoreSpeakerThreshold();
|
||||
|
||||
const getSpeakerThreshold = () => {
|
||||
asyncStdoutToPython("/config/input_speaker_energy_threshold");
|
||||
};
|
||||
|
||||
const setSpeakerThreshold = (speaker_threshold) => {
|
||||
asyncStdoutToPython("/controller/callback_set_speaker_energy_threshold", speaker_threshold);
|
||||
};
|
||||
|
||||
return { getSpeakerThreshold, setSpeakerThreshold, currentSpeakerThreshold, updateSpeakerThreshold };
|
||||
};
|
||||
Reference in New Issue
Block a user