mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
fix: skip access token related state if not necessary
This commit is contained in:
parent
95a2efb6ac
commit
a6884b981d
1 changed files with 8 additions and 1 deletions
|
|
@ -13,8 +13,15 @@ export function OAuthWrapper({ children }: React.PropsWithChildren<{}>) {
|
|||
const running = useGetAccessToken()
|
||||
const $state = useLoadedContext(SideBarStateContext)
|
||||
|
||||
const firstRenderRef = React.useRef(true)
|
||||
React.useEffect(() => {
|
||||
$state.onChange(running ? 'getting-access-token' : 'after-getting-access-token')
|
||||
if (running) {
|
||||
$state.onChange('getting-access-token')
|
||||
} else if (firstRenderRef.current) {
|
||||
firstRenderRef.current = false
|
||||
} else {
|
||||
$state.onChange('after-getting-access-token')
|
||||
}
|
||||
}, [running])
|
||||
|
||||
// block children rendering on the first render if setting token
|
||||
|
|
|
|||
Loading…
Reference in a new issue