Skip to content

Commit

Permalink
feat(deps): update TanStack Query to v5 (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReidyT authored Oct 2, 2024
1 parent 9def0fb commit dfd7197
Show file tree
Hide file tree
Showing 22 changed files with 62 additions and 109 deletions.
15 changes: 8 additions & 7 deletions cypress/fixtures/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import {
LocalFileItemFactory,
MaxWidth,
MimeTypes,
S3FileItemFactory,
PackedLocalFileItemFactory,
PackedS3FileItemFactory,
buildFileExtra,
buildS3FileExtra,
} from '@graasp/sdk';
Expand All @@ -18,7 +19,7 @@ export const VIDEO_FILEPATH = 'files/video.mp4';
export const TEXT_FILEPATH = 'files/sometext.txt';

export const IMAGE_ITEM_DEFAULT: LocalFileItemForTest = {
...LocalFileItemFactory({
...PackedLocalFileItemFactory({
id: 'bd5519a2-5ba9-4305-b221-185facbe6a99',
name: 'icon.png',
description: 'a default image description',
Expand Down Expand Up @@ -70,7 +71,7 @@ export const IMAGE_ITEM_DEFAULT_WITH_MAX_WIDTH: LocalFileItemForTest = {
};

export const VIDEO_ITEM_DEFAULT: LocalFileItemForTest = {
...LocalFileItemFactory({
...PackedLocalFileItemFactory({
id: 'qd5519a2-5ba9-4305-b221-185facbe6a99',
name: 'video.mp4',
description: 'a default video description',
Expand All @@ -95,7 +96,7 @@ export const VIDEO_ITEM_DEFAULT: LocalFileItemForTest = {
};

export const PDF_ITEM_DEFAULT: LocalFileItemForTest = {
...LocalFileItemFactory({
...PackedLocalFileItemFactory({
id: 'cd5519a2-5ba9-4305-b221-185facbe6a99',
name: 'doc.pdf',
description: 'a default pdf description',
Expand Down Expand Up @@ -125,7 +126,7 @@ export const ZIP_DEFAULT: ZIPInternalItem = {
};

export const IMAGE_ITEM_S3: S3FileItemForTest = {
...S3FileItemFactory({
...PackedS3FileItemFactory({
id: 'ad5519a2-5ba9-4305-b221-185facbe6a99',
name: 'icon.png',
description: 'a default image description',
Expand All @@ -150,7 +151,7 @@ export const IMAGE_ITEM_S3: S3FileItemForTest = {
};

export const VIDEO_ITEM_S3: S3FileItemForTest = {
...S3FileItemFactory({
...PackedS3FileItemFactory({
id: 'qd5519a2-5ba9-4305-b221-185facbe6a93',
name: 'video.mp4',
description: 'a default video description',
Expand All @@ -175,7 +176,7 @@ export const VIDEO_ITEM_S3: S3FileItemForTest = {
};

export const PDF_ITEM_S3: S3FileItemForTest = {
...S3FileItemFactory({
...PackedS3FileItemFactory({
id: 'bd5519a2-5ba9-4305-b221-185facbe6a99',
name: 'doc.pdf',
description: 'a default pdf description',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@emotion/styled": "11.13.0",
"@graasp/chatbox": "3.3.0",
"@graasp/map": "1.19.0",
"@graasp/query-client": "3.25.0",
"@graasp/query-client": "3.26.0",
"@graasp/sdk": "4.31.0",
"@graasp/stylis-plugin-rtl": "2.2.0",
"@graasp/translations": "1.39.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const Root = (): JSX.Element => (
<ThemeWrapper />
</I18nextProvider>
{import.meta.env.DEV && import.meta.env.MODE !== 'test' && (
<ReactQueryDevtools position="bottom-right" />
<ReactQueryDevtools buttonPosition="bottom-left" />
)}
</QueryClientProvider>
</HelmetProvider>
Expand Down
4 changes: 2 additions & 2 deletions src/components/file/FileUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const FileUploader = ({
const { itemId: parentItemId } = useParams();
const [error, setError] = useState<string>();

const { mutateAsync: uploadFiles, isLoading } = mutations.useUploadFiles();
const { mutateAsync: uploadFiles, isPending } = mutations.useUploadFiles();

const [totalProgress, setTotalProgress] = useState(0);

Expand Down Expand Up @@ -96,7 +96,7 @@ const FileUploader = ({
onDrop([...e.target.files]);
}
}}
isLoading={isLoading}
isLoading={isPending}
uploadProgress={Math.ceil(totalProgress * 100)}
multiple
onDrop={onDrop}
Expand Down
4 changes: 2 additions & 2 deletions src/components/hooks/useItemCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ export const useItemCategories = ({

const {
mutate: createItemCategory,
isLoading: isPostLoading,
isPending: isPostLoading,
isSuccess: isPostSuccess,
isError: isPostError,
} = usePostItemCategory();
const {
mutate: deleteItemCategory,
isLoading: isDeleteLoading,
isPending: isDeleteLoading,
isSuccess: isDeleteSuccess,
isError: isDeleteError,
} = useDeleteItemCategory();
Expand Down
2 changes: 1 addition & 1 deletion src/components/hooks/useItemLicense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const useItemLicense = ({

const {
mutate: updateItem,
isLoading,
isPending: isLoading,
isError,
isSuccess,
} = useEditItem({ enableNotifications });
Expand Down
2 changes: 1 addition & 1 deletion src/components/item/publish/CoEditorsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const CoEditorsContainer = ({

const {
mutate: updateDisplayCoEditors,
isLoading,
isPending: isLoading,
isSuccess,
isError,
} = mutations.useEditItem({
Expand Down
2 changes: 1 addition & 1 deletion src/components/item/publish/EditItemDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const EditItemDescription = ({ item }: Props): JSX.Element => {
const {
mutate: updateItem,
isSuccess,
isLoading,
isPending: isLoading,
isError,
} = mutations.useEditItem({
enableNotifications: false,
Expand Down
2 changes: 1 addition & 1 deletion src/components/item/publish/EditItemName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const EditItemName = ({ item }: Props): JSX.Element => {
const {
mutate: updateItem,
isSuccess,
isLoading,
isPending: isLoading,
isError,
} = mutations.useEditItem({
enableNotifications: false,
Expand Down
6 changes: 2 additions & 4 deletions src/components/item/publish/ItemPublishTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ const ItemPublishTab = (): JSX.Element => {
const { isLoading: isMemberLoading } = hooks.useCurrentMember();
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
const { status } = useDataSyncContext();
const {
data: publicationStatus,
isInitialLoading: isPublicationStatusLoading,
} = usePublicationStatus(item.id);
const { data: publicationStatus, isLoading: isPublicationStatusLoading } =
usePublicationStatus(item.id);

const [notifyCoEditors, setNotifyCoEditors] = useState<boolean>(false);

Expand Down
4 changes: 2 additions & 2 deletions src/components/item/publish/PublicationStatusComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const { usePublicationStatus } = hooks;
export const PublicationStatusComponent = ({ item }: Props): JSX.Element => {
const { t } = useBuilderTranslation();
const { t: translateEnum } = useEnumsTranslation();
const { data: status, isInitialLoading } = usePublicationStatus(item.id);
const { data: status, isLoading } = usePublicationStatus(item.id);
const translatedType = capitalizeFirstLetter(translateEnum(item.type));

if (isInitialLoading) {
if (isLoading) {
return (
<Chip
icon={<CircularProgress size={15} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const useCustomizedTags = ({
const {
mutate: updateCustomizedTags,
isSuccess,
isLoading,
isPending: isLoading,
isError,
} = mutations.useEditItem({
enableNotifications,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const InvalidButton = ({ item, isLoading }: Props): JSX.Element => {
const { id: itemId, public: isPublic } = item;
const { isOpen, openModal, closeModal } = useModalStatus();

const { mutate: validateItem, isLoading: isValidating } =
const { mutate: validateItem, isPending: isValidating } =
usePostItemValidation();

const handleValidateItem = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const PublicationButtonSelector = ({
item,
notifyCoEditors,
}: Props): ReactNode | undefined => {
const { data: status, isInitialLoading: isStatusFirstLoading } =
const { data: status, isLoading: isStatusFirstLoading } =
usePublicationStatus(item.id);

switch (status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const PublishedButton = ({ item, isLoading }: Props): JSX.Element => {
const { t } = useBuilderTranslation();
const { id: itemId } = item;

const { mutate: unpublish, isLoading: isUnPublishing } = useUnpublishItem();
const { mutate: unpublish, isPending: isUnPublishing } = useUnpublishItem();

const handleUnPublishItem = () => unpublish({ id: itemId });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const ReadyToPublishButton = ({
const { id: itemId, public: isPublic } = item;
const { isOpen, openModal, closeModal } = useModalStatus();

const { mutate: publish, isLoading: isPublishing } = usePublishItem();
const { mutate: publish, isPending: isPublishing } = usePublishItem();

const publishItem = () =>
publish({ id: itemId, notification: notifyCoEditors });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const UnpublishedButton = ({ item, isLoading }: Props): JSX.Element => {
const { id: itemId, public: isPublic } = item;
const { isOpen, openModal, closeModal } = useModalStatus();

const { mutate: validateItem, isLoading: isValidating } =
const { mutate: validateItem, isPending: isValidating } =
usePostItemValidation();

const handleValidateItem = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const ShortLinkDialogContent = ({
}: Props): JSX.Element => {
const { t: translateBuilder } = useBuilderTranslation();

const { mutateAsync: postShortLink, isLoading: loadingPost } =
const { mutateAsync: postShortLink, isPending: loadingPost } =
usePostShortLink();
const { mutateAsync: patchShortLink, isLoading: loadingDelete } =
const { mutateAsync: patchShortLink, isPending: loadingDelete } =
usePatchShortLink();

const DIALOG_TITLE = translateBuilder(
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/DownloadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const DownloadButton = ({ item }: Props): JSX.Element => {
mutate: downloadItem,
data,
isSuccess,
isLoading: isDownloading,
isPending: isDownloading,
} = mutations.useExportItem();

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/main/ImportH5P.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const ImportH5P = ({
previousItemId?: DiscriminatedItem['id'];
}): JSX.Element => {
const { itemId } = useParams();
const { mutateAsync: importH5P, isLoading } = mutations.useImportH5P();
const { mutateAsync: importH5P, isPending: isLoading } =
mutations.useImportH5P();
const { update, close: closeNotification } = useUploadWithProgress();
const { t: translateBuilder } = useBuilderTranslation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const RequestAccessContent = ({ member, itemId }: Props): JSX.Element => {
const {
mutateAsync: requestMembership,
isSuccess,
isLoading,
isPending: isLoading,
} = mutations.useRequestMembership();
const { data: request } = hooks.useOwnMembershipRequest(itemId);

Expand Down
Loading

0 comments on commit dfd7197

Please sign in to comment.