Handle user changes
This commit is contained in:
parent
68f87f4048
commit
e63d8f0305
1 changed files with 13 additions and 1 deletions
|
@ -170,6 +170,10 @@ class MattermostClient {
|
||||||
}
|
}
|
||||||
return this.users;
|
return this.users;
|
||||||
}
|
}
|
||||||
|
regetUsers() {
|
||||||
|
this.users = null;
|
||||||
|
return this.getUsers();
|
||||||
|
}
|
||||||
|
|
||||||
async filePublicLink(file_id) {
|
async filePublicLink(file_id) {
|
||||||
const response = await this.get(`/files/${file_id}/link`, {});
|
const response = await this.get(`/files/${file_id}/link`, {});
|
||||||
|
@ -186,7 +190,8 @@ class MattermostClient {
|
||||||
const socket = new WebSocket(endpoint);
|
const socket = new WebSocket(endpoint);
|
||||||
|
|
||||||
socket.addEventListener("error", event => {
|
socket.addEventListener("error", event => {
|
||||||
console.error("Websocket errored", event.data);
|
console.error("Websocket errored", event.data);
|
||||||
|
this.regetUsers();
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.addEventListener("close", event => {
|
socket.addEventListener("close", event => {
|
||||||
|
@ -208,6 +213,13 @@ class MattermostClient {
|
||||||
|
|
||||||
} else if (data.event === "channel_viewed") {
|
} else if (data.event === "channel_viewed") {
|
||||||
pubsub.publish("CHANNEL_READ", {endpoint: this.endpoint, channel_id: data.data.channel_id});
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue