Handle incoming channel read events
This commit is contained in:
parent
64285bdf71
commit
a7bd5f7dc7
2 changed files with 5 additions and 7 deletions
|
@ -133,13 +133,7 @@ function switchToChannel(client, team, channel) {
|
||||||
response.order.reverse();
|
response.order.reverse();
|
||||||
populateChannelContents(client, channel, response);
|
populateChannelContents(client, channel, response);
|
||||||
|
|
||||||
markChannelAsRead(client, channel)
|
markChannelAsRead(client, channel);
|
||||||
.then(_ => {
|
|
||||||
pubsub.publish("CHANNEL_READ", {
|
|
||||||
endpoint: client.endpoint,
|
|
||||||
channel_id: channel.id
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
|
@ -207,7 +207,11 @@ class MattermostClient {
|
||||||
if (data.event === "posted") {
|
if (data.event === "posted") {
|
||||||
const post = JSON.parse(data.data.post);
|
const post = JSON.parse(data.data.post);
|
||||||
pubsub.publish("MESSAGES_NEW", {...post, endpoint: this.endpoint});
|
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});
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue