history changes

This commit is contained in:
Patrick_Pluto 2024-10-02 14:01:16 +02:00
parent 4f024464e5
commit 6a5c069820

View file

@ -1,22 +1,22 @@
type ChatMessage = {
name: string;
message: any;
messages: any;
timestamp: number;
};
let chatHistory: ChatMessage[] = [];
function addMessage(name: string, message: any): void {
function addMessageHistory(name: string, message: any): void {
const newMessage: ChatMessage = {
name: name,
message: message,
messages: message,
timestamp: Date.now()
};
chatHistory.push(newMessage);
console.log(`Added message from ${name}: ${message}`);
}
function removeMessage(timestamp: number): void {
function removeMessageHistory(timestamp: number): void {
const index = chatHistory.findIndex((msg) => msg.timestamp === timestamp);
if (index > -1) {
chatHistory.splice(index, 1);