Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1506,6 +1506,7 @@ const CONST = {
PUSHER_PING_PONG: 'pusher_ping_pong',
LOCATION_UPDATE_INTERVAL: 5000,
PLAY_SOUND_MESSAGE_DEBOUNCE_TIME: 500,
NOTIFY_NEW_ACTION_DELAY: 700,
SKELETON_ANIMATION_SPEED: 3,
SEARCH_OPTIONS_COMPARISON: 'search_options_comparison',
SEARCH_MOST_RECENT_OPTIONS: 'search_most_recent_options',
Expand Down
10 changes: 2 additions & 8 deletions src/components/Search/SearchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {turnOnMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import {isMobileChrome} from '@libs/Browser';
import {addKeyDownPressListener, removeKeyDownPressListener} from '@libs/KeyboardShortcut/KeyDownPressListener';
import durationHighlightItem from '@libs/Navigation/helpers/getDurationHighlightItem';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -287,16 +288,9 @@ function SearchList(
clearTimeout(itemFocusTimeoutRef.current);
}

const duration =
CONST.ANIMATED_HIGHLIGHT_ENTRY_DELAY +
CONST.ANIMATED_HIGHLIGHT_ENTRY_DURATION +
CONST.ANIMATED_HIGHLIGHT_START_DELAY +
CONST.ANIMATED_HIGHLIGHT_START_DURATION +
CONST.ANIMATED_HIGHLIGHT_END_DELAY +
CONST.ANIMATED_HIGHLIGHT_END_DURATION;
itemFocusTimeoutRef.current = setTimeout(() => {
setItemsToHighlight(null);
}, duration);
}, durationHighlightItem);
},
[data, scrollToIndex],
);
Expand Down
10 changes: 10 additions & 0 deletions src/libs/Navigation/helpers/getDurationHighlightItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import CONST from '@src/CONST';

const durationHighlightItem =
CONST.ANIMATED_HIGHLIGHT_ENTRY_DELAY +
CONST.ANIMATED_HIGHLIGHT_ENTRY_DURATION +
CONST.ANIMATED_HIGHLIGHT_START_DELAY +
CONST.ANIMATED_HIGHLIGHT_START_DURATION +
CONST.ANIMATED_HIGHLIGHT_END_DELAY +
CONST.ANIMATED_HIGHLIGHT_END_DURATION;
export default durationHighlightItem;
6 changes: 5 additions & 1 deletion src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5609,7 +5609,11 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) {
}

if (activeReportID && !isMoneyRequestReport) {
notifyNewAction(activeReportID, payeeAccountID);
Navigation.setNavigationActionToMicrotaskQueue(() =>
setTimeout(() => {
notifyNewAction(activeReportID, payeeAccountID, reportPreviewAction);
}, CONST.TIMING.NOTIFY_NEW_ACTION_DELAY),
);
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,9 @@ type PureReportActionItemProps = {
/** Whether to show border for MoneyRequestReportPreviewContent */
shouldShowBorder?: boolean;

/** Whether to highlight the action for a few seconds */
shouldHighlight?: boolean;

/** Current user's account id */
currentUserAccountID?: number;
};
Expand Down Expand Up @@ -428,6 +431,7 @@ function PureReportActionItem({
dismissTrackExpenseActionableWhisper = () => {},
userBillingFundID,
shouldShowBorder,
shouldHighlight = false,
currentUserAccountID,
}: PureReportActionItemProps) {
const actionSheetAwareScrollViewContext = useContext(ActionSheetAwareScrollView.ActionSheetAwareScrollViewContext);
Expand Down Expand Up @@ -457,8 +461,9 @@ function PureReportActionItem({
const isReportArchived = useReportIsArchived(report?.reportID);

const highlightedBackgroundColorIfNeeded = useMemo(
() => (isReportActionLinked ? StyleUtils.getBackgroundColorStyle(theme.messageHighlightBG) : {}),
[StyleUtils, isReportActionLinked, theme.messageHighlightBG],
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
() => (isReportActionLinked || shouldHighlight ? StyleUtils.getBackgroundColorStyle(theme.messageHighlightBG) : {}),
[StyleUtils, isReportActionLinked, theme.messageHighlightBG, shouldHighlight],
);

const reportPreviewStyles = StyleUtils.getMoneyRequestReportPreviewStyle(shouldUseNarrowLayout, 1, undefined, undefined);
Expand Down Expand Up @@ -1646,6 +1651,7 @@ export default memo(PureReportActionItem, (prevProps, nextProps) => {
deepEqual(prevProps.missingPaymentMethod, nextProps.missingPaymentMethod) &&
prevProps.reimbursementDeQueuedOrCanceledActionMessage === nextProps.reimbursementDeQueuedOrCanceledActionMessage &&
prevProps.modifiedExpenseMessage === nextProps.modifiedExpenseMessage &&
prevProps.shouldHighlight === nextProps.shouldHighlight &&
prevProps.userBillingFundID === nextProps.userBillingFundID
);
});
40 changes: 36 additions & 4 deletions src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions';
import {isSafari} from '@libs/Browser';
import DateUtils from '@libs/DateUtils';
import {getChatFSAttributes, parseFSAttributes} from '@libs/Fullstory';
import durationHighlightItem from '@libs/Navigation/helpers/getDurationHighlightItem';
import isReportTopmostSplitNavigator from '@libs/Navigation/helpers/isReportTopmostSplitNavigator';
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
import Navigation from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -173,6 +174,7 @@ function ReportActionsList({
const isReportArchived = useReportIsArchived(report?.reportID);

const [isScrollToBottomEnabled, setIsScrollToBottomEnabled] = useState(false);
const [actionIdToHighlight, setActionIdToHighlight] = useState('');

useEffect(() => {
const unsubscribe = Visibility.onVisibilityChange(() => {
Expand Down Expand Up @@ -409,7 +411,7 @@ function ReportActionsList({
}, [lastAction, prevSortedVisibleReportActionsObjects, reportScrollManager]);

const scrollToBottomForCurrentUserAction = useCallback(
(isFromCurrentUser: boolean) => {
(isFromCurrentUser: boolean, action?: OnyxTypes.ReportAction) => {
InteractionManager.runAfterInteractions(() => {
// If a new comment is added and it's from the current user scroll to the bottom otherwise leave the user positioned where
// they are now in the list.
Expand All @@ -425,14 +427,42 @@ function ReportActionsList({
});
return;
}
const index = sortedVisibleReportActions.findIndex((item) => keyExtractor(item) === action?.reportActionID);
if (action?.actionName === CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW) {
if (index > 0) {
setTimeout(() => {
reportScrollManager.scrollToIndex(index);
}, 100);
} else {
setIsFloatingMessageCounterVisible(false);
reportScrollManager.scrollToBottom();
}
if (action?.reportActionID) {
setActionIdToHighlight(action.reportActionID);
}
} else {
setIsFloatingMessageCounterVisible(false);
reportScrollManager.scrollToBottom();
}

setIsFloatingMessageCounterVisible(false);
reportScrollManager.scrollToBottom();
setIsScrollToBottomEnabled(true);
});
},
[report.reportID, reportScrollManager, setIsFloatingMessageCounterVisible],
[report.reportID, reportScrollManager, setIsFloatingMessageCounterVisible, sortedVisibleReportActions, reportScrollManager],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somehow duplicate dependency is not flagged here. Strange.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird... Do you have a PR to fix it? Or should I open one?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great, thank you!

);

// Clear the highlighted report action after scrolling and highlighting
useEffect(() => {
if (actionIdToHighlight === '') {
return;
}
// Time highlight is the same as SearchPage
const timer = setTimeout(() => {
setActionIdToHighlight('');
}, durationHighlightItem);
return () => clearTimeout(timer);
}, [actionIdToHighlight]);

useEffect(() => {
// Why are we doing this, when in the cleanup of the useEffect we are already calling the unsubscribe function?
// Answer: On web, when navigating to another report screen, the previous report screen doesn't get unmounted,
Expand Down Expand Up @@ -608,6 +638,7 @@ function ReportActionsList({
isFirstVisibleReportAction={firstVisibleReportActionID === reportAction.reportActionID}
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
transactions={Object.values(transactions ?? {})}
shouldHighlight={actionIdToHighlight === reportAction.reportActionID}
/>
);
},
Expand All @@ -627,6 +658,7 @@ function ReportActionsList({
shouldUseThreadDividerLine,
firstVisibleReportActionID,
unreadMarkerReportActionID,
actionIdToHighlight,
],
);

Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/report/ReportActionsListItemRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type ReportActionsListItemRendererProps = {

/** If the thread divider line will be used */
shouldUseThreadDividerLine?: boolean;

/** Animate highlight action in few seconds */
shouldHighlight?: boolean;
};

function ReportActionsListItemRenderer({
Expand All @@ -81,6 +84,7 @@ function ReportActionsListItemRenderer({
shouldDisplayReplyDivider,
isFirstVisibleReportAction = false,
shouldUseThreadDividerLine = false,
shouldHighlight = false,
parentReportActionForTransactionThread,
}: ReportActionsListItemRendererProps) {
const originalMessage = useMemo(() => getOriginalMessage(reportAction), [reportAction]);
Expand Down Expand Up @@ -204,6 +208,7 @@ function ReportActionsListItemRenderer({
index={index}
isFirstVisibleReportAction={isFirstVisibleReportAction}
shouldUseThreadDividerLine={shouldUseThreadDividerLine}
shouldHighlight={shouldHighlight}
/>
);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/actions/IOUTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {WRITE_COMMANDS} from '@libs/API/types';
import type {ApiCommand} from '@libs/API/types';
import {getMicroSecondOnyxErrorWithTranslationKey} from '@libs/ErrorUtils';
import {translateLocal} from '@libs/Localize';
import Navigation from '@libs/Navigation/Navigation';
import {rand64} from '@libs/NumberUtils';
import {getLoginsByAccountIDs} from '@libs/PersonalDetailsUtils';
import {
Expand Down Expand Up @@ -1613,7 +1614,7 @@ describe('actions/IOU', () => {
comment: '',
},
});
expect(notifyNewAction).toHaveBeenCalledTimes(1);
expect(Navigation.setNavigationActionToMicrotaskQueue).toHaveBeenCalledTimes(1);
});
});

Expand Down