Skip to content

Commit 65df210

Browse files
fix(mobile): keep reduced-motion scrolling current
1 parent 816c386 commit 65df210

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,19 +659,22 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
659659
[userInputCoverageApplies],
660660
);
661661
const { freeze, scrollMessageToEnd } = useKeyboardScrollToEnd({ listRef });
662-
// Read when a scroll starts; the listener keeps it current if the user
663-
// changes Reduce Motion while the thread is open.
662+
// Avoid animating until the system preference is known.
664663
const reduceMotionRef = useRef(true);
665664
useEffect(() => {
666665
// A change event or cleanup makes a still-pending initial query stale.
667666
let superseded = false;
668-
void AccessibilityInfo.isReduceMotionEnabled().then((enabled) => {
669-
if (!superseded) reduceMotionRef.current = enabled;
670-
});
671667
const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", (enabled) => {
672668
superseded = true;
673669
reduceMotionRef.current = enabled;
674670
});
671+
void AccessibilityInfo.isReduceMotionEnabled()
672+
.then((enabled) => {
673+
if (!superseded) reduceMotionRef.current = enabled;
674+
})
675+
.catch(() => {
676+
// Keep the current preference if the native query fails.
677+
});
675678
return () => {
676679
superseded = true;
677680
subscription.remove();

0 commit comments

Comments
 (0)