Added dynamic component rendering attached to message with the

@app: command
This commit is contained in:
Samuel Andert
2023-07-22 16:08:00 +02:00
parent 379a163fce
commit 0053515286
4 changed files with 66 additions and 22 deletions

View File

@ -28,8 +28,10 @@ export interface Message {
timestamp: string;
sender: string;
type: string;
composite?: object | null; // New field
}
// Load messages from localStorage or set an empty array if not available
const initialMessages = getFromLocalStorage('chat-messages', []);
@ -48,11 +50,11 @@ export function createMessage(messageData) {
text: messageData.text,
timestamp: currentDate,
sender: messageData.sender,
type: messageData.type
type: messageData.type,
composite: messageData.composite || null // New field
};
messages.update(oldMessages => [...oldMessages, newMessageObj]);
}
export function clearMessages() {
messages.set([]);
}