Skip to content

Commit

Permalink
feat: Upgrade react-native-bootsplash
Browse files Browse the repository at this point in the history
`react-native-bootsplash` has been upgraded to retrieve a fix that
ensures the `show` and `hide` methods always resolve their promises

Related PR: cozy/react-native-bootsplash#4
  • Loading branch information
Ldoppea committed Feb 29, 2024
1 parent eee3901 commit 8ade758
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"react-native-background-geolocation": "^4.13.3",
"react-native-background-upload": "^6.6.0",
"react-native-biometrics": "3.0.1",
"react-native-bootsplash": "github:cozy/react-native-bootsplash#0.0.2",
"react-native-bootsplash": "github:cozy/react-native-bootsplash#0.0.3",
"react-native-change-icon": "^4.0.0",
"react-native-config": "1.5.0",
"react-native-device-info": "^10.3.0",
Expand Down
22 changes: 15 additions & 7 deletions src/app/theme/SplashScreenService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { AppState } from 'react-native'
import RNBootSplash, { VisibilityStatus } from 'react-native-bootsplash'
import RNBootSplash, {
ResultStatus,
VisibilityStatus
} from 'react-native-bootsplash'

import Minilog from 'cozy-minilog'

Expand Down Expand Up @@ -65,8 +68,10 @@ export const showSplashScreen = async (
setTimeoutForSplashScreen(bootsplashName)

try {
await RNBootSplash.show({ fade: true, bootsplashName })
return splashScreenLogger.info(`Splash screen shown "${bootsplashName}"`)
const result = await RNBootSplash.show({ fade: true, bootsplashName })
splashScreenLogger.info(
`Splash screen shown "${bootsplashName}" (${result.toString()})`
)
} catch (error) {
splashScreenLogger.error(
`Error showing splash screen: ${bootsplashName}`,
Expand Down Expand Up @@ -96,8 +101,10 @@ export const hideSplashScreen = async (
)

try {
await manageTimersAndHideSplashScreen(bootsplashName)
return splashScreenLogger.info(`Splash screen hidden "${bootsplashName}"`)
const result = await manageTimersAndHideSplashScreen(bootsplashName)
splashScreenLogger.info(
`Splash screen hidden "${bootsplashName}" (${result.toString()})`
)
} catch (error) {
splashScreenLogger.error(
`Error hiding splash screen: ${bootsplashName}`,
Expand Down Expand Up @@ -143,18 +150,19 @@ export const setTimeoutForSplashScreen = (
const manageTimersAndHideSplashScreen = async (
bootsplashName: SplashScreenEnum | undefined = splashScreens.GLOBAL,
fromTimeout = false
): Promise<void> => {
): Promise<ResultStatus> => {
if (bootsplashName !== splashScreens.SECURE_BACKGROUND)
destroyTimer(bootsplashName, fromTimeout)

try {
await RNBootSplash.hide({ fade: true, bootsplashName })
return await RNBootSplash.hide({ fade: true, bootsplashName })
} catch (error) {
splashScreenLogger.error(
`Error managing timers and hiding splash screen "${bootsplashName}"`,
error
)
logToSentry(error)
return false
}
}

Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16332,9 +16332,9 @@ [email protected]:
resolved "https://registry.yarnpkg.com/react-native-biometrics/-/react-native-biometrics-3.0.1.tgz#23c5a0bdbae1fcb1e08b22936223fe0fc4af846e"
integrity sha512-Ru80gXRa9KG04sl5AB9HyjLjVbduhqZVjA+AiOSGqr+fNqCDmCu9y5WEksnjbnniNLmq1yGcw+qcLXmR1ddLDQ==

"react-native-bootsplash@github:cozy/react-native-bootsplash#0.0.2":
"react-native-bootsplash@github:cozy/react-native-bootsplash#0.0.3":
version "3.2.4"
resolved "https://codeload.github.com/cozy/react-native-bootsplash/tar.gz/f5eb7d6fd628d27f61cc6df2e69d20b0b6960ebe"
resolved "https://codeload.github.com/cozy/react-native-bootsplash/tar.gz/bb60ff4b00d665324d24b8d15c2ed4aceefb99ea"
dependencies:
chalk "^4.1.0"
fs-extra "^9.1.0"
Expand Down

0 comments on commit 8ade758

Please sign in to comment.