order users online list by time of join instead of it getting ordered automatically during websocket transit by id
parent
39f7283f53
commit
7e1de2bd59
|
@ -188,7 +188,7 @@ ta.addEventListener("keydown", function(e) {
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on('online', function(data){
|
socket.on('online', function(data){
|
||||||
const online_li = Object.entries(data[0])
|
const online_li = data[0]
|
||||||
const muted_li = Object.keys(data[1])
|
const muted_li = Object.keys(data[1])
|
||||||
|
|
||||||
document.getElementsByClassName('board-chat-count')[0].innerHTML = online_li.length
|
document.getElementsByClassName('board-chat-count')[0].innerHTML = online_li.length
|
||||||
|
@ -196,17 +196,17 @@ socket.on('online', function(data){
|
||||||
const admin_level = parseInt(document.getElementById('admin_level').value)
|
const admin_level = parseInt(document.getElementById('admin_level').value)
|
||||||
let online = ''
|
let online = ''
|
||||||
let online2 = '<b>Users Online</b>'
|
let online2 = '<b>Users Online</b>'
|
||||||
for (const [k, val] of online_li)
|
for (const u of online_li)
|
||||||
{
|
{
|
||||||
let patron = ''
|
let patron = ''
|
||||||
if (val[3])
|
if (u[3])
|
||||||
patron = ` class="patron" style="background-color:#${val[2]}"`
|
patron = ` class="patron" style="background-color:#${u[2]}"`
|
||||||
|
|
||||||
online += `<li>`
|
online += `<li>`
|
||||||
if (admin_level && muted_li.includes(val[1].toLowerCase()))
|
if (admin_level && muted_li.includes(u[1].toLowerCase()))
|
||||||
online += '<b class="text-danger muted" data-bs-toggle="tooltip" title="Muted">X</b> '
|
online += '<b class="text-danger muted" data-bs-toggle="tooltip" title="Muted">X</b> '
|
||||||
online += `<a class="font-weight-bold" target="_blank" href="/@${val[1]}" style="color:#${val[2]}"><img loading="lazy" class="mr-1" src="/pp/${k}"><span${patron}>${val[1]}</span></a></li>`
|
online += `<a class="font-weight-bold" target="_blank" href="/@${u[1]}" style="color:#${u[2]}"><img loading="lazy" class="mr-1" src="/pp/${u[4]}"><span${patron}>${u[1]}</span></a></li>`
|
||||||
online2 += `<br>@${val[1]}`
|
online2 += `<br>@${u[1]}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const online_el = document.getElementById('online')
|
const online_el = document.getElementById('online')
|
||||||
|
|
|
@ -139,14 +139,14 @@ def speak(data, v):
|
||||||
self_only = True
|
self_only = True
|
||||||
else:
|
else:
|
||||||
del muted[vname]
|
del muted[vname]
|
||||||
emit("online", [online[g.referrer], muted], room=g.referrer, broadcast=True)
|
refresh_online()
|
||||||
|
|
||||||
if SITE == 'rdrama.net' and v.admin_level < PERMS['BYPASS_ANTISPAM_CHECKS']:
|
if SITE == 'rdrama.net' and v.admin_level < PERMS['BYPASS_ANTISPAM_CHECKS']:
|
||||||
def shut_up():
|
def shut_up():
|
||||||
self_only = True
|
self_only = True
|
||||||
muted_until = int(time.time() + 600)
|
muted_until = int(time.time() + 600)
|
||||||
muted[vname] = muted_until
|
muted[vname] = muted_until
|
||||||
emit("online", [online[g.referrer], muted], room=g.referrer, broadcast=True)
|
refresh_online()
|
||||||
|
|
||||||
if not self_only:
|
if not self_only:
|
||||||
identical = [x for x in list(messages[g.referrer].values())[-5:] if v.id == x['user_id'] and text == x['text']]
|
identical = [x for x in list(messages[g.referrer].values())[-5:] if v.id == x['user_id'] and text == x['text']]
|
||||||
|
@ -182,7 +182,7 @@ def speak(data, v):
|
||||||
username = i.group(1).lower()
|
username = i.group(1).lower()
|
||||||
muted_until = int(int(i.group(2)) * 60 + time.time())
|
muted_until = int(int(i.group(2)) * 60 + time.time())
|
||||||
muted[username] = muted_until
|
muted[username] = muted_until
|
||||||
emit("online", [online[g.referrer], muted], room=g.referrer, broadcast=True)
|
refresh_online()
|
||||||
self_only = True
|
self_only = True
|
||||||
|
|
||||||
if self_only or v.shadowbanned or execute_blackjack(v, None, text, "chat"):
|
if self_only or v.shadowbanned or execute_blackjack(v, None, text, "chat"):
|
||||||
|
@ -204,7 +204,8 @@ def refresh_online():
|
||||||
if val[1] in typing[g.referrer]:
|
if val[1] in typing[g.referrer]:
|
||||||
typing[g.referrer].remove(val[1])
|
typing[g.referrer].remove(val[1])
|
||||||
|
|
||||||
emit("online", [online[g.referrer], muted], room=g.referrer, broadcast=True)
|
data = [list(online[g.referrer].values()), muted]
|
||||||
|
emit("online", data, room=g.referrer, broadcast=True)
|
||||||
cache.set('loggedin_chat', len(online[f'{SITE_FULL}/chat']), timeout=0)
|
cache.set('loggedin_chat', len(online[f'{SITE_FULL}/chat']), timeout=0)
|
||||||
|
|
||||||
@socketio.on('connect')
|
@socketio.on('connect')
|
||||||
|
@ -251,7 +252,7 @@ def heartbeat(v):
|
||||||
if g.referrer not in ALLOWED_REFERRERS:
|
if g.referrer not in ALLOWED_REFERRERS:
|
||||||
return '', 400
|
return '', 400
|
||||||
expire_utc = int(time.time()) + 3610
|
expire_utc = int(time.time()) + 3610
|
||||||
online[g.referrer][v.id] = (expire_utc, v.username, v.name_color, v.patron)
|
online[g.referrer][v.id] = (expire_utc, v.username, v.name_color, v.patron, v.id)
|
||||||
refresh_online()
|
refresh_online()
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue