Mercurial Hosting > chat
changeset 92:c41e200c3e76
try to fix lost posts
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 31 Mar 2025 15:43:14 -0600 |
parents | 9196d936d4fa |
children | d0566cc4a2ac |
files | src/add_post.js.luan src/chat.js src/heartbeat.js.luan |
diffstat | 3 files changed, 6 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/add_post.js.luan Sun Mar 16 20:32:10 2025 -0600 +++ b/src/add_post.js.luan Mon Mar 31 15:43:14 2025 -0600 @@ -48,7 +48,7 @@ end ) Notify.add(chat) local html = `post_html(post)` - local js = "added("..json_string(html)..")" + local js = "added("..json_string(html)..","..now..")" chat.http_push(js) js = "getChats('"..chat.id.."',"..now..")" http_push_to_users( chat.user_ids, js )
--- a/src/chat.js Sun Mar 16 20:32:10 2025 -0600 +++ b/src/chat.js Mon Mar 31 15:43:14 2025 -0600 @@ -178,13 +178,14 @@ ajax(url); } -function added(html) { +function added(html,updated) { let input = document.querySelector('div[input]'); input.insertAdjacentHTML('beforebegin',html); fixPosts(); input.scrollIntoView({block: 'end'}); if( document.hasFocus() ) active(); + lastUpdate = updated; } function getChats(chatId,updated) { @@ -192,11 +193,11 @@ if( !first || first.getAttribute('chat') !== chatId ) { // console.log('getChats'); ajax('get_chats.js'); + if( updated ) + lastUpdate = updated; } else if( first && (currentChatId !== chatId || spy) ) { incUnread(first); } - if( updated ) - lastUpdate = updated; if( !document.hasFocus() ) { document.title = title + ' *'; }
--- a/src/heartbeat.js.luan Sun Mar 16 20:32:10 2025 -0600 +++ b/src/heartbeat.js.luan Mon Mar 31 15:43:14 2025 -0600 @@ -34,7 +34,7 @@ local last_update = Http.request.parameters.last_update or error() last_update = to_number(last_update) or error(last_update) local user_last_update = user.last_update() - if time_now() - user_last_update > 70000 and last_update < user_last_update then + if time_now() - user_last_update > 10000 and last_update < user_last_update then logger.info "update" %> location = '/';