-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HIGH: (Comment linking: Step 4) Main "glue" PR for Comment Linking #30269
Conversation
…ntPosition' of https://github.com/margelo/expensify-app-fork into feat/#Expensify#23229-linking
…rgelo/expensify-app-fork; branch 'main' of https://github.com/Expensify/App into feat/#Expensify#23229-linking
I think this may be causing this blocker: #38839 |
Another blocker this may be causing: #38848 |
This may be causing this blocker: #38870 |
This may also be the cause for #38869. We're calling |
I've traced this to
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 1.4.56-8 🚀
|
|
||
if (isFirstLinkedActionRender.current) { | ||
return allReportActions.slice(indexOfLinkedAction); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coming from #38979
Encountered this bug when working on integrating comment linking with reports links :
Recording.2024-04-02.150523.mp4
Steps:
- Send some messages
- Hover over the last message and click on Reply in thread
- Click on parent thread link
- Send a message
Expected Result:
We can scroll to the newest sent message.
Actual Result:
New sent message is not displayed until refresh or scroll to top then to down (rerender)
I see that the new message is added to allReportActions
but not to reportActions
.
@perunt could you please guide on how can I fix this? why do we slice allReportActions
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isFirstLinkedActionRender.current
is true only for the first render when we position the linked message. We slice it from the older messages to the linked message so that the linked message is located at the bottom. Then, fetchNewer is called, and we expand this with new items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found the cause of the bug: when we already have messages after the linked message, loadNewerChats
and handleReportActionPagination
are called and isFirstLinkedActionRender.current
is set to false
, but when the linked message is the last message in the report handleReportActionPagination
is not called (based on hasNewestReportAction
) and isFirstLinkedActionRender.current
remains true
.
I fixed it by adding this code in loadNewerChats
function:
if (reportActionID && indexOfLinkedAction > -1 && hasNewestReportAction && isFirstLinkedActionRender.current) {
isFirstLinkedActionRender.current = false;
setCurrentReportActionID(newestReportAction?.reportActionID);
}
const listID = useMemo(() => { | ||
isFirstLinkedActionRender.current = true; | ||
const newID = generateNewRandomInt(listOldID, 1, Number.MAX_SAFE_INTEGER); | ||
listOldID = newID; | ||
return newID; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [route, isLoadingInitialReportActions]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This caused #38909 – the fix was to early return if no reportActionID
is provided, to trigger re-calculation only in the comment linking flow.
This caused an issue in #38878 where the composer would defocus when trying to edit the parent message in a thread (i.e. 1 level deep). This happens because the App/src/pages/home/report/ReportActionItem.tsx Lines 798 to 800 in d8361ee
which then navigates to itself. The solution is to block the |
@@ -548,7 +602,7 @@ function ReportActionsList({ | |||
ref={reportScrollManager.ref} | |||
testID="report-actions-list" | |||
style={styles.overscrollBehaviorContain} | |||
data={sortedReportActions} | |||
data={sortedVisibleReportActions} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same data(sortedVisibleReportActions
) we need to pass to the renderItem prop displayAsGroup
for consistency. This inconsistency causes the issue #38830 on deleting the comment.
const reportID = report.reportID; | ||
const hasNewestReportAction = reportActions[0]?.isNewestReportAction; | ||
const isLoading = (!!reportActionID && isLoadingInitialReportActions) || !isReadyForCommentLinking; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@perunt Coming from this issue, we're considering a proposal that would change the isLoading
property to:
const isLoading = !!reportActionID && isLoadingInitialReportActions && !isReadyForCommentLinking;
This is in order to stop setting the reportActions
array to empty here
App/src/pages/home/report/ReportActionsView.tsx
Lines 165 to 167 in 2a6d63d
if (isLoading || indexOfLinkedAction === -1) { | |
return []; | |
} |
for cases where we already have the whole report and actions available in Onyx.
My problem is that I am a bit unsure what isLoadingInitialReportActions
part is actually doing here. Are you able to explain why it's needed and/or what case it handles?
My guess is that it shouldn't be true if we've already opened the report and are just returning to it, i.e.
- Open some report (non-comment linked, so
reportActionID
evaluates as falsey) - Navigate away and then return to that report via a comment link, so
reportActionID
will be true isLoadingInitialReportActions
should not be true as we already have all thereportActions
from (1), soisLoading
will be false (assumingisReadyForCommentLinking
is true).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@perunt bump, what do you think about the above proposal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay to me, but we need to be sure that we don't skip the first frame of rendering, as the whole positioning would be glitching. So, for testing this proposal, please use the test steps from this PR as well
const isLinkedReportActionDeleted = useMemo(() => { | ||
if (!reportActionIDFromRoute || !sortedAllReportActions) { | ||
return false; | ||
} | ||
const action = sortedAllReportActions.find((item) => item.reportActionID === reportActionIDFromRoute); | ||
return action && ReportActionsUtils.isDeletedAction(action); | ||
}, [reportActionIDFromRoute, sortedAllReportActions]); | ||
|
||
if (isLinkedReportActionDeleted ?? (!shouldShowSkeleton && reportActionIDFromRoute && reportActions?.length === 0 && !isLinkingToMessage)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have considered whisper actions which the user does not have access to here. This later caused #41370
// AutoScroll is disabled when we do linking to a specific reportAction | ||
const shouldEnableAutoScroll = hasNewestReportAction && (!reportActionID || !isNavigatingToLinkedMessage); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also auto scroll if we switch from many-transactions-view to one-transaction-view (Coming from #47584)
Details
This update adds a Comment Linking feature to our project, enabling users to navigate through chat histories by clicking links in the report. This allows quick jumps to different parts of the conversation.
Fixed Issues
$ #20282
PROPOSAL:
Tests
Test 1: Basic Navigation
Note: Links can be copied to any message and used in any order.
Test 2: Popup Navigation
Test 3: Cache and Logout
Test 4:
Notes:
Ensure the chat contains at least 150 messages. Initially, up to 50 messages are rendered. Navigating to the 70th message should allow further navigation up to the 150th message, even with gaps.
If bugs are found, confirm they are reproducible on another account, or provide credentials for debugging. Thsnks!
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
2024-01-09.15.32.57.mp4
Android: mWeb Chrome
2024-01-09.15.05.40.mp4
iOS: Native
Simulator.Screen.Recording.-.14.Pro.-.2024-01-09.at.14.25.25.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
ch.480.mov
S.720.mov
MacOS: Desktop
Untitled.2.mov