Mercurial Hosting > chat
comparison src/chat.js @ 42:e09747b199e9
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 27 Feb 2025 19:30:54 -0700 |
parents | 7ea33179592a |
children | 42b741a1d5c6 |
comparison
equal
deleted
inserted
replaced
41:818697418dbe | 42:e09747b199e9 |
---|---|
216 }; | 216 }; |
217 pulldown.scrollIntoViewIfNeeded(false); | 217 pulldown.scrollIntoViewIfNeeded(false); |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 setInterval(function(){ | 221 function heartbeat() { |
222 showOnline(); | 222 showOnline(); |
223 ajax(`heartbeat.js?last_update=${lastUpdate}`); | 223 ajax(`heartbeat.js?last_update=${lastUpdate}`); |
224 }, 10000 ); | 224 } |
225 | |
226 setInterval( heartbeat, 10000 ); | |
225 | 227 |
226 let online = {}; | 228 let online = {}; |
227 | 229 |
228 function setOnline(userId) { | 230 function setOnline(userId) { |
229 online[userId] = Date.now(); | 231 online[userId] = Date.now(); |
230 } | 232 } |
231 | 233 |
232 function showOnline() { | 234 function showOnline() { |
233 let old = Date.now() - 20000; | 235 let old = Date.now() - 70000; |
234 for( let id of Object.keys(online) ) { | 236 for( let id of Object.keys(online) ) { |
235 if( online[id] < old ) | 237 if( online[id] < old ) |
236 delete online[id]; | 238 delete online[id]; |
237 } | 239 } |
238 let a = []; | 240 let a = []; |