diff src/lib/Shared.luan @ 33:e2b7f6393dab

add online
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 10 Nov 2024 19:57:14 -0700
parents af41be2dcdec
children 62d04ca486dd
line wrap: on
line diff
--- a/src/lib/Shared.luan	Sat Nov 09 21:41:11 2024 -0700
+++ b/src/lib/Shared.luan	Sun Nov 10 19:57:14 2024 -0700
@@ -117,12 +117,29 @@
 <%
 end
 
+local function chat_other_users_html(chat,user)
+	local my_id = user.id
+	local is_first = true
+	for _, user_id in ipairs(chat.user_ids) do
+		if user_id ~= my_id then
+			local other_user = get_user_by_id(user_id) or error()
+			if is_first then
+				is_first = false
+			else
+				%>, <%
+			end
+			%><%= other_user.email %><span online="<%= other_user.id %>"></span><%
+		end
+	end
+end
+Shared.chat_other_users_html = chat_other_users_html
+
 function Shared.chats_html()
 	local user = current_user() or error()
 	local chats = chat_search( "chat_user_ids:"..user.id, "chat_updated desc" )
 	for _, chat in ipairs(chats) do
 %>
-		<div chat="<%=chat.id%>" onclick="selectChat(this)"><%= chat.other_users_email(user) %></div>
+		<div chat="<%=chat.id%>" onclick="selectChat(this)"><% chat_other_users_html(chat,user) %></div>
 <%
 	end
 end