Skip to content

Commit

Permalink
Clear users and history on connection closed
Browse files Browse the repository at this point in the history
  • Loading branch information
kova98 committed Oct 20, 2023
1 parent f1a37a4 commit c1d6261
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions web-client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,17 @@ function connect() {
console.log('WebSocket is closed.', event);
let status = event.reason === '' ? 'Connection closed.' : event.reason;
setStatus(status);
clearHistory();
users = [];
updateUsersDisplay();
};
}

function clearHistory() {
const messages = document.getElementById('messages');
messages.innerHTML = '';
}

function handleHistory(message) {
for (let i = 0; i < message.Messages.length; i++) {
switch (message.Messages[i].Type) {
Expand Down Expand Up @@ -162,8 +170,4 @@ function goToChat() {

function currentPage() {
return document.querySelector('.page[style*="display: block"]');
}




}

0 comments on commit c1d6261

Please sign in to comment.