Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
[C-1006] Improve initial load, hotfix missing web worker (#1896)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers committed Sep 10, 2022
1 parent edc8433 commit f91506e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 32 deletions.
72 changes: 41 additions & 31 deletions packages/mobile/src/screens/root-screen/RootScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect, useState } from 'react'

import { accountSelectors } from '@audius/common'
import { accountSelectors, Status } from '@audius/common'
import type { DrawerContentComponentProps } from '@react-navigation/drawer'
import { createDrawerNavigator } from '@react-navigation/drawer'
// eslint-disable-next-line import/no-unresolved
Expand All @@ -24,6 +24,10 @@ import { SignOnScreen } from 'app/screens/signon'
import { UpdateRequiredScreen } from 'app/screens/update-required-screen/UpdateRequiredScreen'
import { enterBackground, enterForeground } from 'app/store/lifecycle/actions'

import { SplashScreen } from '../splash-screen'

const { getHasAccount, getAccountStatus } = accountSelectors

export type RootScreenParamList = {
signOn: undefined
App: NavigatorScreenParams<{
Expand Down Expand Up @@ -128,7 +132,8 @@ const NotificationsDrawerContents = (
*/
export const RootScreen = () => {
const dispatch = useDispatch()
const hasAccount = useSelector(accountSelectors.getHasAccount)
const hasAccount = useSelector(getHasAccount)
const accountStatus = useSelector(getAccountStatus)
const [disableGestures, setDisableGestures] = useState(false)
const { updateRequired } = useUpdateRequired()

Expand All @@ -139,33 +144,38 @@ export const RootScreen = () => {

if (updateRequired) return <UpdateStack />

return hasAccount ? (
<Drawer.Navigator
// legacy implementation uses reanimated-v1
useLegacyImplementation={true}
detachInactiveScreens={false}
screenOptions={{
drawerType: 'slide',
headerShown: false,
drawerStyle: {
width: '100%'
},
swipeEdgeWidth: SCREEN_WIDTH,
gestureHandlerProps: {
enabled: !disableGestures
}
}}
drawerContent={(props) => (
<NotificationsDrawerContents
disableGestures={disableGestures}
setDisableGestures={setDisableGestures}
{...props}
/>
)}
>
<Drawer.Screen name='App' component={MainStack} />
</Drawer.Navigator>
) : (
<SignOnStack />
)
if (accountStatus === Status.LOADING) return <SplashScreen />

if (!hasAccount) return <SignOnStack />

if (hasAccount)
return (
<Drawer.Navigator
// legacy implementation uses reanimated-v1
useLegacyImplementation={true}
detachInactiveScreens={false}
screenOptions={{
drawerType: 'slide',
headerShown: false,
drawerStyle: {
width: '100%'
},
swipeEdgeWidth: SCREEN_WIDTH,
gestureHandlerProps: {
enabled: !disableGestures
}
}}
drawerContent={(props) => (
<NotificationsDrawerContents
disableGestures={disableGestures}
setDisableGestures={setDisableGestures}
{...props}
/>
)}
>
<Drawer.Screen name='App' component={MainStack} />
</Drawer.Navigator>
)

return null
}
4 changes: 3 additions & 1 deletion packages/web/src/services/WebWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export default class WebWorker {
code()
`
])
this.worker = new Worker(URL.createObjectURL(blob))
if (typeof Worker !== 'undefined') {
this.worker = new Worker(URL.createObjectURL(blob))
}
this.terminateOnResult = terminateOnResult
}

Expand Down

0 comments on commit f91506e

Please sign in to comment.