@@ -4,6 +4,7 @@ import type {NativeEventSubscription} from 'react-native';
4
4
import { AppState , Linking , Platform } from 'react-native' ;
5
5
import type { OnyxEntry } from 'react-native-onyx' ;
6
6
import Onyx , { useOnyx } from 'react-native-onyx' ;
7
+ import alert from './components/Alert' ;
7
8
import ConfirmModal from './components/ConfirmModal' ;
8
9
import DeeplinkWrapper from './components/DeeplinkWrapper' ;
9
10
import EmojiPicker from './components/EmojiPicker/EmojiPicker' ;
@@ -24,6 +25,7 @@ import * as EmojiPickerAction from './libs/actions/EmojiPickerAction';
24
25
import * as Report from './libs/actions/Report' ;
25
26
import * as User from './libs/actions/User' ;
26
27
import * as ActiveClientManager from './libs/ActiveClientManager' ;
28
+ import * as Environment from './libs/Environment/Environment' ;
27
29
import FS from './libs/Fullstory' ;
28
30
import * as Growl from './libs/Growl' ;
29
31
import Log from './libs/Log' ;
@@ -45,14 +47,21 @@ import type {Route} from './ROUTES';
45
47
import SplashScreenStateContext from './SplashScreenStateContext' ;
46
48
import type { ScreenShareRequest } from './types/onyx' ;
47
49
48
- Onyx . registerLogger ( ( { level, message} ) => {
50
+ Onyx . registerLogger ( ( { level, message, parameters } ) => {
49
51
if ( level === 'alert' ) {
50
- Log . alert ( message ) ;
52
+ Log . alert ( message , parameters ) ;
51
53
console . error ( message ) ;
54
+
55
+ // useOnyx() calls with "canBeMissing" config set to false will display a visual alert in dev environment
56
+ // when they don't return data.
57
+ const shouldShowAlert = typeof parameters === 'object' && ! Array . isArray ( parameters ) && 'showAlert' in parameters && 'key' in parameters ;
58
+ if ( Environment . isDevelopment ( ) && shouldShowAlert ) {
59
+ alert ( `${ message } Key: ${ parameters . key as string } ` ) ;
60
+ }
52
61
} else if ( level === 'hmmm' ) {
53
- Log . hmmm ( message ) ;
62
+ Log . hmmm ( message , parameters ) ;
54
63
} else {
55
- Log . info ( message ) ;
64
+ Log . info ( message , undefined , parameters ) ;
56
65
}
57
66
} ) ;
58
67
@@ -85,17 +94,17 @@ function Expensify() {
85
94
const { splashScreenState, setSplashScreenState} = useContext ( SplashScreenStateContext ) ;
86
95
const [ hasAttemptedToOpenPublicRoom , setAttemptedToOpenPublicRoom ] = useState ( false ) ;
87
96
const { translate} = useLocalize ( ) ;
88
- const [ account ] = useOnyx ( ONYXKEYS . ACCOUNT ) ;
89
- const [ session ] = useOnyx ( ONYXKEYS . SESSION ) ;
90
- const [ lastRoute ] = useOnyx ( ONYXKEYS . LAST_ROUTE ) ;
91
- const [ userMetadata ] = useOnyx ( ONYXKEYS . USER_METADATA ) ;
92
- const [ isCheckingPublicRoom ] = useOnyx ( ONYXKEYS . IS_CHECKING_PUBLIC_ROOM , { initWithStoredValues : false } ) ;
93
- const [ updateAvailable ] = useOnyx ( ONYXKEYS . UPDATE_AVAILABLE , { initWithStoredValues : false } ) ;
94
- const [ updateRequired ] = useOnyx ( ONYXKEYS . UPDATE_REQUIRED , { initWithStoredValues : false } ) ;
95
- const [ isSidebarLoaded ] = useOnyx ( ONYXKEYS . IS_SIDEBAR_LOADED ) ;
96
- const [ screenShareRequest ] = useOnyx ( ONYXKEYS . SCREEN_SHARE_REQUEST ) ;
97
- const [ focusModeNotification ] = useOnyx ( ONYXKEYS . FOCUS_MODE_NOTIFICATION , { initWithStoredValues : false } ) ;
98
- const [ lastVisitedPath ] = useOnyx ( ONYXKEYS . LAST_VISITED_PATH ) ;
97
+ const [ account ] = useOnyx ( ONYXKEYS . ACCOUNT , { canBeMissing : true } ) ;
98
+ const [ session ] = useOnyx ( ONYXKEYS . SESSION , { canBeMissing : false } ) ;
99
+ const [ lastRoute ] = useOnyx ( ONYXKEYS . LAST_ROUTE , { canBeMissing : true } ) ;
100
+ const [ userMetadata ] = useOnyx ( ONYXKEYS . USER_METADATA , { canBeMissing : true } ) ;
101
+ const [ isCheckingPublicRoom ] = useOnyx ( ONYXKEYS . IS_CHECKING_PUBLIC_ROOM , { initWithStoredValues : false , canBeMissing : false } ) ;
102
+ const [ updateAvailable ] = useOnyx ( ONYXKEYS . UPDATE_AVAILABLE , { initWithStoredValues : false , canBeMissing : false } ) ;
103
+ const [ updateRequired ] = useOnyx ( ONYXKEYS . UPDATE_REQUIRED , { initWithStoredValues : false , canBeMissing : false } ) ;
104
+ const [ isSidebarLoaded ] = useOnyx ( ONYXKEYS . IS_SIDEBAR_LOADED , { canBeMissing : false } ) ;
105
+ const [ screenShareRequest ] = useOnyx ( ONYXKEYS . SCREEN_SHARE_REQUEST , { canBeMissing : true } ) ;
106
+ const [ focusModeNotification ] = useOnyx ( ONYXKEYS . FOCUS_MODE_NOTIFICATION , { initWithStoredValues : false , canBeMissing : false } ) ;
107
+ const [ lastVisitedPath ] = useOnyx ( ONYXKEYS . LAST_VISITED_PATH , { canBeMissing : false } ) ;
99
108
100
109
useDebugShortcut ( ) ;
101
110
0 commit comments