[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/useMicThreshold.js
Normal file
17
src-ui/logics/configs/useMicThreshold.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { useMicThreshold as useStoreMicThreshold } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useMicThreshold = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { updateMicThreshold, currentMicThreshold } = useStoreMicThreshold();
|
||||
|
||||
const getMicThreshold = () => {
|
||||
asyncStdoutToPython("/config/input_mic_energy_threshold");
|
||||
};
|
||||
|
||||
const setMicThreshold = (mic_threshold) => {
|
||||
asyncStdoutToPython("/controller/callback_set_mic_energy_threshold", mic_threshold);
|
||||
};
|
||||
|
||||
return { getMicThreshold, setMicThreshold, currentMicThreshold, updateMicThreshold };
|
||||
};
|
||||
Reference in New Issue
Block a user