Separate teams.update event
This commit is contained in:
@@ -8,6 +8,7 @@ import RootStore from "~/stores/RootStore";
|
|||||||
import FileOperation from "~/models/FileOperation";
|
import FileOperation from "~/models/FileOperation";
|
||||||
import Pin from "~/models/Pin";
|
import Pin from "~/models/Pin";
|
||||||
import Star from "~/models/Star";
|
import Star from "~/models/Star";
|
||||||
|
import Team from "~/models/Team";
|
||||||
import withStores from "~/components/withStores";
|
import withStores from "~/components/withStores";
|
||||||
import {
|
import {
|
||||||
PartialWithId,
|
PartialWithId,
|
||||||
@@ -229,10 +230,6 @@ class SocketProvider extends React.Component<Props> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.teamIds) {
|
|
||||||
await auth.fetch();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on("documents.delete", (event: WebsocketEntityDeletedEvent) => {
|
this.socket.on("documents.delete", (event: WebsocketEntityDeletedEvent) => {
|
||||||
@@ -245,6 +242,13 @@ class SocketProvider extends React.Component<Props> {
|
|||||||
policies.remove(event.modelId);
|
policies.remove(event.modelId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.socket.on(
|
||||||
|
"documents.permanent_delete",
|
||||||
|
(event: WebsocketEntityDeletedEvent) => {
|
||||||
|
documents.remove(event.modelId);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.socket.on("groups.delete", (event: WebsocketEntityDeletedEvent) => {
|
this.socket.on("groups.delete", (event: WebsocketEntityDeletedEvent) => {
|
||||||
groups.remove(event.modelId);
|
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>) => {
|
this.socket.on("pins.create", (event: PartialWithId<Pin>) => {
|
||||||
pins.add(event);
|
pins.add(event);
|
||||||
});
|
});
|
||||||
@@ -291,13 +299,6 @@ class SocketProvider extends React.Component<Props> {
|
|||||||
stars.remove(event.modelId);
|
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
|
// 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.
|
// if the user is us then we go ahead and load the collection from API.
|
||||||
this.socket.on(
|
this.socket.on(
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ import {
|
|||||||
GroupUser,
|
GroupUser,
|
||||||
Pin,
|
Pin,
|
||||||
Star,
|
Star,
|
||||||
|
Team,
|
||||||
} from "@server/models";
|
} from "@server/models";
|
||||||
import {
|
import {
|
||||||
presentFileOperation,
|
presentFileOperation,
|
||||||
presentPin,
|
presentPin,
|
||||||
presentStar,
|
presentStar,
|
||||||
|
presentTeam,
|
||||||
} from "@server/presenters";
|
} from "@server/presenters";
|
||||||
import { Event } from "../../types";
|
import { Event } from "../../types";
|
||||||
|
|
||||||
@@ -582,14 +584,13 @@ export default class WebsocketsProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "teams.update": {
|
case "teams.update": {
|
||||||
return socketio.to(`team-${event.teamId}`).emit("entities", {
|
const team = await Team.scope("withDomains").findByPk(event.teamId);
|
||||||
event: event.name,
|
if (!team) {
|
||||||
teamIds: [
|
return;
|
||||||
{
|
}
|
||||||
id: event.teamId,
|
return socketio
|
||||||
},
|
.to(`team-${event.teamId}`)
|
||||||
],
|
.emit(event.name, presentTeam(team));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user