Skip to content

Commit

Permalink
Revert "lint fix"
Browse files Browse the repository at this point in the history
This reverts commit 079e0b7.
  • Loading branch information
FitseTLT committed Jan 14, 2025
1 parent 079e0b7 commit 721161d
Showing 1 changed file with 21 additions and 30 deletions.
51 changes: 21 additions & 30 deletions src/pages/NewChatPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,13 @@ import useSafeAreaInsets from '@hooks/useSafeAreaInsets';
import useScreenWrapperTranstionStatus from '@hooks/useScreenWrapperTransitionStatus';
import useStyledSafeAreaInsets from '@hooks/useStyledSafeAreaInsets';
import useThemeStyles from '@hooks/useThemeStyles';
import {navigateToAndOpenReport, searchInServer, setGroupDraft} from '@libs/actions/Report';
import {canUseTouchScreen} from '@libs/DeviceCapabilities';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import type {Option, Section} from '@libs/OptionsListUtils';
import {
filterAndOrderOptions,
formatSectionsFromSearchTerm,
getFirstKeyForList,
getHeaderMessage,
getPersonalDetailSearchTerms,
getUserToInviteOption,
getValidOptions,
} from '@libs/OptionsListUtils';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import type {OptionData} from '@libs/ReportUtils';
import variables from '@styles/variables';
import * as Report from '@userActions/Report';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand All @@ -60,7 +51,7 @@ function useOptions() {
});

