history changes
This commit is contained in:
parent
4f024464e5
commit
6a5c069820
1 changed files with 4 additions and 4 deletions
|
@ -1,22 +1,22 @@
|
||||||
type ChatMessage = {
|
type ChatMessage = {
|
||||||
name: string;
|
name: string;
|
||||||
message: any;
|
messages: any;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
let chatHistory: ChatMessage[] = [];
|
let chatHistory: ChatMessage[] = [];
|
||||||
|
|
||||||
function addMessage(name: string, message: any): void {
|
function addMessageHistory(name: string, message: any): void {
|
||||||
const newMessage: ChatMessage = {
|
const newMessage: ChatMessage = {
|
||||||
name: name,
|
name: name,
|
||||||
message: message,
|
messages: message,
|
||||||
timestamp: Date.now()
|
timestamp: Date.now()
|
||||||
};
|
};
|
||||||
chatHistory.push(newMessage);
|
chatHistory.push(newMessage);
|
||||||
console.log(`Added message from ${name}: ${message}`);
|
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);
|
const index = chatHistory.findIndex((msg) => msg.timestamp === timestamp);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
chatHistory.splice(index, 1);
|
chatHistory.splice(index, 1);
|
||||||
|
|
Loading…
Reference in a new issue