Skip to content

Commit c4e21f4

Browse files
cristipavalOSBotify
authored andcommitted
Merge pull request #92048 from Expensify/revert-90925-fix/broken-image-download-button-flash
Revert "fix: prevent download button flash when opening broken image attachment" (cherry picked from commit fd3907d) (cherry-picked to staging by cristipaval)
1 parent 78de283 commit c4e21f4

3 files changed

Lines changed: 3 additions & 13 deletions

File tree

src/libs/tryResolveUrlFromApiRoot.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type {ImageSourcePropType} from 'react-native';
22
import Config from '@src/CONFIG';
33
import type {ReceiptSource} from '@src/types/onyx/Transaction';
4-
import proxyConfig from '../../config/proxyConfig';
54
import {getApiRoot} from './ApiUtils';
65

76
// Absolute URLs (`/` or `//`) should be resolved from API ROOT
@@ -30,13 +29,6 @@ function tryResolveUrlFromApiRoot(url: string | ImageSourcePropType | ReceiptSou
3029
return url;
3130
}
3231
const apiRoot = getApiRoot({shouldUseSecure: false});
33-
34-
// When using the staging web proxy, the URL might already include the `/staging/` proxy path.
35-
// In that case, do not replace the leading `/` again, as it would create `/staging/staging/...`.
36-
if (apiRoot === proxyConfig.STAGING && url.startsWith(apiRoot)) {
37-
return url;
38-
}
39-
4032
return url.replace(ORIGIN_PATTERN, apiRoot);
4133
}
4234

src/pages/media/AttachmentModalScreen/AttachmentModalBaseContent/AttachmentStateContextProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function AttachmentStateContextProvider({children}: Props) {
4747
setAttachmentLoadedState({});
4848
}, []);
4949

50-
const isAttachmentLoaded = useCallback((key: AttachmentSource) => attachmentLoaded?.[convertSourceToString(key)] === true, [attachmentLoaded]);
50+
const isAttachmentLoaded = useCallback((key: AttachmentSource) => attachmentLoaded?.[convertSourceToString(key)] !== false, [attachmentLoaded]);
5151
const value = useMemo(() => ({setAttachmentLoaded, clearAttachmentLoaded, isAttachmentLoaded}), [setAttachmentLoaded, clearAttachmentLoaded, isAttachmentLoaded]);
5252
return <AttachmentStateContext.Provider value={value}>{children}</AttachmentStateContext.Provider>;
5353
}

src/pages/media/AttachmentModalScreen/AttachmentModalBaseContent/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import ActivityIndicator from '@components/ActivityIndicator';
66
import AttachmentCarousel from '@components/Attachments/AttachmentCarousel';
77
import {AttachmentCarouselPagerActionsContext, AttachmentCarouselPagerStateContext} from '@components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext';
88
import type {AttachmentCarouselPagerActionsContextType, AttachmentCarouselPagerStateContextType} from '@components/Attachments/AttachmentCarousel/Pager/types';
9-
import AttachmentView, {checkIsFileImage} from '@components/Attachments/AttachmentView';
9+
import AttachmentView from '@components/Attachments/AttachmentView';
1010
import useAttachmentErrors from '@components/Attachments/AttachmentView/useAttachmentErrors';
1111
import type {Attachment} from '@components/Attachments/types';
1212
import BlockingView from '@components/BlockingViews/BlockingView';
@@ -188,19 +188,17 @@ function AttachmentModalBaseContent({
188188

189189
const {isAttachmentLoaded} = useContext(AttachmentStateContext);
190190
const isEReceipt = transaction && !hasReceiptSource(transaction) && hasEReceipt(transaction);
191-
const isFileImage = typeof source !== 'function' && checkIsFileImage(source, fileToDisplay?.name);
192191
const shouldShowDownloadButton = useMemo(() => {
193192
const isValidContext = !isEmptyObject(report) || type === CONST.ATTACHMENT_TYPE.SEARCH || shouldAllowDownloadOutsideReportContext;
194193
if (!isValidContext || isErrorInAttachment(source) || isEReceipt) {
195194
return false;
196195
}
197196

198-
return !!onDownloadAttachment && isDownloadButtonReadyToBeShown && !shouldShowNotFoundPage && !isOffline && !isLocalSource && (!isFileImage || isAttachmentLoaded?.(source));
197+
return !!onDownloadAttachment && isDownloadButtonReadyToBeShown && !shouldShowNotFoundPage && !isOffline && !isLocalSource && isAttachmentLoaded?.(source);
199198
}, [
200199
isAttachmentLoaded,
201200
isDownloadButtonReadyToBeShown,
202201
isErrorInAttachment,
203-
isFileImage,
204202
isLocalSource,
205203
isOffline,
206204
onDownloadAttachment,

0 commit comments

Comments
 (0)