[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:
28
src-ui/logics/configs/useEnableAutoClearMessageBox.js
Normal file
28
src-ui/logics/configs/useEnableAutoClearMessageBox.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useEnableAutoClearMessageBox as useStoreEnableAutoClearMessageBox } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useEnableAutoClearMessageBox = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { currentEnableAutoClearMessageBox, updateEnableAutoClearMessageBox } = useStoreEnableAutoClearMessageBox();
|
||||
|
||||
const getEnableAutoClearMessageBox = () => {
|
||||
updateEnableAutoClearMessageBox(() => new Promise(() => {}));
|
||||
asyncStdoutToPython("/config/enable_auto_clear_message_box");
|
||||
};
|
||||
|
||||
const toggleEnableAutoClearMessageBox = () => {
|
||||
updateEnableAutoClearMessageBox(() => new Promise(() => {}));
|
||||
if (currentEnableAutoClearMessageBox.data) {
|
||||
asyncStdoutToPython("/controller/callback_disable_auto_clear_chatbox");
|
||||
} else {
|
||||
asyncStdoutToPython("/controller/callback_enable_auto_clear_chatbox");
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
getEnableAutoClearMessageBox,
|
||||
toggleEnableAutoClearMessageBox,
|
||||
currentEnableAutoClearMessageBox,
|
||||
updateEnableAutoClearMessageBox
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user