Handle user changes

This commit is contained in:
Midgard 2022-06-17 14:20:42 +02:00
parent 68f87f4048
commit e63d8f0305
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -170,6 +170,10 @@ class MattermostClient {
}
return this.users;
}
regetUsers() {
this.users = null;
return this.getUsers();
}
async filePublicLink(file_id) {
const response = await this.get(`/files/${file_id}/link`, {});
@ -186,7 +190,8 @@ class MattermostClient {
const socket = new WebSocket(endpoint);
socket.addEventListener("error", event => {
console.error("Websocket errored", event.data);
console.error("Websocket errored", event.data);
this.regetUsers();
});
socket.addEventListener("close", event => {
@ -208,6 +213,13 @@ class MattermostClient {
} else if (data.event === "channel_viewed") {
pubsub.publish("CHANNEL_READ", {endpoint: this.endpoint, channel_id: data.data.channel_id});
} else if (
data.event === "user_added" ||
data.event === "user_updated" ||
data.event === "user_removed"
) {
this.regetUsers();
}
});