Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: you've been switched to focus mode modal after open an expense on the Reports page #55764

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {findFocusedRoute} from '@react-navigation/native';
import {findFocusedRoute, useNavigation} from '@react-navigation/native';
import React, {memo, useEffect, useMemo, useRef, useState} from 'react';
import {NativeModules, View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
Expand Down Expand Up @@ -248,6 +248,14 @@ function AuthScreens() {
const isInitialLastUpdateIDAppliedToClientLoading = isLoadingOnyxValue(initialLastUpdateIDAppliedToClientStatus);
const isLastOpenedPublicRoomIDLoadedRef = useRef(false);
const isInitialLastUpdateIDAppliedToClientLoadedRef = useRef(false);
const navigation = useNavigation();

useEffect(() => {
const unsubscribe = navigation.addListener('state', () => {
PriorityMode.autoSwitchToFocusMode();
});
return () => unsubscribe();
}, [navigation]);

// On HybridApp we need to prevent flickering during transition to OldDot
const shouldRenderOnboardingExclusivelyOnHybridApp = useMemo(() => {
Expand Down
12 changes: 12 additions & 0 deletions src/libs/actions/PriorityMode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import debounce from 'lodash/debounce';
import Onyx from 'react-native-onyx';
import type {OnyxCollection} from 'react-native-onyx';
import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import Log from '@libs/Log';
import navigationRef from '@libs/Navigation/navigationRef';
import {isReportParticipant, isValidReport} from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import SCREENS from '@src/SCREENS';
import type {Report} from '@src/types/onyx';

/**
Expand Down Expand Up @@ -101,6 +104,15 @@ function tryFocusModeUpdate() {
return;
}

const currentRoute = navigationRef.getCurrentRoute();
if (getIsNarrowLayout()) {
if (currentRoute?.name !== SCREENS.HOME) {
return;
}
} else if (currentRoute?.name !== SCREENS.REPORT) {
return;
}

// Check to see if the user is using #focus mode, has tried it before, or we have already switched them over automatically.
if ((isInFocusMode ?? false) || hasTriedFocusMode) {
Log.info('Not switching user to optimized focus mode.', false, {isInFocusMode, hasTriedFocusMode});
Expand Down
Loading