Skip to content
TypeScript

fix(mobile): remove perpetual reconnect indicator animation (#24273)

Julius Marminge3e20b652e2dc
diff --git a/apps/mobile/src/features/connection/ConnectionStatusDot.tsx b/apps/mobile/src/features/connection/ConnectionStatusDot.tsx
index 3067296c166..e2d6bc5e3b9 100644
--- a/apps/mobile/src/features/connection/ConnectionStatusDot.tsx
+++ b/apps/mobile/src/features/connection/ConnectionStatusDot.tsx
@@ -1,13 +1,4 @@
-import { useEffect } from "react";
import { View } from "react-native";
-import Animated, {
- cancelAnimation,
- Easing,
- useAnimatedStyle,
- useSharedValue,
- withRepeat,
- withTiming,
-} from "react-native-reanimated";
import type { RemoteClientConnectionState } from "../../lib/connection";
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
@@ -50,49 +41,17 @@ function statusDotTone(
}
}
-function usePulseAnimation(pulse: boolean) {
- const pulseProgress = useSharedValue(0);
-
- useEffect(() => {
- if (pulse) {
- pulseProgress.value = withRepeat(
- withTiming(1, {
- duration: 1100,
- easing: Easing.out(Easing.cubic),
- }),
- -1,
- false,
- );
- return;
- }
-
- cancelAnimation(pulseProgress);
- pulseProgress.value = withTiming(0, {
- duration: 180,
- easing: Easing.out(Easing.quad),
- });
- }, [pulse, pulseProgress]);
-
- return pulseProgress;
-}
-
export function ConnectionStatusDot(props: {
readonly state: ConnectionStatusDotState;
readonly pulse: boolean;
readonly size?: number;
}) {
- const pulseProgress = usePulseAnimation(props.pulse);
const { themeAppearance, themeVariables } = useAppearancePreferences();
const tone = statusDotTone(props.state, themeVariables, themeAppearance === "dark");
const dotSize = props.size ?? 10;
const haloSize = dotSize + 4;
const containerSize = haloSize + 4;
- const haloStyle = useAnimatedStyle(() => ({
- opacity: props.pulse ? 0.14 + (1 - pulseProgress.value) * 0.3 : 0,
- transform: [{ scale: 0.78 + pulseProgress.value * 1.16 }],
- }));
-
return (
<View
style={{
@@ -102,18 +61,19 @@ export function ConnectionStatusDot(props: {
justifyContent: "center",
}}
>
- <Animated.View
- style={[
- haloStyle,
- {
+ {/* Looping Reanimated updates can starve React commits while commit pausing is disabled. */}
+ {props.pulse ? (
+ <View
+ style={{
position: "absolute",
width: haloSize,
height: haloSize,
borderRadius: haloSize / 2,
backgroundColor: tone.haloColor,
- },
- ]}
- />
+ opacity: 0.3,
+ }}
+ />
+ ) : null}
<View
style={{
width: dotSize,