[Refactor] useReceiveRoutes: Add comments and change the order.

This commit is contained in:
Sakamoto Shiina
2024-09-21 00:40:30 +09:00
parent 66e3267798
commit 79e4d28176

View File

@@ -21,14 +21,12 @@ import { useSendMessageButtonType } from "@logics_configs/useSendMessageButtonTy
import { useUiLanguage } from "@logics_configs/useUiLanguage"; import { useUiLanguage } from "@logics_configs/useUiLanguage";
export const useReceiveRoutes = () => { export const useReceiveRoutes = () => {
const { const {
updateTranslationStatus, updateTranslationStatus,
updateTranscriptionSendStatus, updateTranscriptionSendStatus,
updateTranscriptionReceiveStatus, updateTranscriptionReceiveStatus,
} = useMainFunction(); } = useMainFunction();
const { const {
updateSelectedPresetTabNumber, updateSelectedPresetTabNumber,
updateEnableMultiTranslation, updateEnableMultiTranslation,
@@ -36,34 +34,25 @@ export const useReceiveRoutes = () => {
updateSelectedTargetLanguages updateSelectedTargetLanguages
} = useLanguageSettings(); } = useLanguageSettings();
const { updateSelectableLanguageList } = useSelectableLanguageList(); const { updateSelectableLanguageList } = useSelectableLanguageList();
const { const {
updateSentMessageLogById, updateSentMessageLogById,
addSentMessageLog, addSentMessageLog,
addReceivedMessageLog, addReceivedMessageLog,
} = useMessage(); } = useMessage();
const { updateSoftwareVersion } = useSoftwareVersion(); const { updateSoftwareVersion } = useSoftwareVersion();
const { updateEnableAutoMicSelect } = useEnableAutoMicSelect(); const { updateEnableAutoMicSelect } = useEnableAutoMicSelect();
const { updateEnableAutoSpeakerSelect } = useEnableAutoSpeakerSelect(); const { updateEnableAutoSpeakerSelect } = useEnableAutoSpeakerSelect();
const { updateMicHostList } = useMicHostList(); const { updateMicHostList } = useMicHostList();
const { updateSelectedMicHost } = useSelectedMicHost(); const { updateSelectedMicHost } = useSelectedMicHost();
const { updateMicDeviceList } = useMicDeviceList(); const { updateMicDeviceList } = useMicDeviceList();
const { updateSelectedMicDevice } = useSelectedMicDevice(); const { updateSelectedMicDevice } = useSelectedMicDevice();
const { updateSpeakerDeviceList } = useSpeakerDeviceList(); const { updateSpeakerDeviceList } = useSpeakerDeviceList();
const { updateSelectedSpeakerDevice } = useSelectedSpeakerDevice(); const { updateSelectedSpeakerDevice } = useSelectedSpeakerDevice();
const { updateMicThreshold, updateEnableAutomaticMicThreshold } = useMicThreshold(); const { updateMicThreshold, updateEnableAutomaticMicThreshold } = useMicThreshold();
const { updateSpeakerThreshold, updateEnableAutomaticSpeakerThreshold } = useSpeakerThreshold(); const { updateSpeakerThreshold, updateEnableAutomaticSpeakerThreshold } = useSpeakerThreshold();
const { updateEnableAutoClearMessageBox } = useEnableAutoClearMessageBox(); const { updateEnableAutoClearMessageBox } = useEnableAutoClearMessageBox();
const { updateSendMessageButtonType } = useSendMessageButtonType(); const { updateSendMessageButtonType } = useSendMessageButtonType();
const { updateUiLanguage } = useUiLanguage(); const { updateUiLanguage } = useUiLanguage();
const { const {
updateVolumeVariable_Mic, updateVolumeVariable_Mic,
updateVolumeVariable_Speaker, updateVolumeVariable_Speaker,
@@ -72,6 +61,8 @@ export const useReceiveRoutes = () => {
} = useVolume(); } = useVolume();
const routes = { const routes = {
// Main Page
// Main Functions
"/set/enable_translation": updateTranslationStatus, "/set/enable_translation": updateTranslationStatus,
"/set/disable_translation": updateTranslationStatus, "/set/disable_translation": updateTranslationStatus,
"/set/enable_transcription_send": updateTranscriptionSendStatus, "/set/enable_transcription_send": updateTranscriptionSendStatus,
@@ -79,6 +70,7 @@ export const useReceiveRoutes = () => {
"/set/enable_transcription_receive": updateTranscriptionReceiveStatus, "/set/enable_transcription_receive": updateTranscriptionReceiveStatus,
"/set/disable_transcription_receive": updateTranscriptionReceiveStatus, "/set/disable_transcription_receive": updateTranscriptionReceiveStatus,
// Language Settings
"/get/selected_tab_no": updateSelectedPresetTabNumber, "/get/selected_tab_no": updateSelectedPresetTabNumber,
"/set/selected_tab_no": updateSelectedPresetTabNumber, "/set/selected_tab_no": updateSelectedPresetTabNumber,
"/get/multi_language_translation": updateEnableMultiTranslation, "/get/multi_language_translation": updateEnableMultiTranslation,
@@ -87,10 +79,20 @@ export const useReceiveRoutes = () => {
"/get/selected_target_languages": updateSelectedTargetLanguages, "/get/selected_target_languages": updateSelectedTargetLanguages,
"/set/selected_target_languages": updateSelectedTargetLanguages, "/set/selected_target_languages": updateSelectedTargetLanguages,
// Language Selector
"/get/list_languages": updateSelectableLanguageList, "/get/list_languages": updateSelectableLanguageList,
// Message
"/run/send_message_box": updateSentMessageLogById,
"/action/transcription_send_mic_message": addSentMessageLog,
"/action/transcription_receive_speaker_message": addReceivedMessageLog,
// Config Page
// Common
"/get/version": updateSoftwareVersion, "/get/version": updateSoftwareVersion,
// Device Tab
"/get/auto_mic_select": updateEnableAutoMicSelect, "/get/auto_mic_select": updateEnableAutoMicSelect,
"/set/enable_auto_mic_select": updateEnableAutoMicSelect, "/set/enable_auto_mic_select": updateEnableAutoMicSelect,
"/set/disable_auto_mic_select": updateEnableAutoMicSelect, "/set/disable_auto_mic_select": updateEnableAutoMicSelect,
@@ -120,13 +122,6 @@ export const useReceiveRoutes = () => {
"/set/enable_check_speaker_threshold": updateSpeakerThresholdCheckStatus, "/set/enable_check_speaker_threshold": updateSpeakerThresholdCheckStatus,
"/set/disable_check_speaker_threshold": updateSpeakerThresholdCheckStatus, "/set/disable_check_speaker_threshold": updateSpeakerThresholdCheckStatus,
"/get/auto_clear_message_box": updateEnableAutoClearMessageBox,
"/set/enable_auto_clear_message_box": updateEnableAutoClearMessageBox,
"/set/disable_auto_clear_message_box": updateEnableAutoClearMessageBox,
"/get/send_message_button_type": updateSendMessageButtonType,
"/set/send_message_button_type": updateSendMessageButtonType,
"/get/mic_energy_threshold": updateMicThreshold, "/get/mic_energy_threshold": updateMicThreshold,
"/set/mic_energy_threshold": updateMicThreshold, "/set/mic_energy_threshold": updateMicThreshold,
"/get/speaker_energy_threshold": updateSpeakerThreshold, "/get/speaker_energy_threshold": updateSpeakerThreshold,
@@ -139,13 +134,17 @@ export const useReceiveRoutes = () => {
"/set/enable_speaker_dynamic_energy_threshold": updateEnableAutomaticSpeakerThreshold, "/set/enable_speaker_dynamic_energy_threshold": updateEnableAutomaticSpeakerThreshold,
"/set/disable_speaker_dynamic_energy_threshold": updateEnableAutomaticSpeakerThreshold, "/set/disable_speaker_dynamic_energy_threshold": updateEnableAutomaticSpeakerThreshold,
// Appearance
"/get/ui_language": updateUiLanguage, "/get/ui_language": updateUiLanguage,
"/set/ui_language": updateUiLanguage, "/set/ui_language": updateUiLanguage,
// Others Tab
"/get/auto_clear_message_box": updateEnableAutoClearMessageBox,
"/set/enable_auto_clear_message_box": updateEnableAutoClearMessageBox,
"/set/disable_auto_clear_message_box": updateEnableAutoClearMessageBox,
"/run/send_message_box": updateSentMessageLogById, "/get/send_message_button_type": updateSendMessageButtonType,
"/action/transcription_send_mic_message": addSentMessageLog, "/set/send_message_button_type": updateSendMessageButtonType,
"/action/transcription_receive_speaker_message": addReceivedMessageLog
}; };
const receiveRoutes = (parsed_data) => { const receiveRoutes = (parsed_data) => {