From c89226e59df101d1569b97869b8ca0d93e695dcc Mon Sep 17 00:00:00 2001 From: Joseph Baylon Date: Tue, 12 Apr 2022 13:33:51 -0700 Subject: [PATCH] Moved conditional logbox to index.ts --- app/init/launch.ts | 9 +-------- babel.config.js | 2 +- types/env.d.ts => env.d.ts | 1 - index.ts | 12 ++++++++++-- 4 files changed, 12 insertions(+), 12 deletions(-) rename types/env.d.ts => env.d.ts (85%) diff --git a/app/init/launch.ts b/app/init/launch.ts index aa8d49779..c2af77a97 100644 --- a/app/init/launch.ts +++ b/app/init/launch.ts @@ -1,9 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {RUNNING_E2E} from '@env'; import Emm from '@mattermost/react-native-emm'; -import {Alert, Linking, LogBox, Platform} from 'react-native'; +import {Alert, Linking, Platform} from 'react-native'; import {Notifications} from 'react-native-notifications'; import {appEntry, pushNotificationEntry, upgradeEntry} from '@actions/remote/entry'; @@ -220,9 +219,3 @@ export const getLaunchPropsFromNotification = async (notification: NotificationW return launchProps; }; - -// Ignore all notifications if running e2e -const isRunningE2e = RUNNING_E2E === 'true'; -// eslint-disable-next-line no-console -console.log(`RUNNING_E2E: ${RUNNING_E2E}, isRunningE2e: ${isRunningE2e}`); -LogBox.ignoreAllLogs(isRunningE2e); diff --git a/babel.config.js b/babel.config.js index daeb43aea..08d6c97b3 100644 --- a/babel.config.js +++ b/babel.config.js @@ -45,7 +45,7 @@ module.exports = { }, }], ['module:react-native-dotenv', { - moduleName: '@env', + moduleName: 'react-native-dotenv', path: '.env', blacklist: null, whitelist: null, diff --git a/types/env.d.ts b/env.d.ts similarity index 85% rename from types/env.d.ts rename to env.d.ts index 109580c22..1b5ca9042 100644 --- a/types/env.d.ts +++ b/env.d.ts @@ -3,5 +3,4 @@ // So that typescript doesn't complain about importing `@env` through react-native-dotenv declare module '@env' { - export const RUNNING_E2E: string; } diff --git a/index.ts b/index.ts index f92fd8b6b..a260f5459 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,8 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import {DeviceEventEmitter, Platform} from 'react-native'; +import {DeviceEventEmitter, LogBox, Platform} from 'react-native'; +import {RUNNING_E2E} from 'react-native-dotenv'; import 'react-native-gesture-handler'; import {ComponentDidAppearEvent, ComponentDidDisappearEvent, Navigation} from 'react-native-navigation'; @@ -21,7 +22,6 @@ import setFontFamily from './app/utils/font_family'; declare const global: { HermesInternal: null | {} }; if (__DEV__) { - const LogBox = require('react-native/Libraries/LogBox/LogBox'); LogBox.ignoreLogs([ '`-[RCTRootView cancelTouches]`', 'scaleY', @@ -29,6 +29,14 @@ if (__DEV__) { 'new NativeEventEmitter', 'ViewPropTypes will be removed from React Native', ]); + + // Ignore all notifications if running e2e + const isRunningE2e = RUNNING_E2E === 'true'; + // eslint-disable-next-line no-console + console.log(`RUNNING_E2E: ${RUNNING_E2E}, isRunningE2e: ${isRunningE2e}`); + if (isRunningE2e) { + LogBox.ignoreAllLogs(true); + } } setFontFamily();