[Update/Perf] Config Page: Device Tab. Add threshold_component(dev).
Improve re-render, unnecessary, problem.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useMainFunction } from "./useMainFunction";
|
||||
import { useConfig } from "./useConfig";
|
||||
import { useMessage } from "./useMessage";
|
||||
import { useVolume } from "./useVolume";
|
||||
|
||||
export const useReceiveRoutes = () => {
|
||||
const {
|
||||
@@ -25,9 +26,10 @@ export const useReceiveRoutes = () => {
|
||||
|
||||
updateSpeakerDeviceList,
|
||||
updateSelectedSpeakerDevice,
|
||||
|
||||
} = useConfig();
|
||||
|
||||
const { updateVolumeVariable_Mic } = useVolume();
|
||||
|
||||
const routes = {
|
||||
"/controller/callback_enable_translation": updateTranslationStatus,
|
||||
"/controller/callback_disable_translation": updateTranslationStatus,
|
||||
@@ -51,6 +53,8 @@ export const useReceiveRoutes = () => {
|
||||
"/config/choice_speaker_device": updateSelectedSpeakerDevice,
|
||||
"/controller/callback_set_speaker_device": updateSelectedSpeakerDevice,
|
||||
|
||||
"/action/check_mic_threshold_energy": updateVolumeVariable_Mic,
|
||||
|
||||
|
||||
"/controller/callback_messagebox_send": updateSentMessageLog,
|
||||
"/action/transcription_send_mic_message": addSentMessageLog,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { store } from "@store";
|
||||
import { encode } from 'js-base64'
|
||||
import { encode } from "js-base64";
|
||||
|
||||
export const useStdoutToPython = () => {
|
||||
const asyncStdoutToPython = async (path, value) => {
|
||||
|
||||
22
src-ui/logics/useVolume.js
Normal file
22
src-ui/logics/useVolume.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
useMicVolume,
|
||||
} from "@store";
|
||||
|
||||
import { useStdoutToPython } from "./useStdoutToPython";
|
||||
|
||||
|
||||
export const useVolume = () => {
|
||||
const { asyncStdoutToPython } = useStdoutToPython();
|
||||
const { updateMicVolume } = useMicVolume();
|
||||
|
||||
// const asyncPending = () => new Promise(() => {});
|
||||
return {
|
||||
volumeCheckStart_Mic: () => asyncStdoutToPython("/controller/callback_enable_check_mic_threshold"),
|
||||
volumeCheckStop_Mic: () => asyncStdoutToPython("/controller/callback_disable_check_mic_threshold"),
|
||||
updateVolumeVariable_Mic: (payload) => {
|
||||
updateMicVolume(payload.data);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user