[bugfix] Hotfix: Fix slowed message sending.(too much sent '/run/typing_message_box'). set 2 secs cool time.
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import {
|
||||
useStore_MessageLogs,
|
||||
useStore_MessageInputValue,
|
||||
store,
|
||||
} from "@store";
|
||||
|
||||
import { useStdoutToPython } from "@useStdoutToPython";
|
||||
|
||||
const COOLDOWN = 2000; // 2 seconds
|
||||
|
||||
export const useMessage = () => {
|
||||
const { currentMessageLogs, addMessageLogs, updateMessageLogs } = useStore_MessageLogs();
|
||||
const { currentMessageInputValue, updateMessageInputValue } = useStore_MessageInputValue();
|
||||
@@ -65,7 +68,11 @@ export const useMessage = () => {
|
||||
};
|
||||
|
||||
const startTyping = () => {
|
||||
asyncStdoutToPython("/run/typing_message_box");
|
||||
const now = Date.now();
|
||||
if (now - store.last_executed_time_startTyping >= 2000) {
|
||||
store.last_executed_time_startTyping = now;
|
||||
asyncStdoutToPython("/run/typing_message_box");
|
||||
}
|
||||
};
|
||||
|
||||
const stopTyping = () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ export const store = {
|
||||
is_initialized_load_plugin: false,
|
||||
is_fetched_plugins_info_already: false,
|
||||
is_initialized_fetched_plugin_info: false,
|
||||
last_executed_time_startTyping: 0,
|
||||
};
|
||||
|
||||
const generatePropertyNames = (base_name) => ({
|
||||
|
||||
Reference in New Issue
Block a user