Ignore server unread sync for active channel
This commit is contained in:
parent
3c4a9efe7e
commit
4a0f319e91
@ -20,15 +20,25 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
socket.on("msg", function(data) {
|
socket.on("msg", function(data) {
|
||||||
let targetId = data.chan;
|
const receivingChannel = findChannel(data.chan);
|
||||||
let {channel} = findChannel(data.chan);
|
|
||||||
|
|
||||||
if (typeof data.highlight !== "undefined") {
|
if (!receivingChannel) {
|
||||||
channel.highlight = data.highlight;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof data.unread !== "undefined") {
|
let channel = receivingChannel.channel;
|
||||||
channel.unread = data.unread;
|
const isActiveChannel = vueApp.activeChannel && vueApp.activeChannel.channel === channel;
|
||||||
|
|
||||||
|
// Do not set unread counter for channel if it is currently active on this client
|
||||||
|
// It may increase on the server before it processes channel open event from this client
|
||||||
|
if (!isActiveChannel) {
|
||||||
|
if (typeof data.highlight !== "undefined") {
|
||||||
|
channel.highlight = data.highlight;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof data.unread !== "undefined") {
|
||||||
|
channel.unread = data.unread;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.msg.self || data.msg.highlight) {
|
if (data.msg.self || data.msg.highlight) {
|
||||||
@ -38,10 +48,10 @@ socket.on("msg", function(data) {
|
|||||||
// Display received notices and errors in currently active channel.
|
// Display received notices and errors in currently active channel.
|
||||||
// Reloading the page will put them back into the lobby window.
|
// Reloading the page will put them back into the lobby window.
|
||||||
// We only want to put errors/notices in active channel if they arrive on the same network
|
// We only want to put errors/notices in active channel if they arrive on the same network
|
||||||
if (data.msg.showInActive && vueApp.activeChannel && vueApp.activeChannel.network === channel.network) {
|
if (data.msg.showInActive && vueApp.activeChannel && vueApp.activeChannel.network === receivingChannel.network) {
|
||||||
channel = vueApp.activeChannel.channel;
|
channel = vueApp.activeChannel.channel;
|
||||||
|
|
||||||
targetId = data.chan = channel.id;
|
data.chan = channel.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.messages.push(data.msg);
|
channel.messages.push(data.msg);
|
||||||
@ -49,12 +59,12 @@ socket.on("msg", function(data) {
|
|||||||
if (data.msg.self) {
|
if (data.msg.self) {
|
||||||
channel.firstUnread = data.msg.id;
|
channel.firstUnread = data.msg.id;
|
||||||
} else {
|
} else {
|
||||||
notifyMessage(targetId, channel, vueApp.activeChannel, data.msg);
|
notifyMessage(data.chan, channel, vueApp.activeChannel, data.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
let messageLimit = 0;
|
let messageLimit = 0;
|
||||||
|
|
||||||
if (!vueApp.activeChannel || vueApp.activeChannel.channel !== channel) {
|
if (!isActiveChannel) {
|
||||||
// If message arrives in non active channel, keep only 100 messages
|
// If message arrives in non active channel, keep only 100 messages
|
||||||
messageLimit = 100;
|
messageLimit = 100;
|
||||||
} else if (channel.scrolledToBottom) {
|
} else if (channel.scrolledToBottom) {
|
||||||
|
Loading…
Reference in New Issue
Block a user