Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions shared/chat/audio/audio-recorder.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import logger from '@/logger'
import * as Haptics from 'expo-haptics'
import * as FileSystem from 'expo-file-system'
import AudioSend from './audio-send.native'
import {scheduleOnRN} from 'react-native-worklets'

const {useSharedValue, Extrapolation, useAnimatedStyle} = Reanimated
const {interpolate, withSequence, withSpring, runOnJS} = Reanimated
const {interpolate, withSequence, withSpring} = Reanimated
const {useAnimatedReaction, withDelay, withTiming, interpolateColor, default: Animated} = Reanimated
type SVN = Reanimated.SharedValue<number>

Expand Down Expand Up @@ -80,7 +81,7 @@ const useTooltip = () => {

const flashTip = React.useCallback(() => {
'worklet'
runOnJS(setShowTooltip)(true)
scheduleOnRN(setShowTooltip, true)
}, [setShowTooltip])

return {flashTip, tooltip}
Expand Down Expand Up @@ -113,11 +114,11 @@ const useIconAndOverlay = (p: {
if (f === 0) {
if (fadeSyncedSV.value !== 0) {
fadeSyncedSV.set(0)
runOnJS(setVisible)(Visible.HIDDEN)
scheduleOnRN(setVisible, Visible.HIDDEN)
}
} else if (fadeSyncedSV.value !== 1) {
fadeSyncedSV.set(1)
runOnJS(setVisible)(Visible.SHOW)
scheduleOnRN(setVisible, Visible.SHOW)
}
}
)
Expand Down Expand Up @@ -192,7 +193,7 @@ const useIconAndOverlay = (p: {
.maxPointers(1)
.onTouchesDown(() => {
'worklet'
runOnJS(setupOverlayTimeout)()
scheduleOnRN(setupOverlayTimeout)
if (!panStartSV.value) {
panStartSV.set(Date.now())
}
Expand All @@ -202,22 +203,22 @@ const useIconAndOverlay = (p: {
const diff = Date.now() - panStartSV.value
startedSV.set(0)
panStartSV.set(0)
runOnJS(cleanupOverlayTimeout)()
scheduleOnRN(cleanupOverlayTimeout)
const needTip = diff < 200
const wasCancel = canceledSV.value === 1
const panLocked = lockedSV.value === 1
if (wasCancel) {
runOnJS(onCancelRecording)()
scheduleOnRN(onCancelRecording)
return
}

if (needTip) {
runOnJS(onFlashTip)()
scheduleOnRN(onFlashTip)
return
}

if (!panLocked) {
runOnJS(sendRecording)()
scheduleOnRN(sendRecording)
onReset()
fadeSV.set(withTiming(0, {duration: 200}))
}
Expand Down
6 changes: 4 additions & 2 deletions shared/common-adapters/zoomable-image.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import * as Styles from '@/styles'
import * as React from 'react'
import Image2 from './image2.native'
import {View, type LayoutChangeEvent} from 'react-native'
import {useSharedValue, runOnJS} from 'react-native-reanimated'
import {useSharedValue} from 'react-native-reanimated'
import {scheduleOnRN} from 'react-native-worklets'
import {
fitContainer,
ResumableZoom,
Expand Down Expand Up @@ -37,12 +38,13 @@ const ZoomableImage = React.memo(function ZoomableImage(p: Props) {
x: left,
y: top,
}
runOnJS(onZoom)(z)
scheduleOnRN(onZoom, z)
}
},
[currentZoomSV, onZoom, resolution]
)

// not a worklet
const onSwipe = React.useCallback(
(dir: SwipeDirection) => {
if (Math.abs(currentZoomSV.get() - 1) < 0.1) {
Expand Down
Loading