-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Enable ESLint rule / DEV alert() to match with useOnyx canBeMissing option
#59191
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
Changes from all commits
3222ed4
8b4a297
e176d98
7898916
93f5abb
029edb5
10dc598
6d29c21
a8781a7
926b8f7
5160138
e0d7e67
81239b1
e6acb78
f03fe09
a6b0dfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import type {NativeEventSubscription} from 'react-native'; | |
| import {AppState, Linking, Platform} from 'react-native'; | ||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
| import Onyx, {useOnyx} from 'react-native-onyx'; | ||
| import alert from './components/Alert'; | ||
| import ConfirmModal from './components/ConfirmModal'; | ||
| import DeeplinkWrapper from './components/DeeplinkWrapper'; | ||
| import EmojiPicker from './components/EmojiPicker/EmojiPicker'; | ||
|
|
@@ -24,6 +25,7 @@ import * as EmojiPickerAction from './libs/actions/EmojiPickerAction'; | |
| import * as Report from './libs/actions/Report'; | ||
| import * as User from './libs/actions/User'; | ||
| import * as ActiveClientManager from './libs/ActiveClientManager'; | ||
| import * as Environment from './libs/Environment/Environment'; | ||
| import FS from './libs/Fullstory'; | ||
| import * as Growl from './libs/Growl'; | ||
| import Log from './libs/Log'; | ||
|
|
@@ -45,14 +47,21 @@ import type {Route} from './ROUTES'; | |
| import SplashScreenStateContext from './SplashScreenStateContext'; | ||
| import type {ScreenShareRequest} from './types/onyx'; | ||
|
|
||
| Onyx.registerLogger(({level, message}) => { | ||
| Onyx.registerLogger(({level, message, parameters}) => { | ||
| if (level === 'alert') { | ||
| Log.alert(message); | ||
| Log.alert(message, parameters); | ||
| console.error(message); | ||
|
|
||
| // useOnyx() calls with "canBeMissing" config set to false will display a visual alert in dev environment | ||
| // when they don't return data. | ||
| const shouldShowAlert = typeof parameters === 'object' && !Array.isArray(parameters) && 'showAlert' in parameters && 'key' in parameters; | ||
| if (Environment.isDevelopment() && shouldShowAlert) { | ||
| alert(`${message} Key: ${parameters.key as string}`); | ||
| } | ||
| } else if (level === 'hmmm') { | ||
| Log.hmmm(message); | ||
| Log.hmmm(message, parameters); | ||
| } else { | ||
| Log.info(message); | ||
| Log.info(message, undefined, parameters); | ||
| } | ||
| }); | ||
|
|
||
|
|
@@ -85,17 +94,17 @@ function Expensify() { | |
| const {splashScreenState, setSplashScreenState} = useContext(SplashScreenStateContext); | ||
| const [hasAttemptedToOpenPublicRoom, setAttemptedToOpenPublicRoom] = useState(false); | ||
| const {translate} = useLocalize(); | ||
| const [account] = useOnyx(ONYXKEYS.ACCOUNT); | ||
| const [session] = useOnyx(ONYXKEYS.SESSION); | ||
| const [lastRoute] = useOnyx(ONYXKEYS.LAST_ROUTE); | ||
| const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA); | ||
| const [isCheckingPublicRoom] = useOnyx(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, {initWithStoredValues: false}); | ||
| const [updateAvailable] = useOnyx(ONYXKEYS.UPDATE_AVAILABLE, {initWithStoredValues: false}); | ||
| const [updateRequired] = useOnyx(ONYXKEYS.UPDATE_REQUIRED, {initWithStoredValues: false}); | ||
| const [isSidebarLoaded] = useOnyx(ONYXKEYS.IS_SIDEBAR_LOADED); | ||
| const [screenShareRequest] = useOnyx(ONYXKEYS.SCREEN_SHARE_REQUEST); | ||
| const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false}); | ||
| const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH); | ||
| const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true}); | ||
| const [session] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false}); | ||
| const [lastRoute] = useOnyx(ONYXKEYS.LAST_ROUTE, {canBeMissing: true}); | ||
| const [userMetadata] = useOnyx(ONYXKEYS.USER_METADATA, {canBeMissing: true}); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| const [isCheckingPublicRoom] = useOnyx(ONYXKEYS.IS_CHECKING_PUBLIC_ROOM, {initWithStoredValues: false, canBeMissing: false}); | ||
| const [updateAvailable] = useOnyx(ONYXKEYS.UPDATE_AVAILABLE, {initWithStoredValues: false, canBeMissing: false}); | ||
| const [updateRequired] = useOnyx(ONYXKEYS.UPDATE_REQUIRED, {initWithStoredValues: false, canBeMissing: false}); | ||
| const [isSidebarLoaded] = useOnyx(ONYXKEYS.IS_SIDEBAR_LOADED, {canBeMissing: false}); | ||
| const [screenShareRequest] = useOnyx(ONYXKEYS.SCREEN_SHARE_REQUEST, {canBeMissing: true}); | ||
| const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false, canBeMissing: false}); | ||
| const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH, {canBeMissing: false}); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then this key can be missing so we should set this to |
||
|
|
||
| useDebugShortcut(); | ||
|
|
||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This key can be missing? Is it when you are logged out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accountwill alert if i'm logged out and I click one of these