mirror of
https://github.com/thelounge/thelounge
synced 2024-11-11 07:04:18 +00:00
Merge pull request #2859 from thelounge/xpaw/openChannel
Fix timing issue crashing on undefined when setting openChannel
This commit is contained in:
commit
18f96934f2
2 changed files with 8 additions and 3 deletions
|
@ -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 a new issue