Skip to content

Commit

Permalink
Merge pull request #34702 from bernhardoj/fix/34466-switching-priorit…
Browse files Browse the repository at this point in the history
…y-mode

Fix switching priority mode to focus still shows read chats
  • Loading branch information
dangrous authored Jan 18, 2024
2 parents 599c005 + e46d522 commit bcd783f
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 @@ -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';
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit bcd783f

Please sign in to comment.