| State.websocket.onmessage = (e) => { | State.websocket.onmessage = (e) => { | ||||
| const message = JSON.parse(e.data) | const message = JSON.parse(e.data) | ||||
| if(message.online) { | |||||
| const difference = (l1, l2) => l1.filter(u => !l2.includes(u)) | |||||
| difference(message.online, State.online).forEach(username => | |||||
| State.posts.push({ts: message.ts, value: `${username} joined`})) | |||||
| difference(State.online, message.online).forEach(username => | |||||
| State.posts.push({ts: message.ts, value: `${username} left`})) | |||||
| } | |||||
| if(!doNotLog.has(message.kind)) { | if(!doNotLog.has(message.kind)) { | ||||
| console.log(message) | console.log(message) | ||||
| } | } |