Mercurial Hosting > chat
comparison src/lib/Shared.luan @ 59:8270106644db
add chat.luan
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 04 Mar 2025 08:22:45 -0700 |
| parents | 9298b04607ae |
| children | e229f4aacde0 |
comparison
equal
deleted
inserted
replaced
| 58:7b6691bd65c3 | 59:8270106644db |
|---|---|
| 5 local Io = require "luan:Io.luan" | 5 local Io = require "luan:Io.luan" |
| 6 local uri = Io.uri or error() | 6 local uri = Io.uri or error() |
| 7 local Time = require "luan:Time.luan" | 7 local Time = require "luan:Time.luan" |
| 8 local Thread = require "luan:Thread.luan" | 8 local Thread = require "luan:Thread.luan" |
| 9 local thread_run = Thread.run or error() | 9 local thread_run = Thread.run or error() |
| 10 local Parsers = require "luan:Parsers.luan" | |
| 11 local json_string = Parsers.json_string or error() | |
| 12 local Html = require "luan:Html.luan" | 10 local Html = require "luan:Html.luan" |
| 13 local html_encode = Html.encode or error() | 11 local html_encode = Html.encode or error() |
| 14 local Http = require "luan:http/Http.luan" | 12 local Http = require "luan:http/Http.luan" |
| 15 local Mail = require "luan:mail/Mail.luan" | 13 local Mail = require "luan:mail/Mail.luan" |
| 16 local User = require "site:/lib/User.luan" | 14 local User = require "site:/lib/User.luan" |
| 143 | 141 |
| 144 function Shared.chats_html() | 142 function Shared.chats_html() |
| 145 local user = current_user() or error() | 143 local user = current_user() or error() |
| 146 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" ) |
| 147 for _, chat in ipairs(chats) do | 145 for _, chat in ipairs(chats) do |
| 146 local chat_id = chat.id | |
| 148 local user_id = chat.other_user_id(user.id) | 147 local user_id = chat.other_user_id(user.id) |
| 149 local other_user = get_user_by_id(user_id) or error() | 148 local other_user = get_user_by_id(user_id) or error() |
| 150 local unread = chat.unread(user) | 149 local unread = chat.unread(user) |
| 151 %> | 150 %> |
| 152 <div chat="<%=chat.id%>" onclick='selectChat(this,<%=json_string(other_user.email)%>)'> | 151 <div chat="<%=chat_id%>" onclick="selectChat('<%=chat_id%>')"> |
| 153 <%= other_user.name_html() %> | 152 <%= other_user.name_html() %> |
| 154 <span online="<%= other_user.id %>"></span> | 153 <span online="<%= other_user.id %>"></span> |
| 155 <span unread="<%=unread%>"><%=unread%></span> | 154 <span unread="<%=unread%>"><%=unread%></span> |
| 156 </div> | 155 </div> |
| 157 <% | 156 <% |
