Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const audio = state.chat2.audioRecording.get(conversationIDKey)
if (!audio) {
logger.info('stopAudioRecording: no audio record, not sending')
return false
}
if (
audio.status === Types.AudioRecordingStatus.CANCELLED ||
action.payload.stopType === Types.AudioStopType.CANCEL
) {
logger.info('stopAudioRecording: recording cancelled, bailing out')
await RPCChatTypes.localCancelUploadTempFileRpcPromise({outboxID: audio.outboxID})
return false
}
if (ChatConstants.audioRecordingDuration(audio) < 500 || audio.path.length === 0) {
logger.info('stopAudioRecording: recording too short, skipping')
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error)
return Chat2Gen.createStopAudioRecording({conversationIDKey, stopType: Types.AudioStopType.CANCEL})
}
if (audio.status === Types.AudioRecordingStatus.STAGED) {
logger.info('stopAudioRecording: in staged mode, not sending')
return false
}
return Chat2Gen.createSendAudioRecording({conversationIDKey, fromStaged: false, info: audio})
}
const onSendAudioRecording = (action: Chat2Gen.SendAudioRecordingPayload) => {
if (!action.payload.fromStaged) {
if (isIOS) {
Haptics.notificationAsync(Haptics.NotificationFeedbackType.Success)
} else {
Vibration.vibrate(50)
}
}
}
notification: type => {
if (Platform.OS !== "ios") {
return;
}
Haptic.notificationAsync(type);
},
selection: () => {