Skip to content

Commit 6921ddb

Browse files
committed
refactor: extract variables
1 parent 01205b3 commit 6921ddb

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/pages/media/AttachmentModalScreen/routes/WorkspaceAvatarModalContent.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,29 @@ function WorkspaceAvatarModalContent({navigation, route}: AttachmentModalScreenP
1717
const [isLoadingApp = false] = useOnyx(ONYXKEYS.IS_LOADING_APP, {canBeMissing: true, initWithStoredValues: false});
1818

1919
const avatarURL = policy?.avatarURL ?? getDefaultWorkspaceAvatar(policy?.name ?? fallbackLetter);
20-
20+
const source = getFullSizeAvatar(avatarURL, 0);
2121
const policyKeysLength = Object.keys(policy ?? {}).length;
2222

2323
// eslint-disable-next-line rulesdir/no-negated-variables
2424
const shouldShowNotFoundPage = policyKeysLength === 0 && !isLoadingApp && (!policyID || !fallbackLetter);
25+
const isLoading = policyKeysLength === 0 && !!isLoadingApp;
26+
const originalFileName = policy?.originalFileName ?? policy?.id ?? policyID;
27+
const headerTitle = policy?.name ?? '';
2528

2629
const onDownloadAttachment = useDownloadAttachment();
2730

2831
const contentProps = useMemo<AttachmentModalBaseContentProps>(
2932
() => ({
30-
source: getFullSizeAvatar(avatarURL, 0),
31-
headerTitle: policy?.name ?? '',
32-
originalFileName: policy?.originalFileName ?? policy?.id ?? policyID,
33+
source,
34+
headerTitle,
35+
originalFileName,
3336
shouldShowNotFoundPage,
37+
isLoading,
3438
isWorkspaceAvatar: true,
35-
isLoading: policyKeysLength === 0 && !!isLoadingApp,
3639
maybeIcon: true,
3740
onDownloadAttachment,
3841
}),
39-
[avatarURL, isLoadingApp, onDownloadAttachment, policy?.id, policy?.name, policy?.originalFileName, policyID, policyKeysLength, shouldShowNotFoundPage],
42+
[headerTitle, isLoading, onDownloadAttachment, originalFileName, shouldShowNotFoundPage, source],
4043
);
4144

4245
return (

0 commit comments

Comments
 (0)