mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-04 23:02:18 +02:00
chan: remove cast in pushMessage
This commit is contained in:
parent
bb7c3925c6
commit
540144c417
|
@ -61,18 +61,13 @@ class Chan {
|
||||||
}
|
}
|
||||||
|
|
||||||
pushMessage(client: Client, msg: Msg, increasesUnread = false) {
|
pushMessage(client: Client, msg: Msg, increasesUnread = false) {
|
||||||
const chan = this.id;
|
const chanId = this.id;
|
||||||
const obj = {chan, msg} as {
|
const obj = {chan: chanId, msg, unread: undefined, highlight: undefined};
|
||||||
chan: number;
|
|
||||||
msg: Msg;
|
|
||||||
unread?: number;
|
|
||||||
highlight?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
msg.id = client.idMsg++;
|
msg.id = client.idMsg++;
|
||||||
|
|
||||||
// If this channel is open in any of the clients, do not increase unread counter
|
// If this channel is open in any of the clients, do not increase unread counter
|
||||||
const isOpen = _.find(client.attachedClients, {openChannel: chan}) !== undefined;
|
const isOpen = _.find(client.attachedClients, {openChannel: chanId}) !== undefined;
|
||||||
|
|
||||||
if (msg.self) {
|
if (msg.self) {
|
||||||
// reset counters/markers when receiving self-/echo-message
|
// reset counters/markers when receiving self-/echo-message
|
||||||
|
@ -85,15 +80,15 @@ class Chan {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (increasesUnread || msg.highlight) {
|
if (increasesUnread || msg.highlight) {
|
||||||
obj.unread = ++this.unread;
|
this.unread++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.highlight) {
|
if (msg.highlight) {
|
||||||
obj.highlight = ++this.highlight;
|
this.highlight++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
client.emit("msg", obj);
|
client.emit("msg", {chan: chanId, msg, unread: this.unread, highlight: this.highlight});
|
||||||
|
|
||||||
// Never store messages in public mode as the session
|
// Never store messages in public mode as the session
|
||||||
// is completely destroyed when the page gets closed
|
// is completely destroyed when the page gets closed
|
||||||
|
|
Loading…
Reference in a new issue