Merge pull request #2859 from thelounge/xpaw/openChannel
Fix timing issue crashing on undefined when setting openChannel
This commit is contained in:
commit
18f96934f2
@ -404,9 +404,14 @@ Client.prototype.more = function(data) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.open = function(socketId, target) {
|
Client.prototype.open = function(socketId, target) {
|
||||||
|
// Due to how socket.io works internally, normal events may arrive later than
|
||||||
|
// the disconnect event, and because we can't control this timing precisely,
|
||||||
|
// process this event normally even if there is no attached client anymore.
|
||||||
|
const attachedClient = this.attachedClients[socketId] || {};
|
||||||
|
|
||||||
// Opening a window like settings
|
// Opening a window like settings
|
||||||
if (target === null) {
|
if (target === null) {
|
||||||
this.attachedClients[socketId].openChannel = -1;
|
attachedClient.openChannel = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +425,7 @@ Client.prototype.open = function(socketId, target) {
|
|||||||
target.chan.unread = 0;
|
target.chan.unread = 0;
|
||||||
target.chan.highlight = 0;
|
target.chan.highlight = 0;
|
||||||
|
|
||||||
this.attachedClients[socketId].openChannel = target.chan.id;
|
attachedClient.openChannel = target.chan.id;
|
||||||
this.lastActiveChannel = target.chan.id;
|
this.lastActiveChannel = target.chan.id;
|
||||||
|
|
||||||
this.emit("open", target.chan.id);
|
this.emit("open", target.chan.id);
|
||||||
|
@ -295,7 +295,7 @@ function initializeClient(socket, client, token, lastMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
socket.on("disconnect", function() {
|
socket.on("disconnect", function() {
|
||||||
client.clientDetach(socket.id);
|
process.nextTick(() => client.clientDetach(socket.id));
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on("input", (data) => {
|
socket.on("input", (data) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user