Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): voice input keeps your edits, your first words, and your language #25808

Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromt3/mobile-voice-inputopened View on GitHub

Showing 7 changed files with 47 additions and 14 deletions (loading 4).

x
0 of 7 viewed, 7 left
9 additions and 13 deletionsapps/mobile/src/features/settings/components/SettingsDragHandle.tsxModified
View file
@@ -18,22 +18,18 @@
const onEnd = useEffectEvent((translation: number, cancelled: boolean) =>
props.onEnd(translation, cancelled),
);
- const [gesture] = useState(() => {
- let translation = 0;
- return Gesture.Pan()
+ // Gesture callbacks become worklets that each copy their closure, so state
+ // shared between them through a local variable never updates; the final
+ // event carries the translation instead.
+ const [gesture] = useState(() =>
+ Gesture.Pan()
.minDistance(0)
.shouldCancelWhenOutside(false)
.runOnJS(true)
- .onStart(() => {
- translation = 0;
- onStart();
- })
- .onUpdate((event) => {
- translation = event.translationY;
- onMove(event.translationY);
- })
- .onFinalize((_, success) => onEnd(translation, !success));
- });
+ .onStart(() => onStart())
+ .onUpdate((event) => onMove(event.translationY))
+ .onFinalize((event, success) => onEnd(event.translationY, !success)),
+ );
return (