[Update] 設定ページ開閉時に、音声認識オンオフ状態の復元を実装。
※今まではBackendで状態復元をしていたが、処理があれなのでUI側での便利機能としてUIが管理することに。
This commit is contained in:
@@ -134,10 +134,19 @@ const UiLanguageController = () => {
|
||||
return null;
|
||||
};
|
||||
|
||||
import { useStore_MainFunctionsStateMemory } from "@store";
|
||||
import { useVolume } from "@logics_common/useVolume";
|
||||
import { useStore_IsOpenedConfigPage } from "@store";
|
||||
import { useIsOpenedConfigPage } from "@logics_common/useIsOpenedConfigPage";
|
||||
import { useMainFunction } from "@logics_main/useMainFunction";
|
||||
const ConfigPageCloseTrigger = () => {
|
||||
const { currentIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
||||
const { currentIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||
const { currentMainFunctionsStateMemory, updateMainFunctionsStateMemory} = useStore_MainFunctionsStateMemory();
|
||||
const {
|
||||
currentTranscriptionSendStatus,
|
||||
setTranscriptionSend,
|
||||
currentTranscriptionReceiveStatus,
|
||||
setTranscriptionReceive,
|
||||
} = useMainFunction();
|
||||
const {
|
||||
currentMicThresholdCheckStatus,
|
||||
volumeCheckStop_Mic,
|
||||
@@ -145,12 +154,30 @@ const ConfigPageCloseTrigger = () => {
|
||||
volumeCheckStop_Speaker,
|
||||
} = useVolume();
|
||||
|
||||
|
||||
const memorizeLatestMainFunctionsState = () => {
|
||||
updateMainFunctionsStateMemory({
|
||||
transcription_send: currentTranscriptionSendStatus.data,
|
||||
transcription_receive: currentTranscriptionReceiveStatus.data,
|
||||
});
|
||||
};
|
||||
|
||||
const restoreMainFunctionState = () => {
|
||||
if (currentMainFunctionsStateMemory.data.transcription_send === true) setTranscriptionSend(true);
|
||||
if (currentMainFunctionsStateMemory.data.transcription_receive === true) setTranscriptionReceive(true);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (currentIsOpenedConfigPage.data === false) {
|
||||
if (currentIsOpenedConfigPage.data === true) { // When config page is opened.
|
||||
memorizeLatestMainFunctionsState();
|
||||
if (currentTranscriptionSendStatus.data === true) setTranscriptionSend(false);
|
||||
if (currentTranscriptionReceiveStatus.data === true) setTranscriptionReceive(false);
|
||||
} else if (currentIsOpenedConfigPage.data === false) { // When config page is closed.
|
||||
if (currentMicThresholdCheckStatus.data === true) volumeCheckStop_Mic();
|
||||
if (currentSpeakerThresholdCheckStatus.data === true) volumeCheckStop_Speaker();
|
||||
restoreMainFunctionState();
|
||||
}
|
||||
}, [currentIsOpenedConfigPage]);
|
||||
}, [currentIsOpenedConfigPage.data]);
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import clsx from "clsx";
|
||||
|
||||
import styles from "./Topbar.module.scss";
|
||||
import { useStore_IsOpenedConfigPage } from "@store";
|
||||
import { useIsOpenedConfigPage } from "@logics_common/useIsOpenedConfigPage";
|
||||
import ArrowLeftSvg from "@images/arrow_left.svg?react";
|
||||
|
||||
import { TitleBox } from "./title_box/TitleBox";
|
||||
@@ -9,9 +9,9 @@ import { SectionTitleBox } from "./section_title_box/SectionTitleBox";
|
||||
import { CompactSwitchBox } from "./compact_switch_box/CompactSwitchBox";
|
||||
|
||||
export const Topbar = () => {
|
||||
const { currentIsOpenedConfigPage, updateIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
||||
const { currentIsOpenedConfigPage, setIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||
const closeConfigPage = () => {
|
||||
updateIsOpenedConfigPage(false);
|
||||
setIsOpenedConfigPage(false);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -2,10 +2,10 @@ import clsx from "clsx";
|
||||
import styles from "./MainPage.module.scss";
|
||||
import { SidebarSection } from "./sidebar_section/SidebarSection";
|
||||
import { MainSection } from "./main_section/MainSection";
|
||||
import { useStore_IsOpenedConfigPage } from "@store";
|
||||
import { useIsOpenedConfigPage } from "@logics_common/useIsOpenedConfigPage";
|
||||
|
||||
export const MainPage = () => {
|
||||
const { currentIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
||||
const { currentIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||
|
||||
return (
|
||||
<div className={clsx(styles.page, styles.main_page, {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import styles from "./OpenSettings.module.scss";
|
||||
import { useStore_IsOpenedConfigPage } from "@store";
|
||||
import { useIsOpenedConfigPage } from "@logics_common/useIsOpenedConfigPage";
|
||||
import ConfigurationSvg from "@images/configuration.svg?react";
|
||||
|
||||
export const OpenSettings = () => {
|
||||
const { updateIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
||||
const { setIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||
|
||||
const openConfigPage = () => {
|
||||
updateIsOpenedConfigPage(true);
|
||||
setIsOpenedConfigPage(true);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user