Skip to content

Commit 5c27729

Browse files
authored
Merge pull request Expensify#72347 from samranahm/71598/check-isUploaded
fix: Prevent previewing large files before upload and show appropriate message
2 parents cc145d6 + ced20d4 commit 5c27729

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

src/components/AnchorForAttachmentsOnly/BaseAnchorForAttachmentsOnly.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {isArchivedNonExpenseReport} from '@libs/ReportUtils';
1212
import {setDownload} from '@userActions/Download';
1313
import CONST from '@src/CONST';
1414
import ONYXKEYS from '@src/ONYXKEYS';
15+
import {isEmptyObject} from '@src/types/utils/EmptyObject';
1516
import type AnchorForAttachmentsOnlyProps from './types';
1617

1718
type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps & {
@@ -66,6 +67,7 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', onP
6667
isDeleted={!!isDeleted}
6768
isUploading={!sourceID}
6869
isAuthTokenRequired={!!sourceID}
70+
isUploaded={!isEmptyObject(report)}
6971
/>
7072
</PressableWithoutFeedback>
7173
)}

src/components/Attachments/AttachmentCarousel/CarouselItem.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeed
99
import SafeAreaConsumer from '@components/SafeAreaConsumer';
1010
import Text from '@components/Text';
1111
import useLocalize from '@hooks/useLocalize';
12+
import useOnyx from '@hooks/useOnyx';
1213
import useThemeStyles from '@hooks/useThemeStyles';
1314
import AttachmentModalContext from '@pages/media/AttachmentModalScreen/AttachmentModalContext';
1415
import CONST from '@src/CONST';
16+
import ONYXKEYS from '@src/ONYXKEYS';
17+
import {isEmptyObject} from '@src/types/utils/EmptyObject';
1518

1619
type CarouselItemProps = {
1720
/** Attachment required information such as the source and file name */
@@ -35,6 +38,7 @@ function CarouselItem({item, onPress, isFocused, isModalHovered, reportID}: Caro
3538
const {translate} = useLocalize();
3639
const {isAttachmentHidden} = useContext(AttachmentModalContext);
3740
const [isHidden, setIsHidden] = useState(() => (item.reportActionID && isAttachmentHidden(item.reportActionID)) ?? item.hasBeenFlagged);
41+
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {canBeMissing: true});
3842

3943
const renderButton = (style: StyleProp<ViewStyle>) => (
4044
<Button
@@ -90,6 +94,7 @@ function CarouselItem({item, onPress, isFocused, isModalHovered, reportID}: Caro
9094
duration={item.duration}
9195
fallbackSource={Expensicons.AttachmentNotFound}
9296
reportID={reportID}
97+
isUploaded={!isEmptyObject(report)}
9398
/>
9499
</View>
95100

src/components/Attachments/AttachmentView/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function AttachmentView({
299299
if (!isUploaded) {
300300
return (
301301
<>
302-
<View style={styles.imageModalImageCenterContainer}>
302+
<View style={[styles.imageModalImageCenterContainer, styles.ph10]}>
303303
<DefaultAttachmentView
304304
icon={Gallery}
305305
fileName={file?.name}

src/styles/utils/getHighResolutionInfoWrapperStyle/index.native.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type GetHighResolutionInfoWrapperStyle from './types';
55
const getHighResolutionInfoWrapperStyle: GetHighResolutionInfoWrapperStyle = (isUploaded) => ({
66
...spacing.ph8,
77
...spacing.pt5,
8-
...(isUploaded ? spacing.pb5 : spacing.mbn1),
8+
...(isUploaded ? spacing.pb5 : spacing.pb1),
99
});
1010

1111
export default getHighResolutionInfoWrapperStyle;

src/styles/utils/getHighResolutionInfoWrapperStyle/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type GetHighResolutionInfoWrapperStyle from './types';
55
const getHighResolutionInfoWrapperStyle: GetHighResolutionInfoWrapperStyle = (isUploaded) => ({
66
...spacing.ph5,
77
...spacing.pt5,
8-
...(isUploaded ? spacing.pb5 : spacing.mbn1),
8+
...(isUploaded ? spacing.pb5 : spacing.pb1),
99
});
1010

1111
export default getHighResolutionInfoWrapperStyle;

0 commit comments

Comments
 (0)