fix: collections.create event not propagated when initialized with private permissions

This commit is contained in:
Tom Moor
2022-08-24 22:49:44 +02:00
parent de5524d366
commit 983010b5d8
2 changed files with 10 additions and 11 deletions

View File

@@ -5,6 +5,7 @@ import { observer } from "mobx-react";
import * as React from "react";
import { io, Socket } from "socket.io-client";
import RootStore from "~/stores/RootStore";
import Collection from "~/models/Collection";
import Document from "~/models/Document";
import FileOperation from "~/models/FileOperation";
import Pin from "~/models/Pin";
@@ -267,6 +268,10 @@ class SocketProvider extends React.Component<Props> {
groups.remove(event.modelId);
});
this.socket.on("collections.create", (event: PartialWithId<Collection>) => {
collections.add(event);
});
this.socket.on(
"collections.delete",
(event: WebsocketEntityDeletedEvent) => {

View File

@@ -13,6 +13,7 @@ import {
Team,
} from "@server/models";
import {
presentCollection,
presentDocument,
presentFileOperation,
presentPin,
@@ -177,22 +178,15 @@ export default class WebsocketsProcessor {
.to(
collection.permission
? `team-${collection.teamId}`
: `collection-${collection.id}`
: `user-${collection.createdById}`
)
.emit("entities", {
event: event.name,
collectionIds: [
{
id: collection.id,
updatedAt: collection.updatedAt,
},
],
});
.emit(event.name, presentCollection(collection));
return socketio
.to(
collection.permission
? `team-${collection.teamId}`
: `collection-${collection.id}`
: `user-${collection.createdById}`
)
.emit("join", {
event: event.name,