Handle cases with missing id in messages, improve index lookup logic, and refactor save handler.

This commit is contained in:
geoffsee
2025-05-31 18:22:42 -04:00
committed by Geoff Seemueller
parent 580f361457
commit 3cf7ceb868
3 changed files with 10 additions and 4 deletions

View File

@@ -25,12 +25,17 @@ const MessageEditor = observer(({ message, onCancel }: MessageEditorProps) => {
onCancel();
};
const handleSave = async () => {
await messageEditorStore.handleSave();
onCancel();
};
const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
messageEditorStore.handleSave();
handleSave();
}
if (e.key === "Escape") {
@@ -66,7 +71,7 @@ const MessageEditor = observer(({ message, onCancel }: MessageEditorProps) => {
<IconButton
aria-label="Save edit"
icon={<Check />}
onClick={() => messageEditorStore.handleSave()}
onClick={handleSave}
size="sm"
variant="ghost"
color={"accent.confirm"}