mirror of
https://github.com/geoffsee/open-gsio.git
synced 2025-09-08 22:56:46 +00:00
Add unit tests for MessageEditorComponent, update message editing logic, and refactor ChatService model handling.
- Added comprehensive tests for `MessageEditorComponent`. - Improved message editing functionality and added client store interactions. - Refactored handling of `getSupportedModels` in `ChatService`. - Updated PWA configuration and added a Safari-specific instruction. - Adjusted `.dev.vars` file to reflect local development updates.
This commit is contained in:

committed by
Geoff Seemueller

parent
5f913eb2d7
commit
ce07b69fbe
@@ -2,21 +2,31 @@ import React, { KeyboardEvent, useState } from "react";
|
||||
import { Box, Flex, IconButton, Textarea } from "@chakra-ui/react";
|
||||
import { Check, X } from "lucide-react";
|
||||
import { observer } from "mobx-react-lite";
|
||||
import store, { type IMessage } from "../../../stores/ClientChatStore";
|
||||
import { Instance } from "mobx-state-tree";
|
||||
import Message from "../../../models/Message";
|
||||
import clientChatStore from "../../../stores/ClientChatStore";
|
||||
|
||||
interface MessageEditorProps {
|
||||
message: IMessage;
|
||||
message: Instance<typeof Message>;
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
const MessageEditor = observer(({ message, onCancel }: MessageEditorProps) => {
|
||||
const [editedContent, setEditedContent] = useState(message.content);
|
||||
|
||||
const handleSave = () => {
|
||||
const messageIndex = store.messages.indexOf(message);
|
||||
const handleSave = async () => {
|
||||
message.setContent(editedContent);
|
||||
|
||||
// Find the index of the edited message
|
||||
const messageIndex = clientChatStore.items.indexOf(message);
|
||||
if (messageIndex !== -1) {
|
||||
store.editMessage(messageIndex, editedContent);
|
||||
// Remove all messages after the edited message
|
||||
clientChatStore.removeAfter(messageIndex);
|
||||
|
||||
// Send the message
|
||||
clientChatStore.sendMessage();
|
||||
}
|
||||
|
||||
onCancel();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user