Mercurial Hosting > chat
comparison src/lib/Shared.luan @ 41:818697418dbe
add voice link
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 27 Feb 2025 19:05:57 -0700 |
| parents | 7ea33179592a |
| children | e138343b2c76 |
comparison
equal
deleted
inserted
replaced
| 40:7ea33179592a | 41:818697418dbe |
|---|---|
| 44 <a href="/">Web Chat</a> | 44 <a href="/">Web Chat</a> |
| 45 <% for _, crumb in ipairs(crumbs or {}) do %> | 45 <% for _, crumb in ipairs(crumbs or {}) do %> |
| 46 / <%=crumb%> | 46 / <%=crumb%> |
| 47 <% end %> | 47 <% end %> |
| 48 </span> | 48 </span> |
| 49 <span> | 49 <span right> |
| 50 <% if user == nil then %> | 50 <% if user == nil then %> |
| 51 <a href="/login.html">Login / Register</a> | 51 <a href="/login.html">Login / Register</a> |
| 52 <% else %> | 52 <% else |
| 53 local voice_url = user.voice_url | |
| 54 if voice_url ~= nil then | |
| 55 %> | |
| 56 <a href="<%=voice_url%>" title="Call" target="voice"><img phone src="/images/call.svg"></a> | |
| 57 <% | |
| 58 end | |
| 59 %> | |
| 53 <a href="/account.html"><%= user.email %></a> | 60 <a href="/account.html"><%= user.email %></a> |
| 54 <% end %> | 61 <% end %> |
| 55 </span> | 62 </span> |
| 56 </div> | 63 </div> |
| 57 <% | 64 <% |
| 109 <div text><%= html_encode(post.content) %></div> | 116 <div text><%= html_encode(post.content) %></div> |
| 110 </div> | 117 </div> |
| 111 <% | 118 <% |
| 112 end | 119 end |
| 113 | 120 |
| 114 local function chat_other_users_html(chat,user) | 121 local function chat_other_users_html(chat,user,show_phone) |
| 115 local my_id = user.id | 122 local my_id = user.id |
| 116 local is_first = true | 123 local is_first = true |
| 117 for _, user_id in ipairs(chat.user_ids) do | 124 for _, user_id in ipairs(chat.user_ids) do |
| 118 if user_id ~= my_id then | 125 if user_id ~= my_id then |
| 119 local other_user = get_user_by_id(user_id) or error() | 126 local other_user = get_user_by_id(user_id) or error() |
| 121 is_first = false | 128 is_first = false |
| 122 else | 129 else |
| 123 %>, <% | 130 %>, <% |
| 124 end | 131 end |
| 125 %><span email><%= other_user.email %></span><span online="<%= other_user.id %>"></span><% | 132 %><span email><%= other_user.email %></span><span online="<%= other_user.id %>"></span><% |
| 133 local voice_url = other_user.voice_url | |
| 134 if voice_url ~= nil and show_phone then | |
| 135 %> <a href="<%=voice_url%>" title="Call" target="voice"><img phone src="/images/call.svg"></a><% | |
| 136 end | |
| 126 end | 137 end |
| 127 end | 138 end |
| 128 end | 139 end |
| 129 Shared.chat_other_users_html = chat_other_users_html | 140 Shared.chat_other_users_html = chat_other_users_html |
| 130 | 141 |
| 131 function Shared.chats_html() | 142 function Shared.chats_html() |
| 132 local user = current_user() or error() | 143 local user = current_user() or error() |
| 133 local chats = chat_search( "chat_user_ids:"..user.id, "chat_updated desc" ) | 144 local chats = chat_search( "chat_user_ids:"..user.id, "chat_updated desc" ) |
| 134 for _, chat in ipairs(chats) do | 145 for _, chat in ipairs(chats) do |
| 135 %> | 146 %> |
| 136 <div chat="<%=chat.id%>" onclick="selectChat(this)"><% chat_other_users_html(chat,user) %></div> | 147 <div chat="<%=chat.id%>" onclick="selectChat(this)"><% chat_other_users_html(chat,user,false) %></div> |
| 137 <% | 148 <% |
| 138 end | 149 end |
| 139 end | 150 end |
| 140 | 151 |
| 141 function Shared.http_push_to_users(user_ids,message) | 152 function Shared.http_push_to_users(user_ids,message) |
