forked from MarseyWorld/MarseyWorld
fds
parent
1c83004972
commit
4bd2d4e967
|
@ -1,8 +1,6 @@
|
|||
from files.helpers.const import SITE
|
||||
|
||||
if SITE in ('pcmemes.net', 'localhost'):
|
||||
count = 0
|
||||
|
||||
import time
|
||||
from files.helpers.wrappers import auth_required
|
||||
from files.helpers.sanitize import sanitize
|
||||
|
@ -14,6 +12,7 @@ if SITE in ('pcmemes.net', 'localhost'):
|
|||
|
||||
socketio = SocketIO(app, async_mode='gevent')
|
||||
typing = []
|
||||
online = []
|
||||
|
||||
@app.get("/chat")
|
||||
@auth_required
|
||||
|
@ -37,10 +36,11 @@ if SITE in ('pcmemes.net', 'localhost'):
|
|||
return '', 204
|
||||
|
||||
@socketio.on('connect')
|
||||
def connect():
|
||||
global count
|
||||
count += 1
|
||||
emit("count", count, broadcast=True)
|
||||
@auth_required
|
||||
def connect(v):
|
||||
if v.username not in online:
|
||||
online.append(v.username)
|
||||
emit("online", online, broadcast=True)
|
||||
|
||||
emit('typing', typing)
|
||||
return '', 204
|
||||
|
@ -48,9 +48,10 @@ if SITE in ('pcmemes.net', 'localhost'):
|
|||
@socketio.on('disconnect')
|
||||
@auth_required
|
||||
def disconnect(v):
|
||||
global count
|
||||
count -= 1
|
||||
emit("count", count, broadcast=True)
|
||||
if v.username in online:
|
||||
online.remove(v.username)
|
||||
emit("online", online, broadcast=True)
|
||||
|
||||
if v.username in typing: typing.remove(v.username)
|
||||
emit('typing', typing, broadcast=True)
|
||||
return '', 204
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% block content %}
|
||||
|
||||
<div class="border-right py-3 px-3">
|
||||
<span data-toggle="tooltip" data-placement="bottom" title="people online right now" class="text-muted">
|
||||
<span data-toggle="tooltip" data-placement="bottom" data-bs-title="Users online right now" title="Users online right now" class="text-muted">
|
||||
<i class="far fa-user fa-sm mr-1"></i>
|
||||
<span class="board-chat-count">0</span>
|
||||
</span>
|
||||
|
@ -157,8 +157,12 @@
|
|||
}
|
||||
})
|
||||
|
||||
socket.on('count', function(data){
|
||||
document.getElementsByClassName('board-chat-count')[0].innerHTML = data
|
||||
socket.on('online', function(data){
|
||||
document.getElementsByClassName('board-chat-count')[0].innerHTML = data.length
|
||||
let online = ''
|
||||
for (const u of data)
|
||||
online += `<li><a href="/@${u}" class="text-lg">${u}</a></li>`
|
||||
document.getElementById('online').innerHTML = online
|
||||
})
|
||||
|
||||
window.addEventListener('blur', function(){
|
||||
|
|
|
@ -287,11 +287,14 @@
|
|||
{% endblock %}
|
||||
|
||||
</div>
|
||||
{% if home or sub and p %}
|
||||
{% block sidebar %}
|
||||
{% block sidebar %}
|
||||
{% if home or sub and p %}
|
||||
{% include "sidebar_" + SITE_NAME + ".html" %}
|
||||
{% endblock %}
|
||||
{% endif %}
|
||||
{% elif request.path == '/chat' %}
|
||||
<div id="online" class="col sidebar text-left d-none d-lg-block pt-3 bg-white" style="max-width:300px">
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue