Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a9aaa28
ref: started AttachemntModal migration
kubabutkiewicz Jan 4, 2024
1998e69
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 4, 2024
e4a4d25
fix: types
kubabutkiewicz Jan 8, 2024
0ab46a5
fix: add props comments
kubabutkiewicz Jan 8, 2024
4d19b6b
fix: resolve comments
kubabutkiewicz Jan 9, 2024
fdf6920
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 9, 2024
3f2a1ce
fix: resolve comments
kubabutkiewicz Jan 9, 2024
2304c8c
fix: resolve comments
kubabutkiewicz Jan 9, 2024
85d0539
fix: resolve comment
kubabutkiewicz Jan 10, 2024
475ac15
fix: resolve comments
kubabutkiewicz Jan 10, 2024
2b2bfca
Remove console.log statement in AttachmentModal component
kubabutkiewicz Jan 10, 2024
f795355
fix: typo
kubabutkiewicz Jan 10, 2024
a6e00eb
fix: resolve comment
kubabutkiewicz Jan 10, 2024
29257d7
fix: minor code improvments
kubabutkiewicz Jan 15, 2024
c7ec5f5
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 15, 2024
96e91b8
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 22, 2024
d5a34db
fix: resovle comments
kubabutkiewicz Jan 22, 2024
a6427ce
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 23, 2024
f3646c7
fix: problem with uploading attachments
kubabutkiewicz Jan 23, 2024
05ec1ec
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 25, 2024
50ea27e
fix: typecheck
kubabutkiewicz Jan 25, 2024
3be3501
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 30, 2024
b7e0708
fix: removed unnecessary assertion
kubabutkiewicz Jan 30, 2024
0991606
Merge branch 'main' of github.com:kubabutkiewicz/expensify-app into t…
kubabutkiewicz Jan 30, 2024
603d34e
fix: lint
kubabutkiewicz Jan 30, 2024
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

Large diffs are not rendered by default.

