Only initialize socket when the user is logged in

This commit is contained in:
Patrick Jentsch 2020-05-27 11:11:54 +02:00
parent afd7469178
commit ecac2c481c
2 changed files with 4 additions and 3 deletions

View File

@ -216,6 +216,4 @@ document.addEventListener("DOMContentLoaded", function() {
flashedMessage = nopaque.flashedMessages.shift(); flashedMessage = nopaque.flashedMessages.shift();
nopaque.flash(flashedMessage[1], flashedMessage[0]); nopaque.flash(flashedMessage[1], flashedMessage[0]);
} }
nopaque.socket.init();
nopaque.socket.emit("user_data_stream_init");
}); });

View File

@ -237,7 +237,10 @@
<script src="{{ url_for('static', filename='js/Materialize/materialize.min.js') }}"></script> <script src="{{ url_for('static', filename='js/Materialize/materialize.min.js') }}"></script>
<script> <script>
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
{% if current_user.is_authenticated %}
nopaque.socket.init();
nopaque.socket.emit("user_data_stream_init");
{% endif %}
}); });
</script> </script>
</body> </body>