Skip to content

Commit 3e20b65

Browse files
fix(mobile): remove perpetual reconnect indicator animation (pingdotgg#24273)
1 parent 17dc1af commit 3e20b65

1 file changed

Lines changed: 8 additions & 48 deletions

File tree

‎apps/mobile/src/features/connection/ConnectionStatusDot.tsx‎

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
import { useEffect } from "react";
21
import { View } from "react-native";
3-
import Animated, {
4-
cancelAnimation,
5-
Easing,
6-
useAnimatedStyle,
7-
useSharedValue,
8-
withRepeat,
9-
withTiming,
10-
} from "react-native-reanimated";
112

123
import type { RemoteClientConnectionState } from "../../lib/connection";
134
import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
@@ -50,49 +41,17 @@ function statusDotTone(
5041
}
5142
}
5243

53-
function usePulseAnimation(pulse: boolean) {
54-
const pulseProgress = useSharedValue(0);
55-
56-
useEffect(() => {
57-
if (pulse) {
58-
pulseProgress.value = withRepeat(
59-
withTiming(1, {
60-
duration: 1100,
61-
easing: Easing.out(Easing.cubic),
62-
}),
63-
-1,
64-
false,
65-
);
66-
return;
67-
}
68-
69-
cancelAnimation(pulseProgress);
70-
pulseProgress.value = withTiming(0, {
71-
duration: 180,
72-
easing: Easing.out(Easing.quad),
73-
});
74-
}, [pulse, pulseProgress]);
75-
76-
return pulseProgress;
77-
}
78-
7944
export function ConnectionStatusDot(props: {
8045
readonly state: ConnectionStatusDotState;
8146
readonly pulse: boolean;
8247
readonly size?: number;
8348
}) {
84-
const pulseProgress = usePulseAnimation(props.pulse);
8549
const { themeAppearance, themeVariables } = useAppearancePreferences();
8650
const tone = statusDotTone(props.state, themeVariables, themeAppearance === "dark");
8751
const dotSize = props.size ?? 10;
8852
const haloSize = dotSize + 4;
8953
const containerSize = haloSize + 4;
9054

91-
const haloStyle = useAnimatedStyle(() => ({
92-
opacity: props.pulse ? 0.14 + (1 - pulseProgress.value) * 0.3 : 0,
93-
transform: [{ scale: 0.78 + pulseProgress.value * 1.16 }],
94-
}));
95-
9655
return (
9756
<View
9857
style={{
@@ -102,18 +61,19 @@ export function ConnectionStatusDot(props: {
10261
justifyContent: "center",
10362
}}
10463
>
105-
<Animated.View
106-
style={[
107-
haloStyle,
108-
{
64+
{/* Looping Reanimated updates can starve React commits while commit pausing is disabled. */}
65+
{props.pulse ? (
66+
<View
67+
style={{
10968
position: "absolute",
11069
width: haloSize,
11170
height: haloSize,
11271
borderRadius: haloSize / 2,
11372
backgroundColor: tone.haloColor,
114-
},
115-
]}
116-
/>
73+
opacity: 0.3,
74+
}}
75+
/>
76+
) : null}
11777
<View
11878
style={{
11979
width: dotSize,

0 commit comments

Comments
 (0)