Skip to content

Conversation

@morepriyam
Copy link
Collaborator

@morepriyam morepriyam commented Dec 26, 2025

Fix Hold Mode Gesture Handlers and Update Submodules

🐛 Problem

The hold mode recording feature was experiencing issues where it would get stuck in hold mode, preventing users from properly stopping recordings. Additionally, the codebase was using deprecated gesture handler APIs that needed to be updated to the modern Gesture API.

🔧 Changes Made

1. Migrated to New Gesture API

  • Replaced deprecated APIs:
    • PanGestureHandlerGesture.Pan()
    • PinchGestureHandlerGesture.Pinch()
    • useAnimatedGestureHandler → Direct gesture handlers with .onBegin(), .onUpdate(), .onEnd(), .onFinalize()
  • Updated imports: Changed from old gesture handler components to Gesture and GestureDetector
  • Gesture composition: Used Gesture.Simultaneous() to allow pan and pinch gestures to work together

2. Fixed Hold Mode Getting Stuck

  • Added .onFinalize() handler: Ensures cleanup happens in all scenarios (end, cancel, fail)
  • Enhanced cleanup in handleRecordingComplete: Explicitly resets screenTouchActive state
  • Added safety useEffect: Automatically resets screen touch and hold state when recording stops
  • Improved state management: Only set isHoldRecording to true for hold mode (not tap mode)
  • Enhanced RecordButton cleanup: Added hold visual feedback cleanup in finally block

3. Fixed React Native Reanimated Warnings

  • Used useDerivedValue to create listeners: Properly registers listeners for shared values updated from JS
  • Referenced all shared values in derived value: Prevents onAnimatedValueUpdate warnings for:
    • isHoldRecording
    • recordingModeShared
    • currentZoom
    • savedZoom
    • currentTouchY
    • initialTouchY

4. Updated Submodules

  • pulse-vault: Updated to latest commit (12f2ddb6)

📝 Technical Details

Before

<PanGestureHandler onGestureEvent={handleScreenPanGesture}>
  <PinchGestureHandler onGestureEvent={useAnimatedGestureHandler({...})}>
    ...
  </PinchGestureHandler>
</PanGestureHandler>

After

const panGesture = Gesture.Pan()
  .onBegin(...)
  .onUpdate(...)
  .onFinalize(...);

const pinchGesture = Gesture.Pinch()
  .onBegin(...)
  .onUpdate(...)
  .onEnd(...);

const composedGesture = Gesture.Simultaneous(panGesture, pinchGesture);

<GestureDetector gesture={composedGesture}>
  ...
</GestureDetector>

Warning Fix

// Create derived value to register listeners for all shared values
useDerivedValue(() => {
  // Reference all shared values to create listeners
  isHoldRecording.value;
  recordingModeShared.value;
  currentZoom.value;
  savedZoom.value;
  currentTouchY.value;
  initialTouchY.value;
  return 0; // Return dummy value
});

🎯 Impact

  • User Experience: Hold mode now works reliably without getting stuck
  • Code Quality: Modern gesture API usage, better error handling
  • Performance: Proper cleanup prevents memory leaks and state issues
  • Maintainability: Using current APIs reduces technical debt

Fixes issues with hold mode getting stuck and deprecated gesture handler warnings.

- Migrate from deprecated PanGestureHandler/PinchGestureHandler to new Gesture API
- Replace useAnimatedGestureHandler with Gesture.Pan() and Gesture.Pinch()
- Fix hold mode getting stuck by ensuring proper cleanup in all scenarios
- Add safety mechanisms to reset screen touch state when recording completes
- Fix onAnimatedValueUpdate warnings by using useAnimatedReaction
- Update pulse-vault submodule to latest commit
- Replace useAnimatedStyle with useDerivedValue to create listeners
- Reference all shared values in derived value to register listeners
- Prevents warnings when shared values are updated from JS
@morepriyam morepriyam merged commit 06fe7af into main Dec 26, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants