Skip to content

Commit

Permalink
Adjusted to reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
zfurtak committed Oct 1, 2024
1 parent a7cf2f4 commit fe43351
Show file tree
Hide file tree
Showing 32 changed files with 55 additions and 57 deletions.
6 changes: 3 additions & 3 deletions ios/NewExpensify.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
D27CE6B77196EF3EF450EEAC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 0D3F9E814828D91464DF9D35 /* PrivacyInfo.xcprivacy */; };
DD79042B2792E76D004484B4 /* RCTBootSplash.mm in Sources */ = {isa = PBXBuildFile; fileRef = DD79042A2792E76D004484B4 /* RCTBootSplash.mm */; };
DDCB2E57F334C143AC462B43 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D20D83B0E39BA6D21761E72 /* ExpoModulesProvider.swift */; };
E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */ = {isa = PBXBuildFile; };
E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */ = {isa = PBXBuildFile; };
E9DF872D2525201700607FDC /* AirshipConfig.plist in Resources */ = {isa = PBXBuildFile; fileRef = E9DF872C2525201700607FDC /* AirshipConfig.plist */; };
ED222ED90E074A5481A854FA /* ExpensifyNeue-BoldItalic.otf in Resources */ = {isa = PBXBuildFile; fileRef = 8B28D84EF339436DBD42A203 /* ExpensifyNeue-BoldItalic.otf */; };
F0C450EA2705020500FD2970 /* colors.json in Resources */ = {isa = PBXBuildFile; fileRef = F0C450E92705020500FD2970 /* colors.json */; };
Expand Down Expand Up @@ -176,8 +176,8 @@
buildActionMask = 2147483647;
files = (
383643682B6D4AE2005BB9AE /* DeviceCheck.framework in Frameworks */,
E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */,
E51DC681C7DEE40AEBDDFBFE /* (null) in Frameworks */,
E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */,
E51DC681C7DEE40AEBDDFBFE /* BuildFile in Frameworks */,
8744C5400E24E379441C04A4 /* libPods-NewExpensify.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,4 @@
"node": "20.15.1",
"npm": "10.7.0"
}
}
}
2 changes: 1 addition & 1 deletion src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function ButtonWithDropdownMenu<IValueType>({
if (!isSplitButton) {
setIsMenuVisible(!isMenuVisible);
} else if (selectedItem?.value) {
onPress(event, selectedItem?.value);
onPress(event, selectedItem.value);
}
},
[isMenuVisible, isSplitButton, onPress, selectedItem?.value],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function EmojiPickerMenu({onEmojiSelected, activeEmoji}: EmojiPickerMenuProps, r
);
}

const emojiCode = typeof preferredSkinTone === 'number' && types?.at(preferredSkinTone) ? types.at(preferredSkinTone) : code;
const emojiCode = typeof preferredSkinTone === 'number' && preferredSkinTone !== -1 && types?.at(preferredSkinTone) ? types.at(preferredSkinTone) : code;
const shouldEmojiBeHighlighted = !!activeEmoji && EmojiUtils.getRemovedSkinToneEmoji(emojiCode) === EmojiUtils.getRemovedSkinToneEmoji(activeEmoji);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/EmojiPicker/EmojiPickerMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function EmojiPickerMenu({onEmojiSelected, activeEmoji}: EmojiPickerMenuProps, r
return;
}
if ('types' in item || 'name' in item) {
const emoji = typeof preferredSkinTone === 'number' && item?.types?.at(preferredSkinTone) ? item.types.at(preferredSkinTone) : item.code;
const emoji = typeof preferredSkinTone === 'number' && preferredSkinTone !== -1 && item?.types?.at(preferredSkinTone) ? item.types.at(preferredSkinTone) : item.code;
onEmojiSelected(emoji ?? '', item);
}
},
Expand Down
7 changes: 4 additions & 3 deletions src/components/LHNOptionsList/OptionRowLHN.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
const isStatusVisible = !!emojiCode && ReportUtils.isOneOnOneChat(!isEmptyObject(report) ? report : undefined);

const subscriptAvatarBorderColor = isFocused ? focusedBackgroundColor : theme.sidebar;
const firstIcon = optionItem.icons?.at(0);

return (
<OfflineWithFeedback
pendingAction={optionItem.pendingAction}
Expand Down Expand Up @@ -234,12 +236,11 @@ function OptionRowLHN({reportID, isFocused = false, onSelectRow = () => {}, opti
<View style={sidebarInnerRowStyle}>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
{!!optionItem.icons?.length &&
firstIcon &&
(optionItem.shouldShowSubscript ? (
<SubscriptAvatar
backgroundColor={hovered && !isFocused ? hoveredBackgroundColor : subscriptAvatarBorderColor}
// because of the check above we know that there is an icon on index 0
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
mainAvatar={optionItem.icons.at(0)!}
mainAvatar={firstIcon}
secondaryAvatar={optionItem.icons.at(1)}
size={isInFocusMode ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
/>
Expand Down
7 changes: 3 additions & 4 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ function MenuItem(
const isDeleted = style && Array.isArray(style) ? style.includes(styles.offlineFeedback.deleted) : false;
const descriptionVerticalMargin = shouldShowDescriptionOnTop ? styles.mb1 : styles.mt1;
const fallbackAvatarSize = viewMode === CONST.OPTION_MODE.COMPACT ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT;
const firstIcon = floatRightAvatars.at(0);
const combinedTitleTextStyle = StyleUtils.combineStyles(
[
styles.flexShrink1,
Expand Down Expand Up @@ -776,14 +777,12 @@ function MenuItem(
<Text style={[styles.textLabelSupporting, ...(combinedStyle as TextStyle[])]}>{subtitle}</Text>
</View>
)}
{floatRightAvatars?.length > 0 && (
{floatRightAvatars?.length > 0 && firstIcon && (
<View style={[styles.alignItemsCenter, styles.justifyContentCenter, brickRoadIndicator ? styles.mr2 : styles.mrn2]}>
{shouldShowSubscriptRightAvatar ? (
<SubscriptAvatar
backgroundColor={isHovered ? theme.activeComponentBG : theme.componentBG}
// because of the check above we know that there is an avatar on index 0, but the error still appears
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
mainAvatar={floatRightAvatars.at(0)!}
mainAvatar={firstIcon}
secondaryAvatar={floatRightAvatars.at(1)}
size={floatRightAvatarSize ?? fallbackAvatarSize}
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/OptionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ function OptionRow({
const hoveredBackgroundColor = hoveredStyle?.backgroundColor ? (hoveredStyle.backgroundColor as string) : backgroundColor;
const focusedBackgroundColor = styles.sidebarLinkActive.backgroundColor;
const shouldUseShortFormInTooltip = (option.participantsList?.length ?? 0) > 1;
const firstIcon = option?.icons?.at(0);

// We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade.
const displayNamesWithTooltips = ReportUtils.getDisplayNamesWithTooltips((option.participantsList ?? (option.accountID ? [option] : [])).slice(0, 10), shouldUseShortFormInTooltip);
Expand Down Expand Up @@ -207,11 +208,10 @@ function OptionRow({
<View style={sidebarInnerRowStyle}>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
{!!option.icons?.length &&
firstIcon &&
(option.shouldShowSubscript ? (
<SubscriptAvatar
// because of the check above we know that there is an icon on index 0
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
mainAvatar={option.icons.at(0)!}
mainAvatar={firstIcon}
secondaryAvatar={option.icons.at(1)}
backgroundColor={hovered && !optionIsFocused ? hoveredBackgroundColor : subscriptColor}
size={CONST.AVATAR_SIZE.DEFAULT}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useReviewDuplicatesNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function useReviewDuplicatesNavigation(stepNames: string[], currentScreenName: S

useEffect(() => {
if (currentScreenName === 'confirmation') {
setPrevScreen(intersection.length > 0 ? intersection.at(intersection.length - 1) : undefined);
setPrevScreen(intersection.length > 0 ? intersection.at(-1) : undefined);
return;
}
const currentIndex = intersection.indexOf(currentScreenName);
Expand Down
8 changes: 2 additions & 6 deletions src/hooks/useViolations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,11 @@ function useViolations(violations: TransactionViolation[], shouldShowOnlyViolati
const getViolationsForField = useCallback(
(field: ViolationField, data?: TransactionViolation['data'], policyHasDependentTags = false, tagValue?: string) => {
const currentViolations = violationsByField.get(field) ?? [];
const firstViolation = currentViolations.at(0);

// someTagLevelsRequired has special logic becase data.errorIndexes is a bit unique in how it denotes the tag list that has the violation
// tagListIndex can be 0 so we compare with undefined
if (
currentViolations.at(0)?.name === CONST.VIOLATIONS.SOME_TAG_LEVELS_REQUIRED &&
data?.tagListIndex !== undefined &&
Array.isArray(currentViolations.at(0)?.data?.errorIndexes)
) {
if (firstViolation?.name === CONST.VIOLATIONS.SOME_TAG_LEVELS_REQUIRED && data?.tagListIndex !== undefined && Array.isArray(firstViolation?.data?.errorIndexes)) {
return currentViolations
.filter((violation) => violation.data?.errorIndexes?.includes(data?.tagListIndex ?? -1))
.map((violation) => ({
Expand All @@ -98,7 +95,6 @@ function useViolations(violations: TransactionViolation[], shouldShowOnlyViolati
},
}));
}
const firstViolation = currentViolations.at(0);

// missingTag has special logic for policies with dependent tags, because only one violation is returned for all tags
// when no tags are present, so the tag name isn't set in the violation data. That's why we add it here
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4022,7 +4022,7 @@ const translations = {
} else if (submittersNames.length === 2) {
joinedNames = submittersNames.join(' and ');
} else if (submittersNames.length > 2) {
joinedNames = `${submittersNames.slice(0, submittersNames.length - 1).join(', ')} and ${submittersNames.at(submittersNames.length - 1)}`;
joinedNames = `${submittersNames.slice(0, submittersNames.length - 1).join(', ')} and ${submittersNames.at(-1)}`;
}
return {
one: `removed you from ${joinedNames}'s approval workflow and workspace chat. Previously submitted reports will remain available for approval in your Inbox.`,
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4066,7 +4066,7 @@ const translations = {
} else if (submittersNames.length === 2) {
joinedNames = submittersNames.join(' y ');
} else if (submittersNames.length > 2) {
joinedNames = `${submittersNames.slice(0, submittersNames.length - 1).join(', ')} y ${submittersNames.at(submittersNames.length - 1)}`;
joinedNames = `${submittersNames.slice(0, submittersNames.length - 1).join(', ')} y ${submittersNames.at(-1)}`;
}
return {
one: `te eliminó del flujo de trabajo de aprobaciones y del chat del espacio de trabajo de ${joinedNames}. Los informes enviados anteriormente seguirán estando disponibles para su aprobación en tu bandeja de entrada.`,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ActiveClientManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const isClientTheLeader: IsClientTheLeader = () => {
return true;
}

const lastActiveClient = activeClients.length && activeClients.at(activeClients.length - 1);
const lastActiveClient = activeClients.length && activeClients.at(-1);

return lastActiveClient === clientID;
};
Expand Down
2 changes: 1 addition & 1 deletion src/libs/IOUUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function insertTagIntoTransactionTagsString(transactionTags: string, tag: string
const tagArray = TransactionUtils.getTagArrayFromName(transactionTags);
tagArray[tagIndex] = tag;

while (tagArray.length > 0 && !tagArray.at(tagArray.length - 1)) {
while (tagArray.length > 0 && !tagArray.at(-1)) {
tagArray.pop();
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/Middleware/Pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const Pagination: Middleware = (requestResponse, request) => {
if ((type === 'initial' && !cursorID) || (type === 'next' && newPage.length === 1 && newPage.at(0) === cursorID)) {
newPage.unshift(CONST.PAGINATION_START_ID);
}
const pageItem = sortedPageItems.at(sortedPageItems.length - 1);
const pageItem = sortedPageItems.at(-1);
if (pageItem && isLastItem(pageItem)) {
newPage.push(CONST.PAGINATION_END_ID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function ResponsiveStackNavigator(props: ResponsiveStackNavigatorProps) {
if (shouldUseNarrowLayout) {
const isSearchCentralPane = (route: RouteProp<ParamListBase>) => getTopmostCentralPaneRoute({routes: [route]} as State<RootStackParamList>)?.name === SCREENS.SEARCH.CENTRAL_PANE;

const lastRoute = routes.at(routes.length - 1);
const lastRoute = routes.at(-1);
const lastSearchCentralPane = lastRoute && isSearchCentralPane(lastRoute) ? lastRoute : undefined;
const filteredRoutes = routes.filter((route) => !isSearchCentralPane(route));

Expand Down
2 changes: 1 addition & 1 deletion src/libs/NextStepUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function parseMessage(messages: Message[] | undefined) {
let tagType = part.type ?? 'span';
let content = Str.safeEscape(part.text);

const previousPart = messages.at(index - 1);
const previousPart = index !== 0 ? messages.at(index - 1) : undefined;
const nextPart = messages.at(index + 1);

if (currentUserEmail === part.text || part.clickToCopyText === currentUserEmail) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/PaginationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function mergeAndSortContinuousPages<TResource>(sortedItems: TResource[], pages:
const result = [sortedPages.at(0)];
for (let i = 1; i < sortedPages.length; i++) {
const page = sortedPages.at(i);
const prevPage = result.at(result.length - 1);
const prevPage = result.at(-1);

if (!page || !prevPage) {
// eslint-disable-next-line no-continue
Expand Down
6 changes: 4 additions & 2 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ function getWorkspaceIcon(report: OnyxInputOrEntry<Report>, policy?: OnyxInputOr
* Gets the personal details for a login by looking in the ONYXKEYS.PERSONAL_DETAILS_LIST Onyx key (stored in the local variable, allPersonalDetails). If it doesn't exist in Onyx,
* then a default object is constructed.
*/
function getPersonalDetailsForAccountID(accountID?: number, personalDetailsData?: Partial<PersonalDetailsList>): Partial<PersonalDetails> {
function getPersonalDetailsForAccountID(accountID: number | undefined, personalDetailsData?: Partial<PersonalDetailsList>): Partial<PersonalDetails> {
if (!accountID) {
return {};
}
Expand Down Expand Up @@ -6441,7 +6441,9 @@ function getNewMarkerReportActionID(report: OnyxEntry<Report>, sortedAndFiltered

const newMarkerIndex = lodashFindLastIndex(sortedAndFilteredReportActions, (reportAction) => (reportAction.created ?? '') > (report?.lastReadTime ?? ''));

return 'reportActionID' in (sortedAndFilteredReportActions?.at(newMarkerIndex) ?? {}) ? sortedAndFilteredReportActions.at(newMarkerIndex)?.reportActionID ?? '' : '';
return newMarkerIndex !== -1 && 'reportActionID' in (sortedAndFilteredReportActions?.at(newMarkerIndex) ?? {})
? sortedAndFilteredReportActions.at(newMarkerIndex)?.reportActionID ?? ''
: '';
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src/libs/SearchUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,10 @@ function buildFilterString(filterName: string, queryFilters: QueryFilter[], deli
let filterValueString = '';
queryFilters.forEach((queryFilter, index) => {
// If the previous queryFilter has the same operator (this rule applies only to eq and neq operators) then append the current value
if ((queryFilter.operator === 'eq' && queryFilters?.at(index - 1)?.operator === 'eq') || (queryFilter.operator === 'neq' && queryFilters.at(index - 1)?.operator === 'neq')) {
if (
index !== 0 &&
((queryFilter.operator === 'eq' && queryFilters?.at(index - 1)?.operator === 'eq') || (queryFilter.operator === 'neq' && queryFilters.at(index - 1)?.operator === 'neq'))
) {
filterValueString += `${delimiter}${sanitizeString(queryFilter.value.toString())}`;
} else {
filterValueString += ` ${filterName}${operatorToSignMap[queryFilter.operator]}${sanitizeString(queryFilter.value.toString())}`;
Expand Down Expand Up @@ -774,7 +777,7 @@ function getSearchHeaderTitle(
.filter(([, taxRateKeys]) => taxRateKeys.some((taxID) => taxRateIDs.includes(taxID)))
.map(([taxRate]) => taxRate);
displayQueryFilters = taxRateNames.map((taxRate) => ({
operator: queryFilter.at(0)?.operator ?? 'and',
operator: queryFilter.at(0)?.operator ?? CONST.SEARCH.SYNTAX_OPERATORS.AND,
value: taxRate,
}));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Onyx.connect({
(reportAction) => ReportActionsUtils.shouldReportActionBeVisibleAsLastAction(reportAction) && reportAction.actionName !== CONST.REPORT.ACTIONS.TYPE.CREATED,
);

const reportAction = reportActionsForDisplay.at(reportActionsForDisplay.length - 1);
const reportAction = reportActionsForDisplay.at(-1);
if (!reportAction) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6998,7 +6998,7 @@ function isLastApprover(approvalChain: string[]): boolean {
if (approvalChain.length === 0) {
return true;
}
return approvalChain.at(approvalChain.length - 1) === currentUserEmail;
return approvalChain.at(-1) === currentUserEmail;
}

function getNextApproverAccountID(report: OnyxEntry<OnyxTypes.Report>) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/OnyxUpdateManager/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function detectGapsAndSplit(lastUpdateIDFromClient: number): DetectGapAndSplitRe
if (gapExists) {
// If there is a gap and we didn't detect two chained updates, "firstUpdateToBeAppliedAfterGap" will always be the the last deferred update.
// We will fetch all missing updates up to the previous update and can always apply the last deferred update.
const firstUpdateToBeAppliedAfterGap = firstUpdateIDAfterGaps ?? Number(updateValues.at(updateValues.length - 1)?.lastUpdateID);
const firstUpdateToBeAppliedAfterGap = firstUpdateIDAfterGaps ?? Number(updateValues.at(-1)?.lastUpdateID);

// Add all deferred updates after the gap(s) to "updatesAfterGaps".
// If "firstUpdateToBeAppliedAfterGap" is set to the last deferred update, the array will be empty.
Expand Down
Loading

0 comments on commit fe43351

Please sign in to comment.