[Refactor] Change state management structures. Async atom to be manage manually.

This commit is contained in:
Sakamoto Shiina
2024-09-23 03:44:33 +09:00
parent 586aaf0091
commit 0616092eff
49 changed files with 295 additions and 190 deletions

View File

@@ -71,8 +71,8 @@ const generateMessageObject = (data, category) => {
};
const updateItemById = (id, translated_data) => (prev_items) => {
return prev_items.map(item => {
const updateItemById = (id, translated_data) => (current_items) => {
return current_items.data.map(item => {
if (item.id === id) {
item.status = "ok";
item.messages.translated = translated_data;

View File

@@ -11,17 +11,24 @@ export const useVolume = () => {
const { asyncStdoutToPython } = useStdoutToPython();
const { updateMicVolume } = useStore_MicVolume();
const { updateSpeakerVolume } = useStore_SpeakerVolume();
const { currentMicThresholdCheckStatus, updateMicThresholdCheckStatus } = useStore_MicThresholdCheckStatus();
const { currentSpeakerThresholdCheckStatus, updateSpeakerThresholdCheckStatus } = useStore_SpeakerThresholdCheckStatus();
const {
currentMicThresholdCheckStatus,
updateMicThresholdCheckStatus,
pendingMicThresholdCheckStatus,
} = useStore_MicThresholdCheckStatus();
const {
currentSpeakerThresholdCheckStatus,
updateSpeakerThresholdCheckStatus,
pendingSpeakerThresholdCheckStatus,
} = useStore_SpeakerThresholdCheckStatus();
const asyncPending = () => new Promise(() => {});
return {
volumeCheckStart_Mic: () => {
updateMicThresholdCheckStatus(asyncPending);
pendingMicThresholdCheckStatus();
asyncStdoutToPython("/set/enable_check_mic_threshold");
},
volumeCheckStop_Mic: () => {
updateMicThresholdCheckStatus(asyncPending);
pendingMicThresholdCheckStatus();
asyncStdoutToPython("/set/disable_check_mic_threshold");
},
updateVolumeVariable_Mic: (payload) => {
@@ -35,11 +42,11 @@ export const useVolume = () => {
volumeCheckStart_Speaker: () => {
updateSpeakerVolume("0");
updateSpeakerThresholdCheckStatus(asyncPending);
pendingSpeakerThresholdCheckStatus();
asyncStdoutToPython("/set/enable_check_speaker_threshold");
},
volumeCheckStop_Speaker: () => {
updateSpeakerThresholdCheckStatus(asyncPending);
pendingSpeakerThresholdCheckStatus();
asyncStdoutToPython("/set/disable_check_speaker_threshold");
},
updateVolumeVariable_Speaker: (payload) => {