Separate teams.update event

This commit is contained in:
Tom Moor
2022-08-24 00:35:50 +02:00
parent d17e6f3432
commit 7804f33e0d
2 changed files with 21 additions and 19 deletions

View File

@@ -8,6 +8,7 @@ import RootStore from "~/stores/RootStore";
import FileOperation from "~/models/FileOperation";
import Pin from "~/models/Pin";
import Star from "~/models/Star";
import Team from "~/models/Team";
import withStores from "~/components/withStores";
import {
PartialWithId,
@@ -229,10 +230,6 @@ class SocketProvider extends React.Component<Props> {
}
}
}
if (event.teamIds) {
await auth.fetch();
}
});
this.socket.on("documents.delete", (event: WebsocketEntityDeletedEvent) => {
@@ -245,6 +242,13 @@ class SocketProvider extends React.Component<Props> {
policies.remove(event.modelId);
});
this.socket.on(
"documents.permanent_delete",
(event: WebsocketEntityDeletedEvent) => {
documents.remove(event.modelId);
}
);
this.socket.on("groups.delete", (event: WebsocketEntityDeletedEvent) => {
groups.remove(event.modelId);
});
@@ -267,6 +271,10 @@ class SocketProvider extends React.Component<Props> {
}
);
this.socket.on("teams.update", (event: PartialWithId<Team>) => {
auth.updateTeam(event);
});
this.socket.on("pins.create", (event: PartialWithId<Pin>) => {
pins.add(event);
});
@@ -291,13 +299,6 @@ class SocketProvider extends React.Component<Props> {
stars.remove(event.modelId);
});
this.socket.on(
"documents.permanent_delete",
(event: WebsocketEntityDeletedEvent) => {
documents.remove(event.modelId);
}
);
// received when a user is given access to a collection
// if the user is us then we go ahead and load the collection from API.
this.socket.on(

View File

@@ -10,11 +10,13 @@ import {
GroupUser,
Pin,
Star,
Team,
} from "@server/models";
import {
presentFileOperation,
presentPin,
presentStar,
presentTeam,
} from "@server/presenters";
import { Event } from "../../types";
@@ -582,14 +584,13 @@ export default class WebsocketsProcessor {
}
case "teams.update": {
return socketio.to(`team-${event.teamId}`).emit("entities", {
event: event.name,
teamIds: [
{
id: event.teamId,
},
],
});
const team = await Team.scope("withDomains").findByPk(event.teamId);
if (!team) {
return;
}
return socketio
.to(`team-${event.teamId}`)
.emit(event.name, presentTeam(team));
}
default: