Skip to content

Commit

Permalink
update listID
Browse files Browse the repository at this point in the history
  • Loading branch information
perunt committed Mar 20, 2024
1 parent acb2b06 commit cb86c85
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/libs/NumberUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,12 @@ function clamp(value: number, min: number, max: number): number {
return Math.min(Math.max(value, min), max);
}

export {rand64, generateHexadecimalValue, generateRandomInt, parseFloatAnyLocale, roundDownToLargestMultiple, roundToTwoDecimalPlaces, clamp};
function generateNewRandomInt(old: number, min: number, max: number): number {
let newNum = old;
while (newNum === old) {
newNum = generateRandomInt(min, max);
}
return newNum;
}

export {rand64, generateHexadecimalValue, generateRandomInt, parseFloatAnyLocale, roundDownToLargestMultiple, roundToTwoDecimalPlaces, clamp, generateNewRandomInt};
6 changes: 0 additions & 6 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import type {RouteProp} from '@react-navigation/native';
import fastMerge from 'expensify-common/lib/fastMerge';
import _ from 'lodash';
import lodashFindLast from 'lodash/findLast';
import {useCallback, useLayoutEffect, useMemo, useRef, useState} from 'react';
import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import getInitialPaginationSize from '@pages/home/report/getInitialPaginationSize';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import type {
ActionName,
ChangeLog,
Expand All @@ -31,7 +26,6 @@ import isReportMessageAttachment from './isReportMessageAttachment';
import * as Localize from './Localize';
import Log from './Log';
import type {MessageElementBase, MessageTextElement} from './MessageElement';
import type {CentralPaneNavigatorParamList} from './Navigation/types';
import * as PersonalDetailsUtils from './PersonalDetailsUtils';
import type {OptimisticIOUReportAction} from './ReportUtils';

Expand Down
8 changes: 5 additions & 3 deletions src/pages/home/report/ReportActionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import usePrevious from '@hooks/usePrevious';
import useWindowDimensions from '@hooks/useWindowDimensions';
import getIsReportFullyVisible from '@libs/getIsReportFullyVisible';
import type {CentralPaneNavigatorParamList} from '@libs/Navigation/types';
import {generateNewRandomInt} from '@libs/NumberUtils';
import Performance from '@libs/Performance';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import {isUserCreatedPolicyRoom} from '@libs/ReportUtils';
Expand Down Expand Up @@ -59,7 +60,7 @@ type ReportActionsViewProps = ReportActionsViewOnyxProps & {
const DIFF_BETWEEN_SCREEN_HEIGHT_AND_LIST = 120;
const SPACER = 16;

let listIDCount = Math.round(Math.random() * 100);
let listOldID = Math.round(Math.random() * 100);

function ReportActionsView({
report,
Expand Down Expand Up @@ -127,8 +128,9 @@ function ReportActionsView({

const listID = useMemo(() => {
isFirstLinkedActionRender.current = true;
listIDCount += 1;
return listIDCount;
const newID = generateNewRandomInt(listOldID, 1, Number.MAX_SAFE_INTEGER);
listOldID = newID;
return newID;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [route, isLoadingInitialReportActions]);

Expand Down

0 comments on commit cb86c85

Please sign in to comment.