[Update] Main Page: Message input box. Add function, auto clear message box.
This commit is contained in:
@@ -29,6 +29,8 @@ const StartPythonFacadeComponent = () => {
|
|||||||
// getMicDeviceList,
|
// getMicDeviceList,
|
||||||
getSelectedMicDevice,
|
getSelectedMicDevice,
|
||||||
getSelectedSpeakerDevice,
|
getSelectedSpeakerDevice,
|
||||||
|
|
||||||
|
getEnableAutoClearMessageBox,
|
||||||
} = useConfig();
|
} = useConfig();
|
||||||
|
|
||||||
|
|
||||||
@@ -42,6 +44,8 @@ const StartPythonFacadeComponent = () => {
|
|||||||
// getMicDeviceList();
|
// getMicDeviceList();
|
||||||
getSelectedMicDevice();
|
getSelectedMicDevice();
|
||||||
getSelectedSpeakerDevice();
|
getSelectedSpeakerDevice();
|
||||||
|
|
||||||
|
getEnableAutoClearMessageBox();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useState } from "react";
|
|||||||
import styles from "./MessageInputBox.module.scss";
|
import styles from "./MessageInputBox.module.scss";
|
||||||
import SendMessageSvg from "@images/send_message.svg?react";
|
import SendMessageSvg from "@images/send_message.svg?react";
|
||||||
import { useMessage } from "@logics/useMessage";
|
import { useMessage } from "@logics/useMessage";
|
||||||
import { store } from "@store";
|
import { store, useEnableAutoClearMessageBox } from "@store";
|
||||||
import { scrollToBottom } from "@logics/scrollToBottom";
|
import { scrollToBottom } from "@logics/scrollToBottom";
|
||||||
|
|
||||||
|
|
||||||
@@ -10,10 +10,14 @@ export const MessageInputBox = () => {
|
|||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
const { sendMessage } = useMessage();
|
const { sendMessage } = useMessage();
|
||||||
|
|
||||||
|
const { currentEnableAutoClearMessageBox } = useEnableAutoClearMessageBox();
|
||||||
|
|
||||||
const onSubmitFunction = (e) => {
|
const onSubmitFunction = (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
sendMessage(inputValue);
|
sendMessage(inputValue);
|
||||||
|
|
||||||
|
if (currentEnableAutoClearMessageBox.data) setInputValue("");
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
scrollToBottom(store.log_box_ref);
|
scrollToBottom(store.log_box_ref);
|
||||||
}, 10);
|
}, 10);
|
||||||
@@ -31,6 +35,7 @@ export const MessageInputBox = () => {
|
|||||||
className={styles.message_box_input_area}
|
className={styles.message_box_input_area}
|
||||||
onChange={onChangeFunction}
|
onChange={onChangeFunction}
|
||||||
placeholder="Input Textfield"
|
placeholder="Input Textfield"
|
||||||
|
value={inputValue}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ export const useConfig = () => {
|
|||||||
|
|
||||||
|
|
||||||
// Others
|
// Others
|
||||||
|
getEnableAutoClearMessageBox: () => {
|
||||||
|
updateEnableAutoClearMessageBox(asyncPending);
|
||||||
|
asyncStdoutToPython("/config/enable_auto_clear_message_box");
|
||||||
|
},
|
||||||
toggleEnableAutoClearMessageBox: () => {
|
toggleEnableAutoClearMessageBox: () => {
|
||||||
updateEnableAutoClearMessageBox(asyncPending);
|
updateEnableAutoClearMessageBox(asyncPending);
|
||||||
if (currentEnableAutoClearMessageBox.data) {
|
if (currentEnableAutoClearMessageBox.data) {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ export const useReceiveRoutes = () => {
|
|||||||
"/action/check_mic_threshold_energy": updateVolumeVariable_Mic,
|
"/action/check_mic_threshold_energy": updateVolumeVariable_Mic,
|
||||||
"/action/check_speaker_threshold_energy": updateVolumeVariable_Speaker,
|
"/action/check_speaker_threshold_energy": updateVolumeVariable_Speaker,
|
||||||
|
|
||||||
|
"/config/enable_auto_clear_message_box": updateEnableAutoClearMessageBox,
|
||||||
"/controller/callback_enable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
"/controller/callback_enable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
||||||
"/controller/callback_disable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
"/controller/callback_disable_auto_clear_chatbox": updateEnableAutoClearMessageBox,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user