Skip to content

Commit 6463de6

Browse files
Merge pull request #34902 from Expensify/aldo_remove-reconnect-report
HIGH: Kill ReconnectToReport
2 parents 6abecc8 + 5c587e0 commit 6463de6

File tree

5 files changed

+2
-97
lines changed

5 files changed

+2
-97
lines changed

src/libs/API/parameters/ReconnectToReportParams.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/libs/API/parameters/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export type {default as VerifyIdentityForBankAccountParams} from './VerifyIdenti
7777
export type {default as AnswerQuestionsForWalletParams} from './AnswerQuestionsForWalletParams';
7878
export type {default as AddCommentOrAttachementParams} from './AddCommentOrAttachementParams';
7979
export type {default as OptInOutToPushNotificationsParams} from './OptInOutToPushNotificationsParams';
80-
export type {default as ReconnectToReportParams} from './ReconnectToReportParams';
8180
export type {default as ReadNewestActionParams} from './ReadNewestActionParams';
8281
export type {default as MarkAsUnreadParams} from './MarkAsUnreadParams';
8382
export type {default as TogglePinnedChatParams} from './TogglePinnedChatParams';

src/libs/API/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ const WRITE_COMMANDS = {
8686
RESTART_BANK_ACCOUNT_SETUP: 'RestartBankAccountSetup',
8787
OPT_IN_TO_PUSH_NOTIFICATIONS: 'OptInToPushNotifications',
8888
OPT_OUT_OF_PUSH_NOTIFICATIONS: 'OptOutOfPushNotifications',
89-
RECONNECT_TO_REPORT: 'ReconnectToReport',
9089
READ_NEWEST_ACTION: 'ReadNewestAction',
9190
MARK_AS_UNREAD: 'MarkAsUnread',
9291
TOGGLE_PINNED_CHAT: 'TogglePinnedChat',
@@ -272,7 +271,6 @@ type WriteCommandParameters = {
272271
[WRITE_COMMANDS.RESTART_BANK_ACCOUNT_SETUP]: Parameters.RestartBankAccountSetupParams;
273272
[WRITE_COMMANDS.OPT_IN_TO_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams;
274273
[WRITE_COMMANDS.OPT_OUT_OF_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams;
275-
[WRITE_COMMANDS.RECONNECT_TO_REPORT]: Parameters.ReconnectToReportParams;
276274
[WRITE_COMMANDS.READ_NEWEST_ACTION]: Parameters.ReadNewestActionParams;
277275
[WRITE_COMMANDS.MARK_AS_UNREAD]: Parameters.MarkAsUnreadParams;
278276
[WRITE_COMMANDS.TOGGLE_PINNED_CHAT]: Parameters.TogglePinnedChatParams;

src/libs/actions/Report.ts

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import type {
2727
OpenReportParams,
2828
OpenRoomMembersPageParams,
2929
ReadNewestActionParams,
30-
ReconnectToReportParams,
3130
RemoveEmojiReactionParams,
3231
RemoveFromRoomParams,
3332
ResolveActionableMentionWhisperParams,
@@ -888,54 +887,6 @@ function navigateToAndOpenChildReport(childReportID = '0', parentReportAction: P
888887
}
889888
}
890889

891-
/** Get the latest report history without marking the report as read. */
892-
function reconnect(reportID: string) {
893-
const optimisticData: OnyxUpdate[] = [
894-
{
895-
onyxMethod: Onyx.METHOD.MERGE,
896-
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
897-
value: {
898-
reportName: allReports?.[reportID]?.reportName ?? CONST.REPORT.DEFAULT_REPORT_NAME,
899-
},
900-
},
901-
{
902-
onyxMethod: Onyx.METHOD.MERGE,
903-
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`,
904-
value: {
905-
isLoadingInitialReportActions: true,
906-
isLoadingNewerReportActions: false,
907-
isLoadingOlderReportActions: false,
908-
},
909-
},
910-
];
911-
912-
const successData: OnyxUpdate[] = [
913-
{
914-
onyxMethod: Onyx.METHOD.MERGE,
915-
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`,
916-
value: {
917-
isLoadingInitialReportActions: false,
918-
},
919-
},
920-
];
921-
922-
const failureData: OnyxUpdate[] = [
923-
{
924-
onyxMethod: Onyx.METHOD.MERGE,
925-
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`,
926-
value: {
927-
isLoadingInitialReportActions: false,
928-
},
929-
},
930-
];
931-
932-
const parameters: ReconnectToReportParams = {
933-
reportID,
934-
};
935-
936-
API.write(WRITE_COMMANDS.RECONNECT_TO_REPORT, parameters, {optimisticData, successData, failureData});
937-
}
938-
939890
/**
940891
* Gets the older actions that have not been read yet.
941892
* Normally happens when you scroll up on a chat, and the actions have not been read yet.
@@ -1182,12 +1133,6 @@ function handleReportChanged(report: OnyxEntry<Report>) {
11821133
conciergeChatReportID = report.reportID;
11831134
}
11841135
}
1185-
1186-
// A report can be missing a name if a comment is received via pusher event and the report does not yet exist in Onyx (eg. a new DM created with the logged in person)
1187-
// In this case, we call reconnect so that we can fetch the report data without marking it as read
1188-
if (report.reportID && report.reportName === undefined) {
1189-
reconnect(report.reportID);
1190-
}
11911136
}
11921137

11931138
/** Deletes a comment from the report, basically sets it as empty string */
@@ -3031,7 +2976,6 @@ export {
30312976
searchInServer,
30322977
addComment,
30332978
addAttachment,
3034-
reconnect,
30352979
updateDescription,
30362980
updateWriteCapabilityAndNavigate,
30372981
updateNotificationPreference,

src/pages/home/report/ReportActionsView.tsx

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ function ReportActionsView({
104104
const {isSmallScreenWidth, windowHeight} = useWindowDimensions();
105105
const contentListHeight = useRef(0);
106106
const isFocused = useIsFocused();
107-
const prevNetworkRef = useRef(network);
108107
const prevAuthTokenType = usePrevious(session?.authTokenType);
109108
const [isNavigatingToLinkedMessage, setNavigatingToLinkedMessage] = useState(!!reportActionID);
110109
const prevIsSmallScreenWidthRef = useRef(isSmallScreenWidth);
@@ -119,14 +118,6 @@ function ReportActionsView({
119118
Report.openReport(reportID, reportActionID);
120119
};
121120

122-
const reconnectReportIfNecessary = () => {
123-
if (!shouldFetchReport(report)) {
124-
return;
125-
}
126-
127-
Report.reconnect(reportID);
128-
};
129-
130121
useLayoutEffect(() => {
131122
setCurrentReportActionID('');
132123
}, [route]);
@@ -273,35 +264,13 @@ function ReportActionsView({
273264
// eslint-disable-next-line react-hooks/exhaustive-deps
274265
}, [route, indexOfLinkedAction]);
275266

276-
useEffect(() => {
277-
const prevNetwork = prevNetworkRef.current;
278-
// When returning from offline to online state we want to trigger a request to OpenReport which
279-
// will fetch the reportActions data and mark the report as read. If the report is not fully visible
280-
// then we call ReconnectToReport which only loads the reportActions data without marking the report as read.
281-
const wasNetworkChangeDetected = prevNetwork.isOffline && !network.isOffline;
282-
if (wasNetworkChangeDetected) {
283-
if (isReportFullyVisible) {
284-
openReportIfNecessary();
285-
} else {
286-
reconnectReportIfNecessary();
287-
}
288-
}
289-
// update ref with current network state
290-
prevNetworkRef.current = network;
291-
// eslint-disable-next-line react-hooks/exhaustive-deps
292-
}, [network, isReportFullyVisible]);
293-
294267
useEffect(() => {
295268
const wasLoginChangedDetected = prevAuthTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS && !session?.authTokenType;
296269
if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(report)) {
297-
if (isReportFullyVisible) {
298-
openReportIfNecessary();
299-
} else {
300-
reconnectReportIfNecessary();
301-
}
270+
openReportIfNecessary();
302271
}
303272
// eslint-disable-next-line react-hooks/exhaustive-deps
304-
}, [session, report, isReportFullyVisible]);
273+
}, [session, report]);
305274

306275
useEffect(() => {
307276
const prevIsSmallScreenWidth = prevIsSmallScreenWidthRef.current;

0 commit comments

Comments
 (0)