Mercurial Hosting > chat
changeset 8:d654e3471132
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 30 Oct 2024 00:08:59 -0600 |
parents | 41d35b72c774 |
children | b8b12fd8be22 |
files | src/chat.html.luan |
diffstat | 1 files changed, 15 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/chat.html.luan Tue Oct 29 22:11:40 2024 -0600 +++ b/src/chat.html.luan Wed Oct 30 00:08:59 2024 -0600 @@ -20,6 +20,8 @@ local run_in_transaction = Db.run_in_transaction or error() local Chat = require "site:/lib/Chat.luan" local chat_search = Chat.search or error() +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "chat.html" local function get_chat(with) @@ -32,7 +34,7 @@ ids[#ids+1] = id end local query = concat(t," ") - run_in_transaction( function() + return run_in_transaction( function() local chats = chat_search(query) local n = #chats if n == 0 then @@ -65,10 +67,11 @@ Http.response.send_redirect(url) return end + local selected = nil if not is_empty(with) then with[user.email] = true if size(with) > 1 then - get_chat(with) + selected = get_chat(with) end end local chats = user.get_chats() @@ -143,6 +146,16 @@ <div posts></div> </div> </body> +<% + if selected ~= nil then +%> + <script> + let div = document.querySelector('div[chat="<%=selected.id%>"]'); + selectChat(div); + </script> +<% + end +%> </html> <% end