Handle incoming channel read events

This commit is contained in:
Midgard 2022-06-09 14:36:33 +02:00
parent 64285bdf71
commit a7bd5f7dc7
Signed by: midgard
GPG key ID: 511C112F1331BBB4
2 changed files with 5 additions and 7 deletions

View file

@ -133,13 +133,7 @@ function switchToChannel(client, team, channel) {
response.order.reverse();
populateChannelContents(client, channel, response);
markChannelAsRead(client, channel)
.then(_ => {
pubsub.publish("CHANNEL_READ", {
endpoint: client.endpoint,
channel_id: channel.id
});
});
markChannelAsRead(client, channel);
})
.catch(error => {
console.error(error);

View file

@ -207,7 +207,11 @@ class MattermostClient {
if (data.event === "posted") {
const post = JSON.parse(data.data.post);
pubsub.publish("MESSAGES_NEW", {...post, endpoint: this.endpoint});
} else if (data.event === "channel_viewed") {
pubsub.publish("CHANNEL_READ", {endpoint: this.endpoint, channel_id: data.data.channel_id});
}
});
}