diff --git a/src/libs/API/parameters/ReconnectToReportParams.ts b/src/libs/API/parameters/ReconnectToReportParams.ts deleted file mode 100644 index e7701cd36ca9..000000000000 --- a/src/libs/API/parameters/ReconnectToReportParams.ts +++ /dev/null @@ -1,5 +0,0 @@ -type ReconnectToReportParams = { - reportID: string; -}; - -export default ReconnectToReportParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 87d9e2265568..1bc80e4c08c4 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -77,7 +77,6 @@ export type {default as VerifyIdentityForBankAccountParams} from './VerifyIdenti export type {default as AnswerQuestionsForWalletParams} from './AnswerQuestionsForWalletParams'; export type {default as AddCommentOrAttachementParams} from './AddCommentOrAttachementParams'; export type {default as OptInOutToPushNotificationsParams} from './OptInOutToPushNotificationsParams'; -export type {default as ReconnectToReportParams} from './ReconnectToReportParams'; export type {default as ReadNewestActionParams} from './ReadNewestActionParams'; export type {default as MarkAsUnreadParams} from './MarkAsUnreadParams'; export type {default as TogglePinnedChatParams} from './TogglePinnedChatParams'; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 9e6d4a6a5ecf..3cff726a530c 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -86,7 +86,6 @@ const WRITE_COMMANDS = { RESTART_BANK_ACCOUNT_SETUP: 'RestartBankAccountSetup', OPT_IN_TO_PUSH_NOTIFICATIONS: 'OptInToPushNotifications', OPT_OUT_OF_PUSH_NOTIFICATIONS: 'OptOutOfPushNotifications', - RECONNECT_TO_REPORT: 'ReconnectToReport', READ_NEWEST_ACTION: 'ReadNewestAction', MARK_AS_UNREAD: 'MarkAsUnread', TOGGLE_PINNED_CHAT: 'TogglePinnedChat', @@ -272,7 +271,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.RESTART_BANK_ACCOUNT_SETUP]: Parameters.RestartBankAccountSetupParams; [WRITE_COMMANDS.OPT_IN_TO_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams; [WRITE_COMMANDS.OPT_OUT_OF_PUSH_NOTIFICATIONS]: Parameters.OptInOutToPushNotificationsParams; - [WRITE_COMMANDS.RECONNECT_TO_REPORT]: Parameters.ReconnectToReportParams; [WRITE_COMMANDS.READ_NEWEST_ACTION]: Parameters.ReadNewestActionParams; [WRITE_COMMANDS.MARK_AS_UNREAD]: Parameters.MarkAsUnreadParams; [WRITE_COMMANDS.TOGGLE_PINNED_CHAT]: Parameters.TogglePinnedChatParams; diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 775d2459b0f3..a27f92ef8f57 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -27,7 +27,6 @@ import type { OpenReportParams, OpenRoomMembersPageParams, ReadNewestActionParams, - ReconnectToReportParams, RemoveEmojiReactionParams, RemoveFromRoomParams, ResolveActionableMentionWhisperParams, @@ -888,54 +887,6 @@ function navigateToAndOpenChildReport(childReportID = '0', parentReportAction: P } } -/** Get the latest report history without marking the report as read. */ -function reconnect(reportID: string) { - const optimisticData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, - value: { - reportName: allReports?.[reportID]?.reportName ?? CONST.REPORT.DEFAULT_REPORT_NAME, - }, - }, - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, - value: { - isLoadingInitialReportActions: true, - isLoadingNewerReportActions: false, - isLoadingOlderReportActions: false, - }, - }, - ]; - - const successData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, - value: { - isLoadingInitialReportActions: false, - }, - }, - ]; - - const failureData: OnyxUpdate[] = [ - { - onyxMethod: Onyx.METHOD.MERGE, - key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${reportID}`, - value: { - isLoadingInitialReportActions: false, - }, - }, - ]; - - const parameters: ReconnectToReportParams = { - reportID, - }; - - API.write(WRITE_COMMANDS.RECONNECT_TO_REPORT, parameters, {optimisticData, successData, failureData}); -} - /** * Gets the older actions that have not been read yet. * 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) { conciergeChatReportID = report.reportID; } } - - // 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) - // In this case, we call reconnect so that we can fetch the report data without marking it as read - if (report.reportID && report.reportName === undefined) { - reconnect(report.reportID); - } } /** Deletes a comment from the report, basically sets it as empty string */ @@ -3031,7 +2976,6 @@ export { searchInServer, addComment, addAttachment, - reconnect, updateDescription, updateWriteCapabilityAndNavigate, updateNotificationPreference, diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index 99fa266aa0de..e7bf0c1337cd 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -104,7 +104,6 @@ function ReportActionsView({ const {isSmallScreenWidth, windowHeight} = useWindowDimensions(); const contentListHeight = useRef(0); const isFocused = useIsFocused(); - const prevNetworkRef = useRef(network); const prevAuthTokenType = usePrevious(session?.authTokenType); const [isNavigatingToLinkedMessage, setNavigatingToLinkedMessage] = useState(!!reportActionID); const prevIsSmallScreenWidthRef = useRef(isSmallScreenWidth); @@ -119,14 +118,6 @@ function ReportActionsView({ Report.openReport(reportID, reportActionID); }; - const reconnectReportIfNecessary = () => { - if (!shouldFetchReport(report)) { - return; - } - - Report.reconnect(reportID); - }; - useLayoutEffect(() => { setCurrentReportActionID(''); }, [route]); @@ -273,35 +264,13 @@ function ReportActionsView({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [route, indexOfLinkedAction]); - useEffect(() => { - const prevNetwork = prevNetworkRef.current; - // When returning from offline to online state we want to trigger a request to OpenReport which - // will fetch the reportActions data and mark the report as read. If the report is not fully visible - // then we call ReconnectToReport which only loads the reportActions data without marking the report as read. - const wasNetworkChangeDetected = prevNetwork.isOffline && !network.isOffline; - if (wasNetworkChangeDetected) { - if (isReportFullyVisible) { - openReportIfNecessary(); - } else { - reconnectReportIfNecessary(); - } - } - // update ref with current network state - prevNetworkRef.current = network; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [network, isReportFullyVisible]); - useEffect(() => { const wasLoginChangedDetected = prevAuthTokenType === CONST.AUTH_TOKEN_TYPES.ANONYMOUS && !session?.authTokenType; if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(report)) { - if (isReportFullyVisible) { - openReportIfNecessary(); - } else { - reconnectReportIfNecessary(); - } + openReportIfNecessary(); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [session, report, isReportFullyVisible]); + }, [session, report]); useEffect(() => { const prevIsSmallScreenWidth = prevIsSmallScreenWidthRef.current;