forked from React-Group/interstellar_ai
		
	Compare commits
	
		
			2 commits
		
	
	
		
			b12eb25d78
			...
			aba9817490
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| aba9817490 | |||
| 
							 | 
						63971d66fc | 
					 1 changed files with 27 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								app/backend/ChatHistory.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								app/backend/ChatHistory.ts
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
type ChatMessage = {
 | 
			
		||||
    name: string;
 | 
			
		||||
    message: any;
 | 
			
		||||
    timestamp: number;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
let chatHistory: ChatMessage[] = [];
 | 
			
		||||
 | 
			
		||||
function addMessage(name: string, message: any): void {
 | 
			
		||||
    const newMessage: ChatMessage = {
 | 
			
		||||
        name: name,
 | 
			
		||||
        message: message,
 | 
			
		||||
        timestamp: Date.now()
 | 
			
		||||
    };
 | 
			
		||||
    chatHistory.push(newMessage);
 | 
			
		||||
    console.log(`Added message from ${name}: ${message}`);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function removeMessage(timestamp: number): void {
 | 
			
		||||
    const index = chatHistory.findIndex((msg) => msg.timestamp === timestamp);
 | 
			
		||||
    if (index > -1) {
 | 
			
		||||
        chatHistory.splice(index, 1);
 | 
			
		||||
        console.log(`Removed message with timestamp: ${timestamp}`);
 | 
			
		||||
    } else {
 | 
			
		||||
        console.log(`Message not found with timestamp: ${timestamp}`);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue