fix: Models are not all removed from local store upon access change (#3729)

* fix: Clean data from stores correctly on 401/403 response

* Convert DataLoader from class component, remove observables and caching

* types
This commit is contained in:
Tom Moor
2022-07-03 22:48:50 +02:00
committed by GitHub
parent 9cd26168e1
commit 5d498632c6
7 changed files with 165 additions and 212 deletions

View File

@@ -6,6 +6,7 @@ import * as React from "react";
import io from "socket.io-client";
import RootStore from "~/stores/RootStore";
import withStores from "~/components/withStores";
import { AuthorizationError, NotFoundError } from "~/utils/errors";
import { getVisibilityListener, getPageVisible } from "~/utils/pageVisibility";
type SocketWithAuthentication = {
@@ -154,7 +155,10 @@ class SocketProvider extends React.Component<Props> {
force: true,
});
} catch (err) {
if (err.statusCode === 404 || err.statusCode === 403) {
if (
err instanceof AuthorizationError ||
err instanceof NotFoundError
) {
documents.remove(documentId);
return;
}
@@ -216,7 +220,10 @@ class SocketProvider extends React.Component<Props> {
force: true,
});
} catch (err) {
if (err.statusCode === 404 || err.statusCode === 403) {
if (
err instanceof AuthorizationError ||
err instanceof NotFoundError
) {
documents.removeCollectionDocuments(collectionId);
memberships.removeCollectionMemberships(collectionId);
collections.remove(collectionId);
@@ -245,7 +252,10 @@ class SocketProvider extends React.Component<Props> {
force: true,
});
} catch (err) {
if (err.statusCode === 404 || err.statusCode === 403) {
if (
err instanceof AuthorizationError ||
err instanceof NotFoundError
) {
groups.remove(groupId);
}
}