Skip to content

Commit f65878d

Browse files
authored
Merge pull request #2757 from GetStream/attachment-picker-icons-visibility
fix: attachment picker image picker icon visibility as per dependency
2 parents 3c05a9f + d1ecfd7 commit f65878d

File tree

3 files changed

+32
-16
lines changed

3 files changed

+32
-16
lines changed

package/src/components/AttachmentPicker/components/AttachmentPickerSelectionBar.tsx

+22-14
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ export const AttachmentPickerSelectionBar = () => {
2727
setSelectedPicker,
2828
} = useAttachmentPickerContext();
2929

30-
const { hasCameraPicker, hasFilePicker, imageUploads, pickFile, takeAndUploadImage } =
31-
useMessageInputContext();
30+
const {
31+
hasCameraPicker,
32+
hasFilePicker,
33+
hasImagePicker,
34+
imageUploads,
35+
pickFile,
36+
takeAndUploadImage,
37+
} = useMessageInputContext();
3238

3339
const {
3440
theme: {
@@ -53,18 +59,20 @@ export const AttachmentPickerSelectionBar = () => {
5359

5460
return (
5561
<View style={[styles.container, container, { height: attachmentSelectionBarHeight }]}>
56-
<TouchableOpacity
57-
hitSlop={{ bottom: 15, top: 15 }}
58-
onPress={setImagePicker}
59-
testID='upload-photo-touchable'
60-
>
61-
<View style={[styles.icon, icon]}>
62-
<ImageSelectorIcon
63-
numberOfImageUploads={imageUploads.length}
64-
selectedPicker={selectedPicker}
65-
/>
66-
</View>
67-
</TouchableOpacity>
62+
{hasImagePicker ? (
63+
<TouchableOpacity
64+
hitSlop={{ bottom: 15, top: 15 }}
65+
onPress={setImagePicker}
66+
testID='upload-photo-touchable'
67+
>
68+
<View style={[styles.icon, icon]}>
69+
<ImageSelectorIcon
70+
numberOfImageUploads={imageUploads.length}
71+
selectedPicker={selectedPicker}
72+
/>
73+
</View>
74+
</TouchableOpacity>
75+
) : null}
6876
{hasFilePicker ? (
6977
<TouchableOpacity
7078
hitSlop={{ bottom: 15, top: 15 }}

package/src/components/Channel/Channel.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import {
8484
FlatList as FlatListDefault,
8585
isAudioRecorderAvailable,
8686
isDocumentPickerAvailable,
87+
isImageMediaLibraryAvailable,
8788
isImagePickerAvailable,
8889
} from '../../native';
8990
import * as dbApi from '../../store/apis';
@@ -522,7 +523,7 @@ const ChannelWithContext = <
522523
hasCommands = true,
523524
// If pickDocument isn't available, default to hiding the file picker
524525
hasFilePicker = isDocumentPickerAvailable(),
525-
hasImagePicker = true,
526+
hasImagePicker = isImagePickerAvailable() || isImageMediaLibraryAvailable(),
526527
hideDateSeparators = false,
527528
hideStickyDateHeader = false,
528529
ImageLoadingFailedIndicator = ImageLoadingFailedIndicatorDefault,

package/src/components/MessageInput/components/NativeAttachmentPicker.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const NativeAttachmentPicker = ({
3636
},
3737
} = useTheme();
3838
const {
39+
hasCameraPicker,
3940
hasFilePicker,
4041
hasImagePicker,
4142
pickAndUploadImageFromNativePicker,
@@ -115,7 +116,13 @@ export const NativeAttachmentPicker = ({
115116
if (hasFilePicker) {
116117
buttons.push({ icon: <FileSelectorIcon />, id: 'File', onPressHandler: pickFile });
117118
}
118-
buttons.push({ icon: <CameraSelectorIcon />, id: 'Camera', onPressHandler: takeAndUploadImage });
119+
if (hasCameraPicker) {
120+
buttons.push({
121+
icon: <CameraSelectorIcon />,
122+
id: 'Camera',
123+
onPressHandler: takeAndUploadImage,
124+
});
125+
}
119126

120127
return (
121128
<>

0 commit comments

Comments
 (0)