Skip to content

Commit

Permalink
feat: add ws hook calls for shared items and children updates
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofmochi committed Jun 22, 2021
1 parent ffba93c commit d42927a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/SharedItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ErrorAlert id={SHARED_ITEMS_ERROR_ALERT_ID} />;
}

if (isLoading) {
if (isLoading || isUserLoading) {
return <Loader />;
}

Expand Down
3 changes: 2 additions & 1 deletion src/components/main/ItemScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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, {
Expand Down
2 changes: 2 additions & 0 deletions src/config/queryClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
queryClient,
QueryClientProvider,
hooks,
ws,
useMutation,
ReactQueryDevtools,
API_ROUTES,
Expand All @@ -18,6 +19,7 @@ export {
queryClient,
QueryClientProvider,
hooks,
ws,
useMutation,
ReactQueryDevtools,
API_ROUTES,
Expand Down

0 comments on commit d42927a

Please sign in to comment.