Remove collection fetch on document delete

This commit is contained in:
Tom Moor
2022-08-25 10:43:05 +02:00
parent 60309975e0
commit d2aea687f3
6 changed files with 53 additions and 22 deletions

View File

@@ -17,6 +17,7 @@ import {
PartialWithId,
WebsocketCollectionUpdateIndexEvent,
WebsocketCollectionUserEvent,
WebsocketDocumentDeletedEvent,
WebsocketEntitiesEvent,
WebsocketEntityDeletedEvent,
} from "~/types";
@@ -247,15 +248,23 @@ class SocketProvider extends React.Component<Props> {
}
);
this.socket.on("documents.delete", (event: WebsocketEntityDeletedEvent) => {
const document = documents.get(event.modelId);
this.socket.on(
"documents.delete",
(event: WebsocketDocumentDeletedEvent) => {
const document = documents.get(event.modelId);
const collection = collections.get(event.collectionId);
if (document) {
document.deletedAt = new Date().toISOString();
if (collection) {
collection.removeDocument(event.modelId);
}
if (document) {
document.deletedAt = new Date().toISOString();
}
policies.remove(event.modelId);
}
policies.remove(event.modelId);
});
);
this.socket.on(
"documents.permanent_delete",