Skip to content

Commit

Permalink
[ts migration] Removed unnecessary variable creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ruben-rebelo committed Jan 8, 2024
1 parent f9f4469 commit a62150d
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ type BaseAnchorForAttachmentsOnlyProps = AnchorForAttachmentsOnlyProps &
};

function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', download, onPressIn, onPressOut}: BaseAnchorForAttachmentsOnlyProps) {
const sourceURL = source;
const sourceURLWithAuth = addEncryptedAuthTokenToURL(sourceURL);
const sourceID = (sourceURL.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];
const fileName = displayName;
const sourceURLWithAuth = addEncryptedAuthTokenToURL(source);
const sourceID = (source.match(CONST.REGEX.ATTACHMENT_ID) ?? [])[1];

const isDownloading = download?.isDownloading ?? false;

Expand All @@ -44,19 +42,19 @@ function BaseAnchorForAttachmentsOnly({style, source = '', displayName = '', dow
return;
}
Download.setDownload(sourceID, true);
fileDownload(sourceURLWithAuth, fileName).then(() => Download.setDownload(sourceID, false));
fileDownload(sourceURLWithAuth, displayName).then(() => Download.setDownload(sourceID, false));
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
// @ts-expect-error TODO: Remove this once ShowContextMenuContext (https://github.com/Expensify/App/issues/24980) is migrated to TypeScript.
onLongPress={(event) => showContextMenuForReport(event, anchor, report.reportID, action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report))}
accessibilityLabel={fileName}
accessibilityLabel={displayName}
role={CONST.ROLE.BUTTON}
>
<AttachmentView
// @ts-expect-error TODO: Remove this once AttachmentView (https://github.com/Expensify/App/issues/25150) is migrated to TypeScript.
source={sourceURLWithAuth}
file={{name: fileName}}
file={{name: displayName}}
shouldShowDownloadIcon
shouldShowLoadingSpinnerIcon={isDownloading}
/>
Expand Down

0 comments on commit a62150d

Please sign in to comment.