fix: OAuth blocked loading process

This commit is contained in:
EnixCoda 2021-06-02 09:52:51 +08:00
parent 56f1d0d0f4
commit e70f31567b
No known key found for this signature in database
GPG key ID: 0C1A07377913A1DD

View file

@ -13,15 +13,8 @@ export function OAuthWrapper({ children }: React.PropsWithChildren<{}>) {
const running = useGetAccessToken()
const $state = useLoadedContext(SideBarStateContext)
const firstRenderRef = React.useRef(true)
React.useEffect(() => {
if (running) {
$state.onChange('getting-access-token')
} else if (firstRenderRef.current) {
firstRenderRef.current = false
} else {
$state.onChange('after-getting-access-token')
}
$state.onChange(running ? 'getting-access-token' : 'after-getting-access-token')
}, [running])
// block children rendering on the first render if setting token