Handle users.demote event (#6315)

* fix: Handle users.demote event

* fix: fetchAll

* fix: fetch based on total
This commit is contained in:
Apoorv Mishra
2023-12-27 08:33:44 +05:30
committed by GitHub
parent 4fd0e99909
commit 08aacdb302
6 changed files with 56 additions and 19 deletions

View File

@@ -18,6 +18,7 @@ import Pin from "~/models/Pin";
import Star from "~/models/Star";
import Subscription from "~/models/Subscription";
import Team from "~/models/Team";
import User from "~/models/User";
import withStores from "~/components/withStores";
import {
PartialWithId,
@@ -460,6 +461,13 @@ class WebsocketProvider extends React.Component<Props> {
}
);
this.socket.on("users.demote", async (event: PartialWithId<User>) => {
if (auth.user && event.id === auth.user.id) {
documents.all.forEach((document) => policies.remove(document.id));
await collections.fetchAll();
}
});
// received a message from the API server that we should request
// to join a specific room. Forward that to the ws server.
this.socket.on("join", (event) => {