Skip to content

Commit

Permalink
Conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
youssef-lr committed Aug 15, 2023
1 parent a2a2012 commit c802b8c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 169 deletions.
166 changes: 0 additions & 166 deletions src/components/AttachmentView.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ const propTypes = {
...withLocalizePropTypes,
};

function AttachmentViewImage({source, file, isAuthTokenRequired, loadComplete, onPress, isImage, onScaleChanged, translate}) {
function AttachmentViewImage({source, file, isAuthTokenRequired, loadComplete, onPress, onError, isImage, onScaleChanged, translate}) {
const children = (
<ImageView
onScaleChanged={onScaleChanged}
url={source}
fileName={file.name}
isAuthTokenRequired={isImage && isAuthTokenRequired}
onError={onError}
/>
);
return onPress ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const propTypes = {
...withLocalizePropTypes,
};

function AttachmentViewImage({source, file, isAuthTokenRequired, isFocused, isUsedInCarousel, loadComplete, onPress, isImage, onScaleChanged, translate}) {
function AttachmentViewImage({source, file, isAuthTokenRequired, isFocused, isUsedInCarousel, loadComplete, onPress, onError, isImage, onScaleChanged, translate}) {
const children = isUsedInCarousel ? (
<AttachmentCarouselPage
source={source}
Expand All @@ -26,6 +26,7 @@ function AttachmentViewImage({source, file, isAuthTokenRequired, isFocused, isUs
onScaleChanged={onScaleChanged}
url={source}
fileName={file.name}
onError={onError}
isAuthTokenRequired={isImage && isAuthTokenRequired}
/>
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/Attachments/AttachmentView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function AttachmentView({
isFocused,
}) {
const [loadComplete, setLoadComplete] = useState(false);
const [isValidImage, setIsValidImage] = useState(true);

// Handles case where source is a component (ex: SVG)
if (_.isFunction(source)) {
Expand Down Expand Up @@ -95,7 +96,7 @@ function AttachmentView({
// For this check we use both source and file.name since temporary file source is a blob
// both PDFs and images will appear as images when pasted into the the text field
const isImage = Str.isImage(source);
if (isImage || (file && Str.isImage(file.name))) {
if ((isImage || (file && Str.isImage(file.name))) && isValidImage) {
return (
<AttachmentViewImage
source={source}
Expand All @@ -105,6 +106,7 @@ function AttachmentView({
loadComplete={loadComplete}
isFocused={isFocused}
isImage={isImage}
onError={() => setIsValidImage(false)}
onPress={onPress}
onScaleChanged={onScaleChanged}
/>
Expand Down

0 comments on commit c802b8c

Please sign in to comment.