Skip to content

Commit b0a566f

Browse files
authored
fix: change default value of audioRecordingEnabled and not rely on package availability for default value (#2884)
* fix: change default value of audioRecordingEnabled and not rely on package availability for default value * fix: tests snapshots
1 parent f7eeec8 commit b0a566f

File tree

4 files changed

+40
-56
lines changed

4 files changed

+40
-56
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ import {
8585
} from '../../icons';
8686
import {
8787
FlatList as FlatListDefault,
88-
isAudioRecorderAvailable,
8988
isDocumentPickerAvailable,
9089
isImageMediaLibraryAvailable,
9190
isImagePickerAvailable,
@@ -494,7 +493,7 @@ const ChannelWithContext = <
494493
AudioAttachment = AudioAttachmentDefault,
495494
AudioAttachmentUploadPreview = AudioAttachmentDefault,
496495
AudioRecorder = AudioRecorderDefault,
497-
audioRecordingEnabled = isAudioRecorderAvailable(),
496+
audioRecordingEnabled = false,
498497
AudioRecordingInProgress = AudioRecordingInProgressDefault,
499498
AudioRecordingLockIndicator = AudioRecordingLockIndicatorDefault,
500499
AudioRecordingPreview = AudioRecordingPreviewDefault,

package/src/components/MessageInput/MessageInput.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ import {
5656
useTranslationContext,
5757
} from '../../contexts/translationContext/TranslationContext';
5858

59-
import { isImageMediaLibraryAvailable, triggerHaptic } from '../../native';
59+
import {
60+
isAudioRecorderAvailable,
61+
isImageMediaLibraryAvailable,
62+
triggerHaptic,
63+
} from '../../native';
6064
import type { Asset, DefaultStreamChatGenerics } from '../../types/types';
6165
import { AIStates, useAIState } from '../AITypingIndicatorView';
6266
import { AutoCompleteInput } from '../AutoCompleteInput/AutoCompleteInput';
@@ -624,7 +628,7 @@ const MessageInputWithContext = <
624628
} = useAudioController();
625629

626630
const isSendingButtonVisible = () => {
627-
if (audioRecordingEnabled) {
631+
if (audioRecordingEnabled && isAudioRecorderAvailable()) {
628632
if (recording) {
629633
return false;
630634
}
@@ -856,7 +860,7 @@ const MessageInputWithContext = <
856860
</View>
857861
))
858862
)}
859-
{audioRecordingEnabled && !micLocked && (
863+
{audioRecordingEnabled && isAudioRecorderAvailable() && !micLocked && (
860864
<GestureDetector gesture={panGestureMic}>
861865
<Animated.View
862866
style={[

package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import {
88
import { useTheme } from '../../../../contexts/themeContext/ThemeContext';
99
import { useTranslationContext } from '../../../../contexts/translationContext/TranslationContext';
1010
import { Mic } from '../../../../icons/Mic';
11-
import {
12-
AudioRecordingReturnType,
13-
isAudioRecorderAvailable,
14-
triggerHaptic,
15-
} from '../../../../native';
11+
import { AudioRecordingReturnType, triggerHaptic } from '../../../../native';
1612

1713
import type { DefaultStreamChatGenerics } from '../../../../types/types';
1814

@@ -102,8 +98,6 @@ const AudioRecordingButtonWithContext = <
10298
}
10399
};
104100

105-
if (!isAudioRecorderAvailable()) return null;
106-
107101
return (
108102
<Pressable
109103
delayLongPress={asyncMessagesMinimumPressDuration}

package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,21 +2136,9 @@ exports[`Thread should match thread snapshot 1`] = `
21362136
</View>
21372137
</View>
21382138
<View
2139-
collapsable={false}
21402139
style={
21412140
[
21422141
{},
2143-
{
2144-
"opacity": undefined,
2145-
"transform": [
2146-
{
2147-
"translateX": 0,
2148-
},
2149-
{
2150-
"translateY": 0,
2151-
},
2152-
],
2153-
},
21542142
{},
21552143
]
21562144
}
@@ -2160,7 +2148,7 @@ exports[`Thread should match thread snapshot 1`] = `
21602148
{
21612149
"busy": undefined,
21622150
"checked": undefined,
2163-
"disabled": undefined,
2151+
"disabled": true,
21642152
"expanded": undefined,
21652153
"selected": undefined,
21662154
}
@@ -2187,26 +2175,16 @@ exports[`Thread should match thread snapshot 1`] = `
21872175
onStartShouldSetResponder={[Function]}
21882176
style={
21892177
[
2190-
{
2191-
"alignItems": "center",
2192-
"borderRadius": 50,
2193-
"justifyContent": "center",
2194-
},
2195-
{
2196-
"backgroundColor": "#FFFFFF",
2197-
"height": 40,
2198-
"width": 40,
2199-
},
22002178
{},
22012179
]
22022180
}
2203-
testID="audio-button"
2181+
testID="send-button"
22042182
>
22052183
<RNSVGSvgView
22062184
align="xMidYMid"
22072185
bbHeight={32}
22082186
bbWidth={32}
2209-
fill="#7A7A7A"
2187+
fill="#DBDBDB"
22102188
focusable={false}
22112189
height={32}
22122190
meetOrSlice={0}
@@ -2232,7 +2210,7 @@ exports[`Thread should match thread snapshot 1`] = `
22322210
<RNSVGGroup
22332211
fill={
22342212
{
2235-
"payload": 4286216826,
2213+
"payload": 4292598747,
22362214
"type": 0,
22372215
}
22382216
}
@@ -2242,30 +2220,39 @@ exports[`Thread should match thread snapshot 1`] = `
22422220
]
22432221
}
22442222
>
2245-
<RNSVGGroup
2223+
<RNSVGCircle
2224+
cx={16}
2225+
cy={16}
22462226
fill={
22472227
{
2248-
"payload": 4278190080,
2228+
"payload": 4292598747,
22492229
"type": 0,
22502230
}
22512231
}
2252-
name="24 / mic_iOS"
2253-
>
2254-
<RNSVGPath
2255-
d="M11.5234 13.9922C11.5234 16.8047 13.375 18.7734 16 18.7734C18.6367 18.7734 20.4766 16.8047 20.4766 13.9922V6.69141C20.4766 3.86719 18.6367 1.89844 16 1.89844C13.375 1.89844 11.5234 3.86719 11.5234 6.69141V13.9922ZM13.7383 14.0273V6.64453C13.7383 5.08594 14.6172 4.01953 16 4.01953C17.3828 4.01953 18.2617 5.08594 18.2617 6.64453V14.0273C18.2617 15.5977 17.3828 16.6523 16 16.6523C14.6172 16.6523 13.7383 15.5977 13.7383 14.0273ZM7.10547 14.5078C7.10547 19.3242 10.3047 22.6289 14.9336 23.0742V25.4766H10.6211C10.0234 25.4766 9.51953 25.9688 9.51953 26.5781C9.51953 27.1758 10.0234 27.668 10.6211 27.668H21.3789C21.9883 27.668 22.4922 27.1758 22.4922 26.5781C22.4922 25.9688 21.9883 25.4766 21.3789 25.4766H17.0781V23.0742C21.6953 22.6289 24.9062 19.3242 24.9062 14.5078V12.1875C24.9062 11.5781 24.4141 11.0977 23.8047 11.0977C23.1953 11.0977 22.6914 11.5781 22.6914 12.1875V14.4258C22.6914 18.4102 19.9961 21.0469 16 21.0469C12.0039 21.0469 9.30859 18.4102 9.30859 14.4258V12.1875C9.30859 11.5781 8.81641 11.0977 8.20703 11.0977C7.59766 11.0977 7.10547 11.5781 7.10547 12.1875V14.5078Z"
2256-
fill={
2257-
{
2258-
"payload": 4286216826,
2259-
"type": 0,
2260-
}
2261-
}
2262-
propList={
2263-
[
2264-
"fill",
2265-
]
2232+
propList={
2233+
[
2234+
"fill",
2235+
]
2236+
}
2237+
r={16}
2238+
/>
2239+
<RNSVGPath
2240+
clipRule={0}
2241+
d="M9.33398 14.6666H16.0007V9.33325L22.6673 15.9999L16.0007 22.6666V17.3333H9.33398V14.6666Z"
2242+
fill={
2243+
{
2244+
"payload": 4294967295,
2245+
"type": 0,
22662246
}
2267-
/>
2268-
</RNSVGGroup>
2247+
}
2248+
fillRule={0}
2249+
propList={
2250+
[
2251+
"fill",
2252+
"fillRule",
2253+
]
2254+
}
2255+
/>
22692256
</RNSVGGroup>
22702257
</RNSVGSvgView>
22712258
</View>

0 commit comments

Comments
 (0)