From f26b7b3e50f98ff26268b863c08efa3d89da8a5b Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Jan 2024 12:04:09 +0800 Subject: [PATCH 1/3] fix finally data isn't applied --- src/libs/actions/OnyxUpdates.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxUpdates.ts b/src/libs/actions/OnyxUpdates.ts index d89f10ee9c7b..25b4d85e7b88 100644 --- a/src/libs/actions/OnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdates.ts @@ -86,7 +86,7 @@ function apply({lastUpdateID, type, request, response, updates}: OnyxUpdatesFrom // In this case, we're already received the OnyxUpdate included in the response, so we don't need to apply it again. // However, we do need to apply the successData and failureData from the request - if (type === CONST.ONYX_UPDATE_TYPES.HTTPS && request && response && (!isEmptyObject(request.successData) || !isEmptyObject(request.failureData))) { + if (type === CONST.ONYX_UPDATE_TYPES.HTTPS && request && response && (!isEmptyObject(request.successData) || !isEmptyObject(request.failureData) || !isEmptyObject(request.finallyData))) { Log.info('[OnyxUpdateManager] Applying success or failure data from request without onyxData from response'); // We use a spread here instead of delete because we don't want to change the response for other middlewares From d910b92eafb244976c320892e02f6407ccd9f5ad Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Jan 2024 12:14:57 +0800 Subject: [PATCH 2/3] prettier --- src/libs/actions/OnyxUpdates.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/OnyxUpdates.ts b/src/libs/actions/OnyxUpdates.ts index 25b4d85e7b88..cfb4735f0638 100644 --- a/src/libs/actions/OnyxUpdates.ts +++ b/src/libs/actions/OnyxUpdates.ts @@ -86,7 +86,12 @@ function apply({lastUpdateID, type, request, response, updates}: OnyxUpdatesFrom // In this case, we're already received the OnyxUpdate included in the response, so we don't need to apply it again. // However, we do need to apply the successData and failureData from the request - if (type === CONST.ONYX_UPDATE_TYPES.HTTPS && request && response && (!isEmptyObject(request.successData) || !isEmptyObject(request.failureData) || !isEmptyObject(request.finallyData))) { + if ( + type === CONST.ONYX_UPDATE_TYPES.HTTPS && + request && + response && + (!isEmptyObject(request.successData) || !isEmptyObject(request.failureData) || !isEmptyObject(request.finallyData)) + ) { Log.info('[OnyxUpdateManager] Applying success or failure data from request without onyxData from response'); // We use a spread here instead of delete because we don't want to change the response for other middlewares From e46d522971b5235d0a718776529a434c841e5e02 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 18 Jan 2024 12:20:20 +0800 Subject: [PATCH 3/3] immediately update lhn list when changing priority mode --- src/pages/home/sidebar/SidebarLinksData.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/home/sidebar/SidebarLinksData.js b/src/pages/home/sidebar/SidebarLinksData.js index 580cc7909fd1..c816159e9384 100644 --- a/src/pages/home/sidebar/SidebarLinksData.js +++ b/src/pages/home/sidebar/SidebarLinksData.js @@ -10,6 +10,7 @@ import {withNetwork} from '@components/OnyxProvider'; import withCurrentReportID from '@components/withCurrentReportID'; import withNavigationFocus from '@components/withNavigationFocus'; import useLocalize from '@hooks/useLocalize'; +import usePrevious from '@hooks/usePrevious'; import useThemeStyles from '@hooks/useThemeStyles'; import compose from '@libs/compose'; import SidebarUtils from '@libs/SidebarUtils'; @@ -69,6 +70,7 @@ const defaultProps = { function SidebarLinksData({isFocused, allReportActions, betas, chatReports, currentReportID, insets, isLoadingApp, onLinkClick, policies, priorityMode, network}) { const styles = useThemeStyles(); const {translate} = useLocalize(); + const prevPriorityMode = usePrevious(priorityMode); const reportIDsRef = useRef(null); const isLoading = isLoadingApp; @@ -79,13 +81,14 @@ function SidebarLinksData({isFocused, allReportActions, betas, chatReports, curr return reportIDsRef.current; } - // We need to update existing reports only once while loading because they are updated several times during loading and causes this regression: https://github.com/Expensify/App/issues/24596#issuecomment-1681679531 - // However, if the user is offline, we need to update the reports unconditionally, since the loading of report data might be stuck in this case. - if (!isLoading || !reportIDsRef.current || network.isOffline) { + // 1. We need to update existing reports only once while loading because they are updated several times during loading and causes this regression: https://github.com/Expensify/App/issues/24596#issuecomment-1681679531 + // 2. If the user is offline, we need to update the reports unconditionally, since the loading of report data might be stuck in this case. + // 3. Changing priority mode to Most Recent will call OpenApp. If there is an existing reports and the priority mode is updated, we want to immediately update the list instead of waiting the OpenApp request to complete + if (!isLoading || !reportIDsRef.current || network.isOffline || (reportIDsRef.current && prevPriorityMode !== priorityMode)) { reportIDsRef.current = reportIDs; } return reportIDsRef.current || []; - }, [allReportActions, betas, chatReports, policies, priorityMode, isLoading, network.isOffline]); + }, [allReportActions, betas, chatReports, policies, prevPriorityMode, priorityMode, isLoading, network.isOffline]); // We need to make sure the current report is in the list of reports, but we do not want // to have to re-generate the list every time the currentReportID changes. To do that