[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:
19
src-ui/logics/configs/useSelectedMicHost.js
Normal file
19
src-ui/logics/configs/useSelectedMicHost.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useSelectedMicHost as useStoreSelectedMicHost } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useSelectedMicHost = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentSelectedMicHost, updateSelectedMicHost } = useStoreSelectedMicHost();
|
||||
|
||||
const getSelectedMicHost = () => {
|
||||
updateSelectedMicHost(() => new Promise(() => {}));
|
||||
asyncStdoutToPython("/config/choice_mic_host");
|
||||
};
|
||||
|
||||
const setSelectedMicHost = (selected_mic_host) => {
|
||||
updateSelectedMicHost(() => new Promise(() => {}));
|
||||
asyncStdoutToPython("/controller/callback_set_mic_host", selected_mic_host);
|
||||
};
|
||||
|
||||
return { currentSelectedMicHost, getSelectedMicHost, updateSelectedMicHost, setSelectedMicHost };
|
||||
};
|
||||
Reference in New Issue
Block a user