Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attachment picker image picker icon visibility as per dependency #2757

Merged
merged 1 commit into from
Nov 5, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ export const AttachmentPickerSelectionBar = () => {
setSelectedPicker,
} = useAttachmentPickerContext();

const { hasCameraPicker, hasFilePicker, imageUploads, pickFile, takeAndUploadImage } =
useMessageInputContext();
const {
hasCameraPicker,
hasFilePicker,
hasImagePicker,
imageUploads,
pickFile,
takeAndUploadImage,
} = useMessageInputContext();

const {
theme: {
Expand All @@ -53,18 +59,20 @@ export const AttachmentPickerSelectionBar = () => {

return (
<View style={[styles.container, container, { height: attachmentSelectionBarHeight }]}>
<TouchableOpacity
hitSlop={{ bottom: 15, top: 15 }}
onPress={setImagePicker}
testID='upload-photo-touchable'
>
<View style={[styles.icon, icon]}>
<ImageSelectorIcon
numberOfImageUploads={imageUploads.length}
selectedPicker={selectedPicker}
/>
</View>
</TouchableOpacity>
{hasImagePicker ? (
<TouchableOpacity
hitSlop={{ bottom: 15, top: 15 }}
onPress={setImagePicker}
testID='upload-photo-touchable'
>
<View style={[styles.icon, icon]}>
<ImageSelectorIcon
numberOfImageUploads={imageUploads.length}
selectedPicker={selectedPicker}
/>
</View>
</TouchableOpacity>
) : null}
{hasFilePicker ? (
<TouchableOpacity
hitSlop={{ bottom: 15, top: 15 }}
Expand Down
3 changes: 2 additions & 1 deletion package/src/components/Channel/Channel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import {
FlatList as FlatListDefault,
isAudioRecorderAvailable,
isDocumentPickerAvailable,
isImageMediaLibraryAvailable,
isImagePickerAvailable,
} from '../../native';
import * as dbApi from '../../store/apis';
Expand Down Expand Up @@ -522,7 +523,7 @@ const ChannelWithContext = <
hasCommands = true,
// If pickDocument isn't available, default to hiding the file picker
hasFilePicker = isDocumentPickerAvailable(),
hasImagePicker = true,
hasImagePicker = isImagePickerAvailable() || isImageMediaLibraryAvailable(),
hideDateSeparators = false,
hideStickyDateHeader = false,
ImageLoadingFailedIndicator = ImageLoadingFailedIndicatorDefault,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const NativeAttachmentPicker = ({
},
} = useTheme();
const {
hasCameraPicker,
hasFilePicker,
hasImagePicker,
pickAndUploadImageFromNativePicker,
Expand Down Expand Up @@ -115,7 +116,13 @@ export const NativeAttachmentPicker = ({
if (hasFilePicker) {
buttons.push({ icon: <FileSelectorIcon />, id: 'File', onPressHandler: pickFile });
}
buttons.push({ icon: <CameraSelectorIcon />, id: 'Camera', onPressHandler: takeAndUploadImage });
if (hasCameraPicker) {
buttons.push({
icon: <CameraSelectorIcon />,
id: 'Camera',
onPressHandler: takeAndUploadImage,
});
}

return (
<>
Expand Down
Loading