[Update/Perf] Config Page: Device Tab. Add threshold_component(dev).

Improve re-render, unnecessary, problem.
This commit is contained in:
Sakamoto Shiina
2024-09-07 21:32:44 +09:00
parent 480d0f3f11
commit ef5eb2fb40
13 changed files with 165 additions and 108 deletions

View File

@@ -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,

View File

@@ -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) => {

View 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);
}
};
};