Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into cdanwards/violation…
Browse files Browse the repository at this point in the history
…s/transaction-thread-violations

# Conflicts:
#	src/pages/home/sidebar/SidebarLinksData.js
  • Loading branch information
trevor-coleman committed Jan 18, 2024
2 parents 7305a48 + bcd783f commit 6e8ebca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/libs/actions/OnyxUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
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
Expand Down
11 changes: 7 additions & 4 deletions src/pages/home/sidebar/SidebarLinksData.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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';
Expand Down Expand Up @@ -98,6 +99,7 @@ const defaultProps = {
function SidebarLinksData({isFocused, allReportActions, betas, chatReports, currentReportID, insets, isLoadingApp, onLinkClick, policies, priorityMode, network, transactionViolations}) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const prevPriorityMode = usePrevious(priorityMode);

const reportIDsRef = useRef(null);
const isLoading = isLoadingApp;
Expand All @@ -108,13 +110,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, transactionViolations]);
}, [allReportActions, betas, chatReports, policies, prevPriorityMode, priorityMode, isLoading, network.isOffline, transactionViolations]);

// 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
Expand Down

0 comments on commit 6e8ebca

Please sign in to comment.