Skip to content

Commit

Permalink
update after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
perunt committed Jan 30, 2024
1 parent 82b7e8b commit 1f90068
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/libs/API/parameters/OpenReportParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type OpenReportParams = {
reportID: string;
reportActionID?: string;
emailList?: string;
accountIDList?: string;
parentReportActionID?: string;
Expand Down
21 changes: 16 additions & 5 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function ReportActionsView({reportActions: allReportActions, ...props}) {
const mostRecentIOUReportActionID = useMemo(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions), [props.reportActions]);
const prevNetworkRef = useRef(props.network);
const prevAuthTokenType = usePrevious(props.session.authTokenType);
const [isInitialLinkedView, setIsInitialLinkedView] = useState(false);
const [isInitialLinkedView, setIsInitialLinkedView] = useState(!!reportActionID);
const prevIsSmallScreenWidthRef = useRef(props.isSmallScreenWidth);
const reportID = props.report.reportID;
const isLoading = (!!reportActionID && props.isLoadingInitialReportActions) || !props.isReadyForCommentLinking;
Expand Down Expand Up @@ -430,14 +430,25 @@ function ReportActionsView({reportActions: allReportActions, ...props}) {
const isTheFirstReportActionIsLinked = firstReportActionID === reportActionID;

useEffect(() => {
let timerId;

if (isTheFirstReportActionIsLinked) {
// this should be applied after we navigated to linked reportAction
setIsInitialLinkedView(true);
} else {
// After navigating to the linked reportAction, apply this to correctly set
// `autoscrollToTopThreshold` prop when linking to a specific reportAction.
InteractionManager.runAfterInteractions(() => {
setIsInitialLinkedView(true);
// Using a short delay to ensure the view is updated after interactions
timerId = setTimeout(() => setIsInitialLinkedView(false), 10);
});
} else {
setIsInitialLinkedView(false);
}

return () => {
if (!timerId) {
return;
}
clearTimeout(timerId);
};
}, [isTheFirstReportActionIsLinked]);

// Comments have not loaded at all yet do nothing
Expand Down

0 comments on commit 1f90068

Please sign in to comment.