fix: prevent boot crash when transition_animation_scale setting is malformed
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+1
-6
@@ -13,12 +13,7 @@ class ExpoPlatformInfoModule : Module() {
|
||||
Function("getIsReducedMotionEnabled") {
|
||||
val resolver = appContext.reactContext?.contentResolver ?: return@Function false
|
||||
val scale = Settings.Global.getString(resolver, Settings.Global.TRANSITION_ANIMATION_SCALE) ?: return@Function false
|
||||
|
||||
try {
|
||||
return@Function scale.toFloat() == 0f
|
||||
} catch (_: Error) {
|
||||
return@Function false
|
||||
}
|
||||
return@Function scale.toFloatOrNull() == 0f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,20 @@ import {type AudioCategory} from './types'
|
||||
|
||||
const NativeModule = requireNativeModule('ExpoPlatformInfo')
|
||||
|
||||
/**
|
||||
* Whether the user has enabled reduced motion at the OS level.
|
||||
*
|
||||
* This is called at module scope during boot via src/state/persisted/schema.ts,
|
||||
* so a rejected native call would crash the app on startup. We catch any native
|
||||
* failure and fall back to false to keep boot safe. See Sentry issue APP-T2EW,
|
||||
* where a malformed TRANSITION_ANIMATION_SCALE setting threw at startup.
|
||||
*/
|
||||
export function getIsReducedMotionEnabled(): boolean {
|
||||
return NativeModule.getIsReducedMotionEnabled()
|
||||
try {
|
||||
return NativeModule.getIsReducedMotionEnabled()
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
export function setAudioActive(active: boolean): void {
|
||||
|
||||
Reference in New Issue
Block a user