From 404732f89f3c9c3032db907ef6b4acb47b5c9059 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Mon, 22 Jan 2024 13:34:48 -0300 Subject: [PATCH 1/6] Kill ReconnectToReport --- src/libs/actions/Report.ts | 59 ---------------------- src/pages/home/report/ReportActionsView.js | 29 +---------- 2 files changed, 2 insertions(+), 86 deletions(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 2ac85dfafa27..72b977d01e7d 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -767,58 +767,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, - }, - }, - ]; - - type ReconnectToReportParameters = { - reportID: string; - }; - - const parameters: ReconnectToReportParameters = { - reportID, - }; - - API.write('ReconnectToReport', 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. @@ -1095,12 +1043,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); - } } Onyx.connect({ @@ -2654,7 +2596,6 @@ export { searchInServer, addComment, addAttachment, - reconnect, updateWelcomeMessage, updateWriteCapabilityAndNavigate, updateNotificationPreference, diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index 2758437a3962..d2ec0f124a62 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -88,10 +88,7 @@ function ReportActionsView(props) { const isFirstRender = useRef(true); const hasCachedActions = useInitialValue(() => _.size(props.reportActions) > 0); const mostRecentIOUReportActionID = useInitialValue(() => ReportActionsUtils.getMostRecentIOURequestActionID(props.reportActions)); - - const prevNetworkRef = useRef(props.network); const prevAuthTokenType = usePrevious(props.session.authTokenType); - const prevIsSmallScreenWidthRef = useRef(props.isSmallScreenWidth); const isFocused = useIsFocused(); @@ -118,36 +115,14 @@ function ReportActionsView(props) { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - 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 = lodashGet(prevNetwork, 'isOffline') && !lodashGet(props.network, 'isOffline'); - if (wasNetworkChangeDetected) { - if (isReportFullyVisible) { - openReportIfNecessary(); - } else { - Report.reconnect(reportID); - } - } - // update ref with current network state - prevNetworkRef.current = props.network; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [props.network, props.report, isReportFullyVisible]); useEffect(() => { const wasLoginChangedDetected = prevAuthTokenType === 'anonymousAccount' && !props.session.authTokenType; if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(props.report)) { - if (isReportFullyVisible) { - openReportIfNecessary(); - } else { - Report.reconnect(reportID); - } + openReportIfNecessary(); } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [props.session, props.report, isReportFullyVisible]); - + }, [props.session, props.report]); useEffect(() => { const prevIsSmallScreenWidth = prevIsSmallScreenWidthRef.current; // If the view is expanded from mobile to desktop layout From 0b4b6669a894f02f91af23fcac12e66e309e9494 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Mon, 22 Jan 2024 16:51:10 -0300 Subject: [PATCH 2/6] Lint --- src/pages/home/report/ReportActionsView.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.js b/src/pages/home/report/ReportActionsView.js index d2ec0f124a62..adb771ed4f81 100755 --- a/src/pages/home/report/ReportActionsView.js +++ b/src/pages/home/report/ReportActionsView.js @@ -115,7 +115,6 @@ function ReportActionsView(props) { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - useEffect(() => { const wasLoginChangedDetected = prevAuthTokenType === 'anonymousAccount' && !props.session.authTokenType; if (wasLoginChangedDetected && didUserLogInDuringSession() && isUserCreatedPolicyRoom(props.report)) { From 7cb1ab1488cea0938710d2b5af8ad68653eac55b Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Wed, 31 Jan 2024 12:58:51 -0800 Subject: [PATCH 3/6] Delete unused params for deleted command ReconnectToReport --- src/libs/API/parameters/ReconnectToReportParams.ts | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 src/libs/API/parameters/ReconnectToReportParams.ts 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; From 10360a32be5e48825a62ce4fd058f494a5020cc1 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Wed, 31 Jan 2024 15:21:02 -0800 Subject: [PATCH 4/6] Remove ReconnectToReportParams --- src/libs/API/parameters/index.ts | 1 - src/libs/API/types.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index 039398c0fbf6..0fd627ec7f9f 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -76,7 +76,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 f58ebc30b4a2..f17645a3e3ac 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -185,7 +185,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.ADD_PERSONAL_BANK_ACCOUNT]: Parameters.AddPersonalBankAccountParams; [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; From ea3f7b6139ca6f62ba3e24a3df3baa908d1b84a1 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Wed, 27 Mar 2024 21:24:38 -0700 Subject: [PATCH 5/6] Remove unused type --- src/libs/API/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 89c929a87c93..10ba657d397c 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', From 278c3f11ab19f1cc9a48dbfe6916df275d9cac69 Mon Sep 17 00:00:00 2001 From: Aldo Canepa Date: Mon, 1 Apr 2024 20:05:24 -0700 Subject: [PATCH 6/6] Remove unused variable --- src/pages/home/report/ReportActionsView.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/report/ReportActionsView.tsx b/src/pages/home/report/ReportActionsView.tsx index dd2b1b867d83..472964986c46 100755 --- a/src/pages/home/report/ReportActionsView.tsx +++ b/src/pages/home/report/ReportActionsView.tsx @@ -88,7 +88,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);