const defaultOptions = useMemo(() => {
const filteredOptions = getValidOptions(
const filteredOptions = OptionsListUtils.getValidOptions(
{
reports: listOptions.reports ?? [],
personalDetails: listOptions.personalDetails ?? [],
Expand All @@ -75,7 +66,7 @@ function useOptions() {
}, [betas, listOptions.personalDetails, listOptions.reports, selectedOptions]);

const options = useMemo(() => {
const filteredOptions = filterAndOrderOptions(defaultOptions, debouncedSearchTerm, {
const filteredOptions = OptionsListUtils.filterAndOrderOptions(defaultOptions, debouncedSearchTerm, {
selectedOptions,
maxRecentReportsToShow: CONST.IOU.MAX_RECENT_REPORTS_TO_SHOW,
});
Expand All @@ -84,11 +75,11 @@ function useOptions() {
}, [debouncedSearchTerm, defaultOptions, selectedOptions]);
const cleanSearchTerm = useMemo(() => debouncedSearchTerm.trim().toLowerCase(), [debouncedSearchTerm]);
const headerMessage = useMemo(() => {
return getHeaderMessage(
return OptionsListUtils.getHeaderMessage(
options.personalDetails.length + options.recentReports.length !== 0,
!!options.userToInvite,
debouncedSearchTerm.trim(),
selectedOptions.some((participant) => getPersonalDetailSearchTerms(participant).join(' ').toLowerCase?.().includes(cleanSearchTerm)),
selectedOptions.some((participant) => OptionsListUtils.getPersonalDetailSearchTerms(participant).join(' ').toLowerCase?.().includes(cleanSearchTerm)),
);
}, [cleanSearchTerm, debouncedSearchTerm, options.personalDetails.length, options.recentReports.length, options.userToInvite, selectedOptions]);

Expand All @@ -97,7 +88,7 @@ function useOptions() {
return;
}

searchInServer(debouncedSearchTerm);
Report.searchInServer(debouncedSearchTerm);
}, [debouncedSearchTerm]);

useEffect(() => {
Expand All @@ -111,7 +102,7 @@ function useOptions() {
}
let participantOption: OptionData | undefined | null = listOptions.personalDetails.find((option) => option.accountID === participant.accountID);
if (!participantOption) {
participantOption = getUserToInviteOption({
participantOption = OptionsListUtils.getUserToInviteOption({
searchValue: participant?.login,
});
}
Expand Down Expand Up @@ -155,14 +146,14 @@ function NewChatPage() {
useOptions();

const [sections, firstKeyForList] = useMemo(() => {
const sectionsList: Section[] = [];
const sectionsList: OptionsListUtils.Section[] = [];
let firstKey = '';

const formatResults = formatSectionsFromSearchTerm(debouncedSearchTerm, selectedOptions, recentReports, personalDetails);
const formatResults = OptionsListUtils.formatSectionsFromSearchTerm(debouncedSearchTerm, selectedOptions, recentReports, personalDetails);
sectionsList.push(formatResults.section);

if (!firstKey) {
firstKey = getFirstKeyForList(formatResults.section.data);
firstKey = OptionsListUtils.getFirstKeyForList(formatResults.section.data);
}

sectionsList.push({
Expand All @@ -171,7 +162,7 @@ function NewChatPage() {
shouldShow: !isEmpty(recentReports),
});
if (!firstKey) {
firstKey = getFirstKeyForList(recentReports);
firstKey = OptionsListUtils.getFirstKeyForList(recentReports);
}

sectionsList.push({
Expand All @@ -180,7 +171,7 @@ function NewChatPage() {
shouldShow: !isEmpty(personalDetails),
});
if (!firstKey) {
firstKey = getFirstKeyForList(personalDetails);
firstKey = OptionsListUtils.getFirstKeyForList(personalDetails);
}

if (userToInvite) {
Expand All @@ -190,7 +181,7 @@ function NewChatPage() {
shouldShow: true,
});
if (!firstKey) {
firstKey = getFirstKeyForList([userToInvite]);
firstKey = OptionsListUtils.getFirstKeyForList([userToInvite]);
}
}

Expand All @@ -202,7 +193,7 @@ function NewChatPage() {
* or navigates to the existing chat if one with those participants already exists.
*/
const createChat = useCallback(
(option?: Option) => {
(option?: OptionsListUtils.Option) => {
if (option?.isSelfDM) {
Navigation.dismissModal(option.reportID);
return;
Expand All @@ -218,13 +209,13 @@ function NewChatPage() {
Log.warn('Tried to create chat with empty login');
return;
}
navigateToAndOpenReport([login]);
Report.navigateToAndOpenReport([login]);
},
[selectedOptions],
);

const itemRightSideComponent = useCallback(
(item: ListItem & Option, isFocused?: boolean) => {
(item: ListItem & OptionsListUtils.Option, isFocused?: boolean) => {
if (!!item.isSelfDM || (item.login && excludedGroupEmails.includes(item.login))) {
return null;
}
Expand Down Expand Up @@ -289,7 +280,7 @@ function NewChatPage() {
accountID: option.accountID ?? CONST.DEFAULT_NUMBER_ID,
}));
const logins = [...selectedParticipants, {login: personalData.login, accountID: personalData.accountID}];
setGroupDraft({participants: logins});
Report.setGroupDraft({participants: logins});
Keyboard.dismiss();
Navigation.navigate(ROUTES.NEW_CHAT_CONFIRM);
}, [selectedOptions, personalData]);
Expand Down Expand Up @@ -336,7 +327,7 @@ function NewChatPage() {
// This is because when wrapping whole screen the screen was freezing when changing Tabs.
keyboardVerticalOffset={variables.contentHeaderHeight + top + variables.tabSelectorButtonHeight + variables.tabSelectorButtonPadding}
>
<SelectionList<Option & ListItem>
<SelectionList<OptionsListUtils.Option & ListItem>
ref={selectionListRef}
ListItem={UserListItem}
sections={areOptionsInitialized ? sections : CONST.EMPTY_ARRAY}
Expand All @@ -351,7 +342,7 @@ function NewChatPage() {
rightHandSideComponent={itemRightSideComponent}
footerContent={footerContent}
showLoadingPlaceholder={!areOptionsInitialized}
shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()}
shouldPreventDefaultFocusOnSelectRow={!DeviceCapabilities.canUseTouchScreen()}
isLoadingNewOptions={!!isSearchingForReports}
initiallyFocusedOptionKey={firstKeyForList}
shouldTextInputInterceptSwipe
Expand Down

0 comments on commit 721161d

Please sign in to comment.