[Refactor] (Huge Refactoring) ReceiveRoutes: change the way define endpoints, hooks and methods.

Remove 'multi language translation enable/disable' related methods that is no longer in use from quite ago.
This commit is contained in:
Sakamoto Shiina
2025-06-14 01:07:12 +09:00
parent 1fcb765ca0
commit fb2b224231
22 changed files with 510 additions and 609 deletions

View File

@@ -1,5 +1,6 @@
import { useStore_MicDeviceList } from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { arrayToObject } from "@utils";
export const useMicDeviceList = () => {
const { asyncStdoutToPython } = useStdoutToPython();
@@ -10,9 +11,17 @@ export const useMicDeviceList = () => {
asyncStdoutToPython("/get/data/mic_device_list");
};
const updateMicDeviceList_FromBackend = (payload) => {
updateMicDeviceList(arrayToObject(payload));
};
return {
currentMicDeviceList,
getMicDeviceList,
updateMicDeviceList,
updateMicDeviceList_FromBackend,
};
};

View File

@@ -1,5 +1,6 @@
import { useStore_MicHostList } from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { arrayToObject } from "@utils";
export const useMicHostList = () => {
const { asyncStdoutToPython } = useStdoutToPython();
@@ -10,9 +11,15 @@ export const useMicHostList = () => {
asyncStdoutToPython("/get/data/mic_host_list");
};
const updateMicHostList_FromBackend = (payload) => {
updateMicHostList(arrayToObject(payload));
};
return {
currentMicHostList,
getMicHostList,
updateMicHostList,
updateMicHostList_FromBackend,
};
};

View File

@@ -1,10 +1,13 @@
import { useStore_SelectedMicHost } from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { useSelectedMicDevice } from "@logics_configs";
export const useSelectedMicHost = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { currentSelectedMicHost, updateSelectedMicHost, pendingSelectedMicHost } = useStore_SelectedMicHost();
const { updateSelectedMicDevice } = useSelectedMicDevice();
const getSelectedMicHost = () => {
pendingSelectedMicHost();
asyncStdoutToPython("/get/data/selected_mic_host");
@@ -15,10 +18,20 @@ export const useSelectedMicHost = () => {
asyncStdoutToPython("/set/data/selected_mic_host", selected_mic_host);
};
// Need refactoring (Duplicated, Host, Device)
const updateSelectedMicHostAndDevice = (payload) => {
updateSelectedMicHost(payload.host);
updateSelectedMicDevice(payload.device);
};
return {
currentSelectedMicHost,
getSelectedMicHost,
updateSelectedMicHost,
setSelectedMicHost,
updateSelectedMicHostAndDevice,
};
};

View File

@@ -1,5 +1,6 @@
import { useStore_SpeakerDeviceList } from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { arrayToObject } from "@utils";
export const useSpeakerDeviceList = () => {
const { asyncStdoutToPython } = useStdoutToPython();
@@ -10,9 +11,16 @@ export const useSpeakerDeviceList = () => {
asyncStdoutToPython("/get/data/speaker_device_list");
};
const updateSpeakerDeviceList_FromBackend = (payload) => {
updateSpeakerDeviceList(arrayToObject(payload));
};
return {
currentSpeakerDeviceList,
getSpeakerDeviceList,
updateSpeakerDeviceList,
updateSpeakerDeviceList_FromBackend,
};
};

View File

@@ -19,10 +19,18 @@ export const useEnableVrcMicMuteSync = () => {
}
};
const updateEnableVrcMicMuteSync_FromBackend = (payload) => {
updateEnableVrcMicMuteSync((old_value) => {
return {...old_value.data, is_enabled: payload};
});
};
return {
currentEnableVrcMicMuteSync,
getEnableVrcMicMuteSync,
toggleEnableVrcMicMuteSync,
updateEnableVrcMicMuteSync,
updateEnableVrcMicMuteSync_FromBackend,
};
};

View File

@@ -15,10 +15,27 @@ export const useMicWordFilterList = () => {
asyncStdoutToPython("/set/data/mic_word_filter", selected_mic_word_filter);
};
const updateMicWordFilterList_FromBackend = (payload) => {
updateMicWordFilterList((prev_list) => {
const updated_list = [...prev_list.data];
for (const value of payload) {
const existing_item = updated_list.find(item => item.value === value);
if (existing_item) {
existing_item.is_redoable = false;
} else {
updated_list.push({ value, is_redoable: false });
}
}
return updated_list;
});
};
return {
currentMicWordFilterList,
getMicWordFilterList,
updateMicWordFilterList,
setMicWordFilterList,
updateMicWordFilterList_FromBackend,
};
};

View File

@@ -1,5 +1,6 @@
import { useStore_SelectableWhisperComputeDeviceList } from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { transformToIndexedArray } from "@utils";
export const useSelectableWhisperComputeDeviceList = () => {
const { asyncStdoutToPython } = useStdoutToPython();
@@ -10,9 +11,15 @@ export const useSelectableWhisperComputeDeviceList = () => {
asyncStdoutToPython("/get/data/transcription_compute_device_list");
};
const updateSelectableWhisperComputeDeviceList_FromBackend = (payload) => {
updateSelectableWhisperComputeDeviceList(transformToIndexedArray(payload));
};
return {
currentSelectableWhisperComputeDeviceList,
getSelectableWhisperComputeDeviceList,
updateSelectableWhisperComputeDeviceList,
updateSelectableWhisperComputeDeviceList_FromBackend,
};
};

View File

@@ -23,6 +23,9 @@ export const useDeepLAuthKey = () => {
pendingDeepLAuthKey();
asyncStdoutToPython("/delete/data/deepl_auth_key");
};
const deletedDeepLAuthKey = () => {
updateDeepLAuthKey("");
};
const savedDeepLAuthKey = (data) => {
updateDeepLAuthKey(data);
@@ -36,6 +39,7 @@ export const useDeepLAuthKey = () => {
setDeepLAuthKey,
deleteDeepLAuthKey,
deletedDeepLAuthKey,
savedDeepLAuthKey,
};
};

View File

@@ -1,5 +1,6 @@
import { useStore_SelectableCTranslate2ComputeDeviceList } from "@store";
import { useStdoutToPython } from "@useStdoutToPython";
import { transformToIndexedArray } from "@utils";
export const useSelectableCTranslate2ComputeDeviceList = () => {
const { asyncStdoutToPython } = useStdoutToPython();
@@ -10,9 +11,15 @@ export const useSelectableCTranslate2ComputeDeviceList = () => {
asyncStdoutToPython("/get/data/translation_compute_device_list");
};
const updateSelectableCTranslate2ComputeDeviceList_FromBackend = (payload) => {
updateSelectableCTranslate2ComputeDeviceList(transformToIndexedArray(payload));
};
return {
currentSelectableCTranslate2ComputeDeviceList,
getSelectableCTranslate2ComputeDeviceList,
updateSelectableCTranslate2ComputeDeviceList,
updateSelectableCTranslate2ComputeDeviceList_FromBackend,
};
};