commit 553c585fc9702737e4a4eebd02630f4de0147ab7
parent 7f6d080dba2dba4a5c219b15720cdd5e9d451036
Author: MTRNord <mtrnord1@gmail.com>
Date: Mon, 8 May 2023 01:58:24 +0200
Make sure to also clear the editor history if we clear the editor itself
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/components/input/chat/input.tsx b/src/components/input/chat/input.tsx
@@ -28,7 +28,7 @@ import { FC, memo, useEffect, useState } from 'react';
import { Send } from 'lucide-react';
import { useRoom } from '../../../app/sdk/client';
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
-import { CLEAR_EDITOR_COMMAND, ParagraphNode } from 'lexical';
+import { CLEAR_EDITOR_COMMAND, CLEAR_HISTORY_COMMAND, ParagraphNode } from 'lexical';
import { useLocation } from 'react-router-dom';
type ChatInputProps = {
@@ -90,6 +90,7 @@ const SendButton: FC<SendButtonProps> = memo(({ roomID, htmlMessage, plainMessag
try {
await room.sendHtmlMessage(htmlMessage, plainMessage);
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
+ editor.dispatchCommand(CLEAR_HISTORY_COMMAND, undefined);
localStorage.removeItem(`editor-${roomID}`);
} catch (e: any) {
console.log(e);
@@ -98,6 +99,7 @@ const SendButton: FC<SendButtonProps> = memo(({ roomID, htmlMessage, plainMessag
try {
await room.sendTextMessage(plainMessage);
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
+ editor.dispatchCommand(CLEAR_HISTORY_COMMAND, undefined);
localStorage.removeItem(`editor-${roomID}`);
} catch (e: any) {
console.log(e);
@@ -135,6 +137,7 @@ const RoomChangePlugin: FC<RoomChangeProps> = ({ roomID }) => {
editor.setEditorState(initialEditorState)
} else {
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
+ editor.dispatchCommand(CLEAR_HISTORY_COMMAND, undefined);
}
}
}, [pathname, roomID]);