realtime.ts: Fix bug in user-color setup

The code was incorrectly migrated from JavaScript set colors in the wrong way.

Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
David Mehren 2020-05-31 21:40:05 +02:00
parent 5c4820483c
commit d2963eedc6
No known key found for this signature in database
GPG key ID: 6017AF117F9756CB

View file

@ -467,16 +467,21 @@ function finishConnection (socket: SocketWithNoteId, noteId: string, socketId: s
return failConnection(403, 'connection forbidden', socket) return failConnection(403, 'connection forbidden', socket)
} }
const user = users.get(socketId) const user = users.get(socketId)
if (!user || !user.userid) return if (!user) {
// update user color to author color logger.warn('Could not find user for socketId ' + socketId)
const author = note.authors.get(user.userid) return
if (author) { }
const socketIdUser = users.get(socket.id) if (user.userid) {
if (!socketIdUser) return // update user color to author color
user.color = socketIdUser.color const author = note.authors.get(user.userid)
users.set(socket.id, user) if (author) {
const socketIdUser = users.get(socket.id)
if (!socketIdUser) return
user.color = author.color
socketIdUser.color = author.color
users.set(socket.id, user)
}
} }
note.users.set(socket.id, user) note.users.set(socket.id, user)
note.socks.push(socket) note.socks.push(socket)
note.server.addClient(socket) note.server.addClient(socket)