Skip to content

Commit

Permalink
Merge branch 'main' into filip-solecki/import-categories-csv
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-solecki authored Aug 27, 2024
2 parents 09223e9 + c9e53f6 commit 0f7b3f8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,7 @@ function getOptions(
}

reportOption.isSelected = isReportSelected(reportOption, selectedOptions);
reportOption.isBold = shouldUseBoldText(reportOption);

if (action === CONST.IOU.ACTION.CATEGORIZE) {
const policyCategories = allPolicyCategories?.[`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${reportOption.policyID}`] ?? {};
Expand All @@ -1984,13 +1985,14 @@ function getOptions(

const personalDetailsOptionsToExclude = [...optionsToExclude, {login: currentUserLogin}];
// Next loop over all personal details removing any that are selectedUsers or recentChats
allPersonalDetailsOptions.forEach((personalDetailOption) => {
for (const personalDetailOption of allPersonalDetailsOptions) {
if (personalDetailsOptionsToExclude.some((optionToExclude) => optionToExclude.login === personalDetailOption.login)) {
return;
continue;
}
personalDetailOption.isBold = shouldUseBoldText(personalDetailOption);

personalDetailsOptions.push(personalDetailOption);
});
}

const currentUserOption = allPersonalDetailsOptions.find((personalDetailsOption) => personalDetailsOption.login === currentUserLogin);

Expand Down
1 change: 1 addition & 0 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ type OptionData = {
amountInputProps?: MoneyRequestAmountInputProps;
tabIndex?: 0 | -1;
isConciergeChat?: boolean;
isBold?: boolean;
} & Report;

type OnyxDataTaskAssigneeChat = {
Expand Down
6 changes: 2 additions & 4 deletions src/pages/ChatFinderPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,14 @@ function ChatFinderPage({betas, isSearchingForReports, navigation}: ChatFinderPa

if (recentReports?.length > 0) {
newSections.push({
data: recentReports.map((report) => {
return {...report, isBold: OptionsListUtils.shouldUseBoldText(report)};
}),
data: recentReports,
shouldShow: true,
});
}

if (localPersonalDetails.length > 0) {
newSections.push({
data: localPersonalDetails.map((personalDetail) => ({...personalDetail, isBold: false})),
data: localPersonalDetails,
shouldShow: true,
});
}
Expand Down
15 changes: 13 additions & 2 deletions src/pages/home/report/ReportAttachments.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React, {useCallback} from 'react';
import React, {useCallback, useEffect, useRef} from 'react';
import {useOnyx} from 'react-native-onyx';
import AttachmentModal from '@components/AttachmentModal';
import type {Attachment} from '@components/Attachments/types';
Expand All @@ -18,6 +18,14 @@ function ReportAttachments({route}: ReportAttachmentsProps) {
const accountID = route.params.accountID;
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID || -1}`);
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);
const hasDismissedModalRef = useRef(false);

useEffect(
() => () => {
hasDismissedModalRef.current = false;
},
[],
);

// In native the imported images sources are of type number. Ref: https://reactnative.dev/docs/image#imagesource
const source = Number(route.params.source) || route.params.source;
Expand All @@ -39,7 +47,10 @@ function ReportAttachments({route}: ReportAttachmentsProps) {
report={report}
source={source}
onModalClose={() => {
Navigation.dismissModal();
if (!hasDismissedModalRef.current) {
Navigation.dismissModal();
hasDismissedModalRef.current = true;
}
// This enables Composer refocus when the attachments modal is closed by the browser navigation
ComposerFocusManager.setReadyToFocus();
}}
Expand Down

0 comments on commit 0f7b3f8

Please sign in to comment.