Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
c84e7ac1
Commit
c84e7ac1
authored
Oct 21, 2022
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disable profile fetch if there is no auth cookie
parent
71f45d05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
useFetchProfileInfo.tsx
lib/hooks/useFetchProfileInfo.tsx
+2
-0
Page.tsx
ui/shared/Page/Page.tsx
+4
-1
No files found.
lib/hooks/useFetchProfileInfo.tsx
View file @
c84e7ac1
...
@@ -3,6 +3,7 @@ import { useQuery } from '@tanstack/react-query';
...
@@ -3,6 +3,7 @@ import { useQuery } from '@tanstack/react-query';
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
interface
Error
{
interface
Error
{
...
@@ -19,5 +20,6 @@ export default function useFetchProfileInfo() {
...
@@ -19,5 +20,6 @@ export default function useFetchProfileInfo() {
return
fetch
(
'
/api/account/profile
'
);
return
fetch
(
'
/api/account/profile
'
);
},
{
},
{
refetchOnMount
:
false
,
refetchOnMount
:
false
,
enabled
:
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
)),
});
});
}
}
ui/shared/Page/Page.tsx
View file @
c84e7ac1
...
@@ -4,6 +4,7 @@ import React from 'react';
...
@@ -4,6 +4,7 @@ import React from 'react';
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
{
QueryKeys
}
from
'
types/client/queries
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
useFetch
from
'
lib/hooks/useFetch
'
;
import
PageContent
from
'
ui/shared/Page/PageContent
'
;
import
PageContent
from
'
ui/shared/Page/PageContent
'
;
import
Header
from
'
ui/snippets/header/Header
'
;
import
Header
from
'
ui/snippets/header/Header
'
;
...
@@ -17,7 +18,9 @@ interface Props {
...
@@ -17,7 +18,9 @@ interface Props {
const
Page
=
({
children
,
wrapChildren
=
true
}:
Props
)
=>
{
const
Page
=
({
children
,
wrapChildren
=
true
}:
Props
)
=>
{
const
fetch
=
useFetch
();
const
fetch
=
useFetch
();
useQuery
<
unknown
,
unknown
,
unknown
>
([
QueryKeys
.
csrf
],
async
()
=>
await
fetch
(
'
/api/account/csrf
'
));
useQuery
<
unknown
,
unknown
,
unknown
>
([
QueryKeys
.
csrf
],
async
()
=>
await
fetch
(
'
/api/account/csrf
'
),
{
enabled
:
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
)),
});
const
renderedChildren
=
wrapChildren
?
(
const
renderedChildren
=
wrapChildren
?
(
<
PageContent
>
{
children
}
</
PageContent
>
<
PageContent
>
{
children
}
</
PageContent
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment