Merge branch 'config_page_open_close_func' into for_webui
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 (
|
||||
|
||||
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 toggleTranslation = () => {
|
||||
const setTranslation = (to_enable) => {
|
||||
pendingTranslationStatus();
|
||||
if (currentTranslationStatus.data) {
|
||||
asyncStdoutToPython("/set/disable/translation");
|
||||
} else {
|
||||
if (to_enable) {
|
||||
asyncStdoutToPython("/set/enable/translation");
|
||||
} else {
|
||||
asyncStdoutToPython("/set/disable/translation");
|
||||
}
|
||||
};
|
||||
const toggleTranslation = () => setTranslation(!currentTranslationStatus.data);
|
||||
|
||||
const toggleTranscriptionSend = () => {
|
||||
const setTranscriptionSend = (to_enable) => {
|
||||
pendingTranscriptionSendStatus();
|
||||
if (currentTranscriptionSendStatus.data) {
|
||||
asyncStdoutToPython("/set/disable/transcription_send");
|
||||
} else {
|
||||
if (to_enable) {
|
||||
asyncStdoutToPython("/set/enable/transcription_send");
|
||||
}
|
||||
};
|
||||
|
||||
const toggleTranscriptionReceive = () => {
|
||||
pendingTranscriptionReceiveStatus();
|
||||
if (currentTranscriptionReceiveStatus.data) {
|
||||
asyncStdoutToPython("/set/disable/transcription_receive");
|
||||
} 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 main_page = getCurrent();
|
||||
@@ -70,14 +74,17 @@ export const useMainFunction = () => {
|
||||
currentTranslationStatus,
|
||||
toggleTranslation,
|
||||
updateTranslationStatus,
|
||||
setTranslation,
|
||||
|
||||
currentTranscriptionSendStatus,
|
||||
toggleTranscriptionSend,
|
||||
updateTranscriptionSendStatus,
|
||||
setTranscriptionSend,
|
||||
|
||||
currentTranscriptionReceiveStatus,
|
||||
toggleTranscriptionReceive,
|
||||
updateTranscriptionReceiveStatus,
|
||||
setTranscriptionReceive,
|
||||
|
||||
currentForegroundStatus,
|
||||
toggleForeground,
|
||||
|
||||
@@ -98,8 +98,12 @@ const createAtomWithHook = (initialValue, base_name, options) => {
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const { atomInstance: Atom_SoftwareVersion, useHook: useStore_SoftwareVersion } = createAtomWithHook("-", "SoftwareVersion");
|
||||
// Common
|
||||
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
|
||||
// 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_IsOpenedConfigPage, useHook: useStore_IsOpenedConfigPage } = createAtomWithHook(false, "IsOpenedConfigPage");
|
||||
export const { atomInstance: Atom_SelectedConfigTabId, useHook: useStore_SelectedConfigTabId } = createAtomWithHook("device", "SelectedConfigTabId");
|
||||
|
||||
// Designs
|
||||
export const { atomInstance: Atom_IsMainPageCompactMode, useHook: useStore_IsMainPageCompactMode } = createAtomWithHook(false, "IsMainPageCompactMode");
|
||||
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
|
||||
// Common
|
||||
export const { atomInstance: Atom_SoftwareVersion, useHook: useStore_SoftwareVersion } = createAtomWithHook("-", "SoftwareVersion");
|
||||
export const { atomInstance: Atom_SelectedConfigTabId, useHook: useStore_SelectedConfigTabId } = createAtomWithHook("device", "SelectedConfigTabId");
|
||||
|
||||
// Designs
|
||||
export const { atomInstance: Atom_IsOpenedDropdownMenu, useHook: useStore_IsOpenedDropdownMenu } = createAtomWithHook("", "IsOpenedDropdownMenu");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user