29 changes: 12 additions & 17 deletions src/components/ReportActionItem/ReportActionItemImage.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Str from 'expensify-common/lib/str';
import React from 'react';
import type {ReactElement} from 'react';
import type {ImageSourcePropType, ViewStyle} from 'react-native';
import {View} from 'react-native';
import type {ImageSourcePropType} from 'react-native';
import AttachmentModal from '@components/AttachmentModal';
import EReceiptThumbnail from '@components/EReceiptThumbnail';
import Image from '@components/Image';
Expand Down Expand Up @@ -79,30 +79,25 @@ function ReportActionItemImage({thumbnail, image, enablePreviewModal = false, tr
return (
<ShowContextMenuContext.Consumer>
{({report}) => (
// @ts-expect-error TODO: Remove this once AttachmentModal (https://github.com/Expensify/App/issues/25130) is migrated to TypeScript.
<AttachmentModal
source={imageSource}
isAuthTokenRequired={!isLocalFile}
report={report}
isReceiptAttachment
canEditReceipt={canEditReceipt}
allowToDownload
allowDownload
originalFileName={transaction?.filename}
>
{
// @ts-expect-error TODO: Remove this once AttachmentModal (https://github.com/Expensify/App/issues/25130) is migrated to TypeScript.
({show}) => (
<PressableWithoutFocus
// @ts-expect-error TODO: Remove this once AttachmentModal (https://github.com/Expensify/App/issues/25130) is migrated to TypeScript.
style={[styles.noOutline, styles.w100, styles.h100]}
onPress={show}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.IMAGEBUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
>
{receiptImageComponent}
</PressableWithoutFocus>
)
}
{({show}) => (
<PressableWithoutFocus
style={[styles.w100, styles.h100, styles.noOutline as ViewStyle]}
onPress={show}
accessibilityRole={CONST.ROLE.BUTTON}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
>
{receiptImageComponent}
</PressableWithoutFocus>
)}
</AttachmentModal>
)}
</ShowContextMenuContext.Consumer>
Expand Down
4 changes: 2 additions & 2 deletions src/libs/TransactionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ Onyx.connect({
callback: (value) => (allReports = value),
});

function isDistanceRequest(transaction: Transaction): boolean {
function isDistanceRequest(transaction: OnyxEntry<Transaction>): boolean {
// This is used during the request creation flow before the transaction has been saved to the server
if (lodashHas(transaction, 'iouRequestType')) {
return transaction.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE;
return transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE;
}

// This is the case for transaction objects once they have been saved to the server
Expand Down
3 changes: 1 addition & 2 deletions src/pages/ReportAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function ReportAvatar({report = {} as Report, policies, isLoadingApp = true}: Re

return (
<AttachmentModal
// @ts-expect-error TODO: Remove this once AttachmentModal (https://github.com/Expensify/App/issues/25130) is migrated to TypeScript.
headerTitle={policyName}
defaultOpen
source={UserUtils.getFullSizeAvatar(avatarURL, 0)}
Expand All @@ -38,7 +37,7 @@ function ReportAvatar({report = {} as Report, policies, isLoadingApp = true}: Re
isWorkspaceAvatar
originalFileName={policy?.originalFileName ?? policyName}
shouldShowNotFoundPage={!report?.reportID && !isLoadingApp}
isLoading={(!report?.reportID || !policy?.id) && isLoadingApp}
isLoading={(!report?.reportID || !policy?.id) && !!isLoadingApp}
/>
);
}
Expand Down
17 changes: 2 additions & 15 deletions src/pages/home/report/ReportAttachments.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback} from 'react';
import type {Attachment} from '@components/AttachmentModal';
import AttachmentModal from '@components/AttachmentModal';
import ComposerFocusManager from '@libs/ComposerFocusManager';
import Navigation from '@libs/Navigation/Navigation';
Expand All @@ -8,19 +9,6 @@ import * as ReportUtils from '@libs/ReportUtils';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';

type File = {
name: string;
};

type Attachment = {
file: File;
hasBeenFlagged: boolean;
isAuthTokenRequired: boolean;
isReceipt: boolean;
reportActionID: string;
source: string;
};

type ReportAttachmentsProps = StackScreenProps<AuthScreensParamList, typeof SCREENS.REPORT_ATTACHMENTS>;

function ReportAttachments({route}: ReportAttachmentsProps) {
Expand All @@ -33,15 +21,14 @@ function ReportAttachments({route}: ReportAttachmentsProps) {

const onCarouselAttachmentChange = useCallback(
(attachment: Attachment) => {
const routeToNavigate = ROUTES.REPORT_ATTACHMENTS.getRoute(reportID, attachment.source);
const routeToNavigate = ROUTES.REPORT_ATTACHMENTS.getRoute(reportID, String(attachment.source));
Navigation.navigate(routeToNavigate);
},
[reportID],
);

return (
<AttachmentModal
// @ts-expect-error TODO: Remove this once AttachmentModal (https://github.com/Expensify/App/issues/25130) is migrated to TypeScript.
allowDownload
defaultOpen
report={report}
Expand Down
3 changes: 1 addition & 2 deletions src/pages/settings/Profile/ProfileAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ function ProfileAvatar({route, personalDetails, isLoadingApp = true}: ProfileAva

return (
<AttachmentModal
// @ts-expect-error TODO: Remove this once AttachmentModal (https://github.com/Expensify/App/issues/25130) is migrated to TypeScript.
headerTitle={personalDetail?.displayName ?? ''}
defaultOpen
source={UserUtils.getFullSizeAvatar(avatarURL, accountID)}
onModalClose={() => {
Navigation.goBack();
}}
originalFileName={personalDetail?.originalFileName ?? ''}
isLoading={isLoading}
isLoading={!!isLoading}
shouldShowNotFoundPage={!avatarURL}
/>
);
Expand Down
3 changes: 1 addition & 2 deletions src/pages/workspace/WorkspaceAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function WorkspaceAvatar({route, policy, isLoadingApp = true}: WorkspaceAvatarPr

return (
<AttachmentModal
// @ts-expect-error TODO: Remove this once AttachmentModal (https://github.com/Expensify/App/issues/25130) is migrated to TypeScript.
headerTitle={policy?.name ?? ''}
defaultOpen
source={UserUtils.getFullSizeAvatar(avatarURL, 0)}
Expand All @@ -34,7 +33,7 @@ function WorkspaceAvatar({route, policy, isLoadingApp = true}: WorkspaceAvatarPr
isWorkspaceAvatar
originalFileName={policy?.originalFileName ?? policy?.name ?? ''}
shouldShowNotFoundPage={!Object.keys(policy ?? {}).length && !isLoadingApp}
isLoading={!Object.keys(policy ?? {}).length && isLoadingApp}
isLoading={!Object.keys(policy ?? {}).length && !!isLoadingApp}
/>
);
}
Expand Down
4 changes: 1 addition & 3 deletions src/styles/utils/generators/ModalStyleUtils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {ViewStyle} from 'react-native';
import type {ModalProps} from 'react-native-modal';
import type {ValueOf} from 'type-fest';
import type {ThemeStyles} from '@styles/index';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import type ModalType from '@src/types/utils/ModalType';
import type StyleUtilGenerator from './types';

function getCenteredModalStyles(styles: ThemeStyles, windowWidth: number, isSmallScreenWidth: boolean, isFullScreenWhenSmall = false): ViewStyle {
Expand All @@ -15,8 +15,6 @@ function getCenteredModalStyles(styles: ThemeStyles, windowWidth: number, isSmal
};
}

type ModalType = ValueOf<typeof CONST.MODAL.MODAL_TYPE>;

type WindowDimensions = {
windowWidth: number;
windowHeight: number;
Expand Down
6 changes: 6 additions & 0 deletions src/types/utils/ModalType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';

type ModalType = ValueOf<typeof CONST.MODAL.MODAL_TYPE>;

export default ModalType;