thelounge/client/js/socket-events/open.js

30 lines
678 B
JavaScript
Raw Normal View History

2017-05-18 22:08:54 +02:00
"use strict";
2019-11-16 18:24:03 +01:00
import socket from "../socket";
import store from "../store";
2017-05-18 22:08:54 +02:00
// Sync unread badge and marker when other clients open a channel
2017-05-18 22:08:54 +02:00
socket.on("open", function(id) {
if (id < 1) {
return;
}
// Don't do anything if the channel is active on this client
if (store.state.activeChannel && store.state.activeChannel.channel.id === id) {
return;
}
// Clear the unread badge
const channel = store.getters.findChannel(id);
if (channel) {
channel.channel.highlight = 0;
channel.channel.unread = 0;
if (channel.channel.messages.length > 0) {
2019-07-17 11:33:59 +02:00
channel.channel.firstUnread =
channel.channel.messages[channel.channel.messages.length - 1].id;
}
}
2017-05-18 22:08:54 +02:00
});