Refresh on profile with valid session
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "react",
|
||||
"private": true,
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user