From d42927a14762f7faac1032f658c46c7c92b994c0 Mon Sep 17 00:00:00 2001 From: Alexandre Chau Date: Tue, 22 Jun 2021 18:48:22 +0200 Subject: [PATCH] feat: add ws hook calls for shared items and children updates --- src/components/SharedItems.js | 6 ++++-- src/components/main/ItemScreen.js | 3 ++- src/config/queryClient.js | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/SharedItems.js b/src/components/SharedItems.js index ce964b3c6..061d8f4fb 100644 --- a/src/components/SharedItems.js +++ b/src/components/SharedItems.js @@ -8,18 +8,20 @@ import { import ItemHeader from './item/header/ItemHeader'; import ErrorAlert from './common/ErrorAlert'; import Items from './main/Items'; -import { hooks } from '../config/queryClient'; +import { hooks, ws } from '../config/queryClient'; import Loader from './common/Loader'; const SharedItems = () => { const { t } = useTranslation(); const { data: sharedItems, isLoading, isError } = hooks.useSharedItems(); + const { data: user, isUserLoading } = hooks.useCurrentMember(); + ws.hooks.useSharedItemsUpdates(user?.get('id')); if (isError) { return ; } - if (isLoading) { + if (isLoading || isUserLoading) { return ; } diff --git a/src/components/main/ItemScreen.js b/src/components/main/ItemScreen.js index 253c2cf31..6febf7e04 100644 --- a/src/components/main/ItemScreen.js +++ b/src/components/main/ItemScreen.js @@ -9,7 +9,7 @@ import { AppItem, } from '@graasp/ui'; import { MUTATION_KEYS } from '@graasp/query-client'; -import { hooks, useMutation } from '../../config/queryClient'; +import { hooks, useMutation, ws } from '../../config/queryClient'; import Items from './Items'; import { buildFileItemId, @@ -47,6 +47,7 @@ const ItemScreen = () => { // display children const { data: children, isLoading: isChildrenLoading } = useChildren(itemId); + ws.hooks.useChildrenUpdates(itemId); const id = item?.get(ITEM_KEYS.ID); const { data: content } = useFileContent(id, { diff --git a/src/config/queryClient.js b/src/config/queryClient.js index 64aa05dd5..d60736ed4 100644 --- a/src/config/queryClient.js +++ b/src/config/queryClient.js @@ -6,6 +6,7 @@ const { queryClient, QueryClientProvider, hooks, + ws, useMutation, ReactQueryDevtools, API_ROUTES, @@ -18,6 +19,7 @@ export { queryClient, QueryClientProvider, hooks, + ws, useMutation, ReactQueryDevtools, API_ROUTES,