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
58e24bb8
Commit
58e24bb8
authored
Nov 03, 2022
by
isstuev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
9736d24a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
15 deletions
+19
-15
appContext.tsx
lib/appContext.tsx
+0
-0
cookies.ts
lib/cookies.ts
+3
-3
_app.tsx
pages/_app.tsx
+1
-1
UserAvatar.tsx
ui/shared/UserAvatar.tsx
+4
-8
NavigationDesktop.tsx
ui/snippets/navigation/NavigationDesktop.tsx
+11
-3
No files found.
lib/
next/AppWrapper
.tsx
→
lib/
appContext
.tsx
View file @
58e24bb8
File moved
lib/cookies.ts
View file @
58e24bb8
...
...
@@ -9,9 +9,9 @@ export enum NAMES {
TXS_SORT
=
'
txs_sort
'
,
}
export
function
get
(
name
?:
string
|
undefined
|
null
)
{
export
function
get
(
name
?:
NAMES
|
undefined
|
null
,
serverCookie
?:
string
)
{
if
(
!
isBrowser
())
{
return
undefined
;
return
serverCookie
?
getFromCookieString
(
serverCookie
,
name
)
:
undefined
;
}
return
Cookies
.
get
(
name
);
}
...
...
@@ -22,6 +22,6 @@ export function set(name: string, value: string, attributes: Types.CookieAttribu
return
Cookies
.
set
(
name
,
value
,
attributes
);
}
export
function
getFromCookieString
(
cookieString
:
string
,
name
:
NAMES
)
{
export
function
getFromCookieString
(
cookieString
:
string
,
name
?:
NAMES
|
undefined
|
null
)
{
return
cookieString
.
split
(
`
${
name
}
=`
)[
1
]?.
split
(
'
;
'
)[
0
];
}
pages/_app.tsx
View file @
58e24bb8
...
...
@@ -3,10 +3,10 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import
type
{
AppProps
}
from
'
next/app
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
{
AppWrapper
}
from
'
lib/appContext
'
;
import
{
Chakra
}
from
'
lib/Chakra
'
;
import
useConfigSentry
from
'
lib/hooks/useConfigSentry
'
;
import
type
{
ErrorType
}
from
'
lib/hooks/useFetch
'
;
import
{
AppWrapper
}
from
'
lib/next/AppWrapper
'
;
import
theme
from
'
theme
'
;
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
...
...
ui/shared/UserAvatar.tsx
View file @
58e24bb8
import
{
useColorModeValue
,
chakra
,
Box
,
Image
}
from
'
@chakra-ui/react
'
;
import
{
useColorModeValue
,
chakra
,
SkeletonCircle
,
Image
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
Identicon
from
'
react-identicons
'
;
import
type
{
UserInfo
}
from
'
types/api/account
'
;
import
{
useAppContext
}
from
'
lib/appContext
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
{
useAppContext
}
from
'
lib/next/AppWrapper
'
;
const
ProfileIcon
=
chakra
(
Identicon
);
...
...
@@ -17,17 +17,13 @@ interface Props {
const
UserAvatar
=
({
size
,
data
,
isFetched
}:
Props
)
=>
{
const
appProps
=
useAppContext
();
const
hasAuth
=
Boolean
(
cookies
.
get
FromCookieString
(
appProps
.
cookies
,
cookies
.
NAMES
.
API_TOKEN
));
const
hasAuth
=
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
,
appProps
.
cookies
));
const
sizeString
=
`
${
size
}
px`
;
const
bgColor
=
useColorModeValue
(
'
blackAlpha.100
'
,
'
white
'
);
// if (hasAuth && !isFetched) {
// }
if
(
hasAuth
&&
!
isFetched
)
{
return
<
Box
w=
{
sizeString
}
h=
{
sizeString
}
></
Box
>;
return
<
SkeletonCircle
h=
{
sizeString
}
w=
{
sizeString
}
/
>;
}
if
(
data
?.
avatar
)
{
...
...
ui/snippets/navigation/NavigationDesktop.tsx
View file @
58e24bb8
...
...
@@ -3,9 +3,9 @@ import React from 'react';
import
appConfig
from
'
configs/app/config
'
;
import
chevronIcon
from
'
icons/arrows/east-mini.svg
'
;
import
{
useAppContext
}
from
'
lib/appContext
'
;
import
*
as
cookies
from
'
lib/cookies
'
;
import
useNavItems
from
'
lib/hooks/useNavItems
'
;
import
{
useAppContext
}
from
'
lib/next/AppWrapper
'
;
import
getDefaultTransitionProps
from
'
theme/utils/getDefaultTransitionProps
'
;
import
NetworkLogo
from
'
ui/snippets/networkMenu/NetworkLogo
'
;
import
NetworkMenu
from
'
ui/snippets/networkMenu/NetworkMenu
'
;
...
...
@@ -17,8 +17,16 @@ const NavigationDesktop = () => {
const
appProps
=
useAppContext
();
const
cookiesString
=
appProps
.
cookies
;
const
isNavBarCollapsed
=
cookies
.
getFromCookieString
(
cookiesString
,
cookies
.
NAMES
.
NAV_BAR_COLLAPSED
)
===
'
true
'
;
const
hasAuth
=
Boolean
(
cookies
.
getFromCookieString
(
cookiesString
,
cookies
.
NAMES
.
API_TOKEN
));
const
isNavBarCollapsedCookie
=
cookies
.
get
(
cookies
.
NAMES
.
NAV_BAR_COLLAPSED
,
cookiesString
);
let
isNavBarCollapsed
;
if
(
isNavBarCollapsedCookie
===
'
true
'
)
{
isNavBarCollapsed
=
true
;
}
if
(
isNavBarCollapsedCookie
===
'
false
'
)
{
isNavBarCollapsed
=
false
;
}
const
hasAuth
=
Boolean
(
cookies
.
get
(
cookies
.
NAMES
.
API_TOKEN
,
cookiesString
));
const
{
mainNavItems
,
accountNavItems
}
=
useNavItems
();
...
...
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