[Refactor] Refactor the way import files.
Organize some codes.
This commit is contained in:
42
src-ui/logics/configs/device/useMicThreshold.js
Normal file
42
src-ui/logics/configs/device/useMicThreshold.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { useStore_MicThreshold, useStore_EnableAutomaticMicThreshold } from "@store";
|
||||
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||
|
||||
export const useMicThreshold = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { updateMicThreshold, currentMicThreshold } = useStore_MicThreshold();
|
||||
const { updateEnableAutomaticMicThreshold, currentEnableAutomaticMicThreshold, pendingEnableAutomaticMicThreshold } = useStore_EnableAutomaticMicThreshold();
|
||||
|
||||
const getMicThreshold = () => {
|
||||
asyncStdoutToPython("/get/data/mic_threshold");
|
||||
};
|
||||
|
||||
const setMicThreshold = (mic_threshold) => {
|
||||
asyncStdoutToPython("/set/data/mic_threshold", mic_threshold);
|
||||
};
|
||||
|
||||
const getEnableAutomaticMicThreshold = () => {
|
||||
pendingEnableAutomaticMicThreshold();
|
||||
asyncStdoutToPython("/get/data/mic_automatic_threshold");
|
||||
};
|
||||
|
||||
const toggleEnableAutomaticMicThreshold = () => {
|
||||
pendingEnableAutomaticMicThreshold();
|
||||
if (currentEnableAutomaticMicThreshold.data) {
|
||||
asyncStdoutToPython("/set/disable/mic_automatic_threshold");
|
||||
} else {
|
||||
asyncStdoutToPython("/set/enable/mic_automatic_threshold");
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
currentMicThreshold,
|
||||
getMicThreshold,
|
||||
setMicThreshold,
|
||||
updateMicThreshold,
|
||||
|
||||
currentEnableAutomaticMicThreshold,
|
||||
getEnableAutomaticMicThreshold,
|
||||
toggleEnableAutomaticMicThreshold,
|
||||
updateEnableAutomaticMicThreshold,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user