Mercurial Hosting > chat
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 32:0f40501b0b56 | 33:e2b7f6393dab |
|---|---|
| 115 <div text fix><%= html_encode(post.content) %></div> | 115 <div text fix><%= html_encode(post.content) %></div> |
| 116 </div> | 116 </div> |
| 117 <% | 117 <% |
| 118 end | 118 end |
| 119 | 119 |
| 120 local function chat_other_users_html(chat,user) | |
| 121 local my_id = user.id | |
| 122 local is_first = true | |
| 123 for _, user_id in ipairs(chat.user_ids) do | |
| 124 if user_id ~= my_id then | |
| 125 local other_user = get_user_by_id(user_id) or error() | |
| 126 if is_first then | |
| 127 is_first = false | |
| 128 else | |
| 129 %>, <% | |
| 130 end | |
| 131 %><%= other_user.email %><span online="<%= other_user.id %>"></span><% | |
| 132 end | |
| 133 end | |
| 134 end | |
| 135 Shared.chat_other_users_html = chat_other_users_html | |
| 136 | |
| 120 function Shared.chats_html() | 137 function Shared.chats_html() |
| 121 local user = current_user() or error() | 138 local user = current_user() or error() |
| 122 local chats = chat_search( "chat_user_ids:"..user.id, "chat_updated desc" ) | 139 local chats = chat_search( "chat_user_ids:"..user.id, "chat_updated desc" ) |
| 123 for _, chat in ipairs(chats) do | 140 for _, chat in ipairs(chats) do |
| 124 %> | 141 %> |
| 125 <div chat="<%=chat.id%>" onclick="selectChat(this)"><%= chat.other_users_email(user) %></div> | 142 <div chat="<%=chat.id%>" onclick="selectChat(this)"><% chat_other_users_html(chat,user) %></div> |
| 126 <% | 143 <% |
| 127 end | 144 end |
| 128 end | 145 end |
| 129 | 146 |
| 130 function Shared.http_push_to_users(user_ids,message) | 147 function Shared.http_push_to_users(user_ids,message) |
