diff src/chat.js @ 59:8270106644db

add chat.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 04 Mar 2025 08:22:45 -0700
parents 323ddacc1593
children 3521166513b3
line wrap: on
line diff
--- a/src/chat.js	Tue Mar 04 07:38:43 2025 -0700
+++ b/src/chat.js	Tue Mar 04 08:22:45 2025 -0700
@@ -16,17 +16,17 @@
 	userEventSource.onmessage = evalEvent;
 }
 
-function selectChat(div,email) {
+function selectChat(chatId) {
 	document.querySelector('div[chat_content]').setAttribute('show','posts');
-	let chatId = div.getAttribute('chat');
 	if( chatId === currentChatId )
 		return;
+	let div = document.querySelector(`div[chat="${chatId}"]`);
 	let selected = div.parentNode.querySelector('[selected]');
 	if( selected )  selected.removeAttribute('selected');
 	div.setAttribute('selected','');
 	ajax(`get_chat.js?chat=${chatId}`);
 	currentChatId = chatId;
-	history.replaceState(null,null,`?with=${email}`);
+	history.replaceState(null,null,`?chat=${chatId}`);
 	clearUnread();
 
 	if(eventSource)  eventSource.close();