Refresh on profile with valid session

This commit is contained in:
Kilian Hofmann 2024-07-30 00:24:43 +02:00
parent 45778d83d0
commit c192eeba65
6 changed files with 7 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GuestBook</title>
<script type="module" crossorigin src="/phpCourse/exam/dist/assets/index-BFREkcQ0.js"></script>
<script type="module" crossorigin src="/phpCourse/exam/dist/assets/index-Cag5GO1b.js"></script>
<link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/react-C9_qfvjK.js">
<link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/mui-BnAUJOoN.js">
<link rel="modulepreload" crossorigin href="/phpCourse/exam/dist/assets/tanstack-BqkrhB-y.js">

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "react",
"private": true,
"version": "1.1.0",
"version": "1.1.1",
"type": "module",
"scripts": {
"dev": "vite",

View File

@ -44,7 +44,7 @@ export const Route = createFileRoute(`${ROUTES.PROFILE}/$id`)({
queryClient.ensureQueryData(profileQueryOptions(Api, id));
},
beforeLoad: ({ params: { id }, context: { Api } }) => {
if (!Api.hasAuth) throw redirect({ to: ROUTES.INDEX });
if (!Api.hasAuth && !Api.currentSession[0]) throw redirect({ to: ROUTES.INDEX });
if (id === Api.authenticatedUser?.id) throw redirect({ to: ROUTES.PROFILE });
},
component: ProfilePage,

View File

@ -36,10 +36,10 @@ const ProfilePage = () => {
export const Route = createFileRoute(`${ROUTES.PROFILE}/`)({
loader: ({ context: { queryClient, Api } }) => {
queryClient.ensureQueryData(profileSelfQueryOptions(Api));
if (Api.authenticatedUser) queryClient.ensureQueryData(profileSelfQueryOptions(Api));
},
beforeLoad: ({ context: { Api } }) => {
if (!Api.hasAuth) throw redirect({ to: ROUTES.INDEX });
if (!Api.hasAuth && !Api.currentSession[0]) throw redirect({ to: ROUTES.INDEX });
},
component: ProfilePage,
});