Merge branch 'config_page_open_close_func' into for_webui
This commit is contained in:
@@ -134,10 +134,19 @@ const UiLanguageController = () => {
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
import { useStore_MainFunctionsStateMemory } from "@store";
|
||||||
import { useVolume } from "@logics_common/useVolume";
|
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 ConfigPageCloseTrigger = () => {
|
||||||
const { currentIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
const { currentIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||||
|
const { currentMainFunctionsStateMemory, updateMainFunctionsStateMemory} = useStore_MainFunctionsStateMemory();
|
||||||
|
const {
|
||||||
|
currentTranscriptionSendStatus,
|
||||||
|
setTranscriptionSend,
|
||||||
|
currentTranscriptionReceiveStatus,
|
||||||
|
setTranscriptionReceive,
|
||||||
|
} = useMainFunction();
|
||||||
const {
|
const {
|
||||||
currentMicThresholdCheckStatus,
|
currentMicThresholdCheckStatus,
|
||||||
volumeCheckStop_Mic,
|
volumeCheckStop_Mic,
|
||||||
@@ -145,12 +154,30 @@ const ConfigPageCloseTrigger = () => {
|
|||||||
volumeCheckStop_Speaker,
|
volumeCheckStop_Speaker,
|
||||||
} = useVolume();
|
} = 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(() => {
|
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 (currentMicThresholdCheckStatus.data === true) volumeCheckStop_Mic();
|
||||||
if (currentSpeakerThresholdCheckStatus.data === true) volumeCheckStop_Speaker();
|
if (currentSpeakerThresholdCheckStatus.data === true) volumeCheckStop_Speaker();
|
||||||
|
restoreMainFunctionState();
|
||||||
}
|
}
|
||||||
}, [currentIsOpenedConfigPage]);
|
}, [currentIsOpenedConfigPage.data]);
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
|
||||||
import styles from "./Topbar.module.scss";
|
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 ArrowLeftSvg from "@images/arrow_left.svg?react";
|
||||||
|
|
||||||
import { TitleBox } from "./title_box/TitleBox";
|
import { TitleBox } from "./title_box/TitleBox";
|
||||||
@@ -9,9 +9,9 @@ import { SectionTitleBox } from "./section_title_box/SectionTitleBox";
|
|||||||
import { CompactSwitchBox } from "./compact_switch_box/CompactSwitchBox";
|
import { CompactSwitchBox } from "./compact_switch_box/CompactSwitchBox";
|
||||||
|
|
||||||
export const Topbar = () => {
|
export const Topbar = () => {
|
||||||
const { currentIsOpenedConfigPage, updateIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
const { currentIsOpenedConfigPage, setIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||||
const closeConfigPage = () => {
|
const closeConfigPage = () => {
|
||||||
updateIsOpenedConfigPage(false);
|
setIsOpenedConfigPage(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ import clsx from "clsx";
|
|||||||
import styles from "./MainPage.module.scss";
|
import styles from "./MainPage.module.scss";
|
||||||
import { SidebarSection } from "./sidebar_section/SidebarSection";
|
import { SidebarSection } from "./sidebar_section/SidebarSection";
|
||||||
import { MainSection } from "./main_section/MainSection";
|
import { MainSection } from "./main_section/MainSection";
|
||||||
import { useStore_IsOpenedConfigPage } from "@store";
|
import { useIsOpenedConfigPage } from "@logics_common/useIsOpenedConfigPage";
|
||||||
|
|
||||||
export const MainPage = () => {
|
export const MainPage = () => {
|
||||||
const { currentIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
const { currentIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx(styles.page, styles.main_page, {
|
<div className={clsx(styles.page, styles.main_page, {
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import styles from "./OpenSettings.module.scss";
|
import styles from "./OpenSettings.module.scss";
|
||||||
import { useStore_IsOpenedConfigPage } from "@store";
|
import { useIsOpenedConfigPage } from "@logics_common/useIsOpenedConfigPage";
|
||||||
import ConfigurationSvg from "@images/configuration.svg?react";
|
import ConfigurationSvg from "@images/configuration.svg?react";
|
||||||
|
|
||||||
export const OpenSettings = () => {
|
export const OpenSettings = () => {
|
||||||
const { updateIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
const { setIsOpenedConfigPage } = useIsOpenedConfigPage();
|
||||||
|
|
||||||
const openConfigPage = () => {
|
const openConfigPage = () => {
|
||||||
updateIsOpenedConfigPage(true);
|
setIsOpenedConfigPage(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
22
src-ui/logics/common/useIsOpenedConfigPage.js
Normal file
22
src-ui/logics/common/useIsOpenedConfigPage.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { useStore_IsOpenedConfigPage } from "@store";
|
||||||
|
import { useStdoutToPython } from "@logics/useStdoutToPython";
|
||||||
|
|
||||||
|
export const useIsOpenedConfigPage = () => {
|
||||||
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
|
const { currentIsOpenedConfigPage, updateIsOpenedConfigPage } = useStore_IsOpenedConfigPage();
|
||||||
|
|
||||||
|
const setIsOpenedConfigPage = (is_opened) => {
|
||||||
|
updateIsOpenedConfigPage(is_opened);
|
||||||
|
// if (is_opened) {
|
||||||
|
// asyncStdoutToPython("/set/enable/config_window");
|
||||||
|
// } else {
|
||||||
|
// asyncStdoutToPython("/set/disable/config_window");
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
currentIsOpenedConfigPage,
|
||||||
|
setIsOpenedConfigPage,
|
||||||
|
updateIsOpenedConfigPage,
|
||||||
|
};
|
||||||
|
};
|
||||||
@@ -32,32 +32,36 @@ export const useMainFunction = () => {
|
|||||||
|
|
||||||
const { asyncStdoutToPython } = useStdoutToPython();
|
const { asyncStdoutToPython } = useStdoutToPython();
|
||||||
|
|
||||||
const toggleTranslation = () => {
|
const setTranslation = (to_enable) => {
|
||||||
pendingTranslationStatus();
|
pendingTranslationStatus();
|
||||||
if (currentTranslationStatus.data) {
|
if (to_enable) {
|
||||||
asyncStdoutToPython("/set/disable/translation");
|
|
||||||
} else {
|
|
||||||
asyncStdoutToPython("/set/enable/translation");
|
asyncStdoutToPython("/set/enable/translation");
|
||||||
|
} else {
|
||||||
|
asyncStdoutToPython("/set/disable/translation");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const toggleTranslation = () => setTranslation(!currentTranslationStatus.data);
|
||||||
|
|
||||||
const toggleTranscriptionSend = () => {
|
const setTranscriptionSend = (to_enable) => {
|
||||||
pendingTranscriptionSendStatus();
|
pendingTranscriptionSendStatus();
|
||||||
if (currentTranscriptionSendStatus.data) {
|
if (to_enable) {
|
||||||
asyncStdoutToPython("/set/disable/transcription_send");
|
|
||||||
} else {
|
|
||||||
asyncStdoutToPython("/set/enable/transcription_send");
|
asyncStdoutToPython("/set/enable/transcription_send");
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleTranscriptionReceive = () => {
|
|
||||||
pendingTranscriptionReceiveStatus();
|
|
||||||
if (currentTranscriptionReceiveStatus.data) {
|
|
||||||
asyncStdoutToPython("/set/disable/transcription_receive");
|
|
||||||
} else {
|
} else {
|
||||||
asyncStdoutToPython("/set/enable/transcription_receive");
|
asyncStdoutToPython("/set/disable/transcription_send");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const toggleTranscriptionSend = () => setTranscriptionSend(!currentTranscriptionSendStatus.data);
|
||||||
|
|
||||||
|
const setTranscriptionReceive = (to_enable) => {
|
||||||
|
pendingTranscriptionReceiveStatus();
|
||||||
|
if (to_enable) {
|
||||||
|
asyncStdoutToPython("/set/enable/transcription_receive");
|
||||||
|
} else {
|
||||||
|
asyncStdoutToPython("/set/disable/transcription_receive");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const toggleTranscriptionReceive = () => setTranscriptionReceive(!currentTranscriptionReceiveStatus.data);
|
||||||
|
|
||||||
|
|
||||||
const toggleForeground = () => {
|
const toggleForeground = () => {
|
||||||
const main_page = getCurrent();
|
const main_page = getCurrent();
|
||||||
@@ -70,14 +74,17 @@ export const useMainFunction = () => {
|
|||||||
currentTranslationStatus,
|
currentTranslationStatus,
|
||||||
toggleTranslation,
|
toggleTranslation,
|
||||||
updateTranslationStatus,
|
updateTranslationStatus,
|
||||||
|
setTranslation,
|
||||||
|
|
||||||
currentTranscriptionSendStatus,
|
currentTranscriptionSendStatus,
|
||||||
toggleTranscriptionSend,
|
toggleTranscriptionSend,
|
||||||
updateTranscriptionSendStatus,
|
updateTranscriptionSendStatus,
|
||||||
|
setTranscriptionSend,
|
||||||
|
|
||||||
currentTranscriptionReceiveStatus,
|
currentTranscriptionReceiveStatus,
|
||||||
toggleTranscriptionReceive,
|
toggleTranscriptionReceive,
|
||||||
updateTranscriptionReceiveStatus,
|
updateTranscriptionReceiveStatus,
|
||||||
|
setTranscriptionReceive,
|
||||||
|
|
||||||
currentForegroundStatus,
|
currentForegroundStatus,
|
||||||
toggleForeground,
|
toggleForeground,
|
||||||
|
|||||||
@@ -98,8 +98,12 @@ const createAtomWithHook = (initialValue, base_name, options) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Common
|
||||||
export const { atomInstance: Atom_SoftwareVersion, useHook: useStore_SoftwareVersion } = createAtomWithHook("-", "SoftwareVersion");
|
export const { atomInstance: Atom_IsOpenedConfigPage, useHook: useStore_IsOpenedConfigPage } = createAtomWithHook(false, "IsOpenedConfigPage");
|
||||||
|
export const { atomInstance: Atom_MainFunctionsStateMemory, useHook: useStore_MainFunctionsStateMemory } = createAtomWithHook({
|
||||||
|
transcription_send: false,
|
||||||
|
transcription_receive: false,
|
||||||
|
}, "MainFunctionsStateMemory");
|
||||||
|
|
||||||
// Main Page
|
// Main Page
|
||||||
// Functions
|
// Functions
|
||||||
@@ -122,9 +126,6 @@ export const { atomInstance: Atom_TranslationEngines, useHook: useStore_Translat
|
|||||||
export const { atomInstance: Atom_SelectedTranslationEngines, useHook: useStore_SelectedTranslationEngines } = createAtomWithHook({}, "SelectedTranslationEngines");
|
export const { atomInstance: Atom_SelectedTranslationEngines, useHook: useStore_SelectedTranslationEngines } = createAtomWithHook({}, "SelectedTranslationEngines");
|
||||||
|
|
||||||
|
|
||||||
export const { atomInstance: Atom_IsOpenedConfigPage, useHook: useStore_IsOpenedConfigPage } = createAtomWithHook(false, "IsOpenedConfigPage");
|
|
||||||
export const { atomInstance: Atom_SelectedConfigTabId, useHook: useStore_SelectedConfigTabId } = createAtomWithHook("device", "SelectedConfigTabId");
|
|
||||||
|
|
||||||
// Designs
|
// Designs
|
||||||
export const { atomInstance: Atom_IsMainPageCompactMode, useHook: useStore_IsMainPageCompactMode } = createAtomWithHook(false, "IsMainPageCompactMode");
|
export const { atomInstance: Atom_IsMainPageCompactMode, useHook: useStore_IsMainPageCompactMode } = createAtomWithHook(false, "IsMainPageCompactMode");
|
||||||
export const { atomInstance: Atom_MessageInputBoxRatio, useHook: useStore_MessageInputBoxRatio } = createAtomWithHook(20, "MessageInputBoxRatio");
|
export const { atomInstance: Atom_MessageInputBoxRatio, useHook: useStore_MessageInputBoxRatio } = createAtomWithHook(20, "MessageInputBoxRatio");
|
||||||
@@ -135,6 +136,10 @@ export const { atomInstance: Atom_IsOpenedLanguageSelector, useHook: useStore_Is
|
|||||||
|
|
||||||
|
|
||||||
// Config Page
|
// Config Page
|
||||||
|
// Common
|
||||||
|
export const { atomInstance: Atom_SoftwareVersion, useHook: useStore_SoftwareVersion } = createAtomWithHook("-", "SoftwareVersion");
|
||||||
|
export const { atomInstance: Atom_SelectedConfigTabId, useHook: useStore_SelectedConfigTabId } = createAtomWithHook("device", "SelectedConfigTabId");
|
||||||
|
|
||||||
// Designs
|
// Designs
|
||||||
export const { atomInstance: Atom_IsOpenedDropdownMenu, useHook: useStore_IsOpenedDropdownMenu } = createAtomWithHook("", "IsOpenedDropdownMenu");
|
export const { atomInstance: Atom_IsOpenedDropdownMenu, useHook: useStore_IsOpenedDropdownMenu } = createAtomWithHook("", "IsOpenedDropdownMenu");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user