Skip to content

Commit 3905b5e

Browse files
authored
Merge pull request #42396 from narefyev91/fix-broken-view-of-linked-messages
Fix linked message visibility in offline mode
2 parents 71db7b7 + 6e35566 commit 3905b5e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/libs/actions/Report.ts

+8
Original file line numberDiff line numberDiff line change
@@ -3579,6 +3579,13 @@ function updateLastVisitTime(reportID: string) {
35793579
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, {lastVisitTime: DateUtils.getDBTime()});
35803580
}
35813581

3582+
function updateLoadingInitialReportAction(reportID: string) {
3583+
if (!ReportUtils.isValidReportIDFromPath(reportID)) {
3584+
return;
3585+
}
3586+
Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, {isLoadingInitialReportActions: false});
3587+
}
3588+
35823589
function clearNewRoomFormError() {
35833590
Onyx.set(ONYXKEYS.FORMS.NEW_ROOM_FORM, {
35843591
isLoading: false,
@@ -3819,6 +3826,7 @@ export {
38193826
leaveGroupChat,
38203827
removeFromGroupChat,
38213828
updateGroupChatMemberRoles,
3829+
updateLoadingInitialReportAction,
38223830
clearAddRoomMemberError,
38233831
clearAvatarErrors,
38243832
};

src/pages/home/report/ReportActionsView.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ function ReportActionsView({
104104
const didLayout = useRef(false);
105105
const didLoadOlderChats = useRef(false);
106106
const didLoadNewerChats = useRef(false);
107+
const {isOffline} = useNetwork();
107108

108109
// triggerListID is used when navigating to a chat with messages loaded from LHN. Typically, these include thread actions, task actions, etc. Since these messages aren't the latest,we don't maintain their position and instead trigger a recalculation of their positioning in the list.
109110
// we don't set currentReportActionID on initial render as linkedID as it should trigger visibleReportActions after linked message was positioned
@@ -128,6 +129,14 @@ function ReportActionsView({
128129
Report.openReport(reportID, reportActionID);
129130
};
130131

132+
useEffect(() => {
133+
// When we linked to message - we do not need to wait for initial actions - they already exists
134+
if (!reportActionID || !isOffline) {
135+
return;
136+
}
137+
Report.updateLoadingInitialReportAction(report.reportID);
138+
}, [isOffline, report.reportID, reportActionID]);
139+
131140
useLayoutEffect(() => {
132141
setCurrentReportActionID('');
133142
}, [route]);
@@ -199,7 +208,7 @@ function ReportActionsView({
199208
*/
200209
const fetchNewerAction = useCallback(
201210
(newestReportAction: OnyxTypes.ReportAction) => {
202-
if (isLoadingNewerReportActions || isLoadingInitialReportActions) {
211+
if (isLoadingNewerReportActions || isLoadingInitialReportActions || (reportActionID && isOffline)) {
203212
return;
204213
}
205214

@@ -216,7 +225,7 @@ function ReportActionsView({
216225
Report.getNewerActions(reportID, newestReportAction.reportActionID);
217226
}
218227
},
219-
[isLoadingNewerReportActions, isLoadingInitialReportActions, reportID, transactionThreadReport, reportActionIDMap],
228+
[isLoadingNewerReportActions, isLoadingInitialReportActions, reportActionID, isOffline, transactionThreadReport, reportActionIDMap, reportID],
220229
);
221230

222231
const hasMoreCached = reportActions.length < combinedReportActions.length;
@@ -348,7 +357,6 @@ function ReportActionsView({
348357
// If there was an error only try again once on initial mount. We should also still load
349358
// more in case we have cached messages.
350359
(!hasMoreCached && didLoadNewerChats.current && hasLoadingNewerReportActionsError) ||
351-
network.isOffline ||
352360
newestReportAction.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE)
353361
) {
354362
return;

0 commit comments

Comments
 (0)