Profile does not retry

This commit is contained in:
2024-07-29 23:27:18 +02:00
parent 9cb34839ec
commit 386472e680
9 changed files with 29 additions and 15 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "react",
"private": true,
"version": "1.0.0",
"version": "1.0.1",
"type": "module",
"scripts": {
"dev": "vite",
@@ -13,7 +13,7 @@ import {
import { useForm } from '@tanstack/react-form';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { t } from 'i18next';
import { FC, FormEvent, useState } from 'react';
import { FC, FormEvent, useEffect, useState } from 'react';
import { useApi } from '../../../api/Api';
import { PostAuth, PostUpdate } from '../../../types/Post';
import ErrorComponent from '../../Error/ErrorComponent';
@@ -71,6 +71,10 @@ const PostEditDialog: FC<Props> = ({ post, open, onClose }) => {
onClose();
};
useEffect(() => {
if (!Api.hasAuth) handleClose();
}, [Api.hasAuth]); //eslint-disable-line react-hooks/exhaustive-deps
return (
<Dialog
open={open}
@@ -12,7 +12,7 @@ import {
import { useForm } from '@tanstack/react-form';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { t } from 'i18next';
import { FC, FormEvent, useState } from 'react';
import { FC, FormEvent, useEffect, useState } from 'react';
import { useApi } from '../../../api/Api';
import { User, UserUpdate } from '../../../types/User';
import ErrorComponent from '../../Error/ErrorComponent';
@@ -71,6 +71,10 @@ const UserEditDialog: FC<Props> = ({ user, open, onClose }) => {
onClose();
};
useEffect(() => {
if (!Api.hasAuth) handleClose();
}, [Api.hasAuth]); //eslint-disable-line react-hooks/exhaustive-deps
return (
<Dialog
open={open}
@@ -23,7 +23,7 @@ import {
import { useForm } from '@tanstack/react-form';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { t } from 'i18next';
import { FC, FormEvent, useState } from 'react';
import { FC, FormEvent, useEffect, useState } from 'react';
import { useApi } from '../../../api/Api';
import { User, UserImageUpdate } from '../../../types/User';
import ErrorComponent from '../../Error/ErrorComponent';
@@ -79,6 +79,10 @@ const UserImageDialog: FC<Props> = ({ user, open, onClose }) => {
onClose();
};
useEffect(() => {
if (!Api.hasAuth) handleClose();
}, [Api.hasAuth]); //eslint-disable-line react-hooks/exhaustive-deps
return (
<Dialog
open={open}
+2
View File
@@ -8,10 +8,12 @@ export const profileSelfQueryOptions = (Api: ReturnType<typeof useApi>) =>
user: await Api.user(),
posts: await Api.userPosts(Api.authenticatedUser?.id ?? 0),
}),
retry: false,
});
export const profileQueryOptions = (Api: ReturnType<typeof useApi>, id?: number) =>
queryOptions({
queryKey: ['profile', { id }],
queryFn: async () => ({ user: await Api.user(id), posts: await Api.userPosts(id) }),
retry: false,
});