comparison src/get_chat.js.luan @ 83:a47036fd0158

group chat
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 11 Mar 2025 13:56:59 -0600
parents b5a316575e64
children 3053a4fc10be
comparison
equal deleted inserted replaced
82:0bc5e0d098f7 83:a47036fd0158
16 local get_chat_by_id = Chat.get_by_id or error() 16 local get_chat_by_id = Chat.get_by_id or error()
17 local Post = require "site:/lib/Post.luan" 17 local Post = require "site:/lib/Post.luan"
18 local post_search = Post.search or error() 18 local post_search = Post.search or error()
19 local Shared = require "site:/lib/Shared.luan" 19 local Shared = require "site:/lib/Shared.luan"
20 local post_html = Shared.post_html or error() 20 local post_html = Shared.post_html or error()
21 local group_name = Shared.group_name or error()
21 local Logging = require "luan:logging/Logging.luan" 22 local Logging = require "luan:logging/Logging.luan"
22 local logger = Logging.logger "get_chat.js" 23 local logger = Logging.logger "get_chat.js"
23 24
24 25
25 local function get_html(user,chat) 26 local function get_html(user,chat)
27 local posts = post_search( "post_chat_id:"..chat.id, "id" ) 28 local posts = post_search( "post_chat_id:"..chat.id, "id" )
28 %> 29 %>
29 <div top> 30 <div top>
30 <h3> 31 <h3>
31 <img back onclick="back()" src="/images/arrow_back.svg"> 32 <img back onclick="back()" src="/images/arrow_back.svg">
32 <span><% 33 <span>
33 local user_id = chat.other_user_id(user.id) 34 <%
34 local other_user = get_user_by_id(user_id) or error(user_id) 35 local user_ids = chat.other_user_ids(user.id)
35 %><%= other_user.name_html() %><span online="<%= other_user.id %>"></span><% 36 if #user_ids > 1 then
36 local voice_url = other_user.voice_url 37 %>
37 if voice_url ~= nil then 38 <%= group_name(user_ids) %>
38 %> <a href="<%=voice_url%>" title="Call" target="voice"><img phone src="/images/call.svg"></a><% 39 <%
39 end 40 else
40 %></span> 41 local other_user = get_user_by_id(user_ids[1]) or error()
42 %>
43 <%= other_user.name_html() %><span online="<%= other_user.id %>"></span>
44 <%
45 local voice_url = other_user.voice_url
46 if voice_url ~= nil then
47 %>
48 <a href="<%=voice_url%>" title="Call" target="voice"><img phone src="/images/call.svg"></a>
49 <%
50 end
51 end
52 %>
53 </span>
41 </h3> 54 </h3>
42 <span pulldown> 55 <span pulldown>
43 <img onclick="clickMenu(this)" src="/images/menu.svg"> 56 <img onclick="clickMenu(this)" src="/images/menu.svg">
44 <div> 57 <div>
45 <span onclick="openPeople()">People in Chat</span> 58 <span onclick="openPeople()">People in Chat</span>
59 <span onclick="openAddToChat()">Add Someone to Chat</span>
46 <span onclick="deleteChat()">Delete Chat</span> 60 <span onclick="deleteChat()">Delete Chat</span>
47 </div> 61 </div>
48 </span> 62 </span>
49 </div> 63 </div>
50 <div main> 64 <div main>