Mercurial Hosting > chat
diff src/chat.html.luan @ 15:8b8905f63d80
add get_chats
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 03 Nov 2024 17:36:49 -0700 |
parents | f9e6a4cc4f7d |
children | 7230c821c368 |
line wrap: on
line diff
--- a/src/chat.html.luan Fri Nov 01 11:22:01 2024 -0600 +++ b/src/chat.html.luan Sun Nov 03 17:36:49 2024 -0700 @@ -13,6 +13,7 @@ local head = Shared.head or error() local header = Shared.header or error() local started = Shared.started or error() +local chats_html = Shared.chats_html or error() local User = require "site:/lib/User.luan" local current_user = User.current or error() local get_user_by_email = User.get_by_email or error() @@ -76,7 +77,6 @@ selected = get_chat(with) end end - local chats = Chat.search( "chat_user_ids:"..user.id, "chat_updated desc" ) Io.stdout = Http.response.text_writer() %> <!doctype html> @@ -92,27 +92,22 @@ <% header() %> <div content> <div chats> -<% - for _, chat in ipairs(chats) do -%> - <div chat="<%=chat.id%>" onclick="selectChat(this)"><%= chat.other_users_email(user) %></div> -<% - end -%> +<% chats_html() %> </div> <div posts></div> </div> - </body> + <script> <% if selected ~= nil then %> - <script> let div = document.querySelector('div[chat="<%=selected.id%>"]'); selectChat(div); - </script> <% end %> + setUserEventSource(<%=user.id%>); + </script> + </body> </html> <% end