From 4660822311f2437ccb2ca63a0725694b38805c78 Mon Sep 17 00:00:00 2001 From: GOVINDDIXIT Date: Mon, 27 Jul 2020 21:35:26 +0530 Subject: [PATCH] use negation for builds --- android/app/build.gradle | 4 ++-- .../java/chat/rocket/reactnative/MainApplication.java | 2 +- app/constants/environment.js | 2 +- app/index.js | 4 ++-- app/notifications/push/index.js | 4 ++-- app/utils/log/index.js | 8 ++++---- app/utils/review.js | 4 ++-- app/views/SettingsView/index.js | 10 +++++----- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index fd1ec2be0..2704965e7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -194,11 +194,11 @@ android { productFlavors { foss { dimension = "type" - buildConfigField "boolean", "PLAY_BUILD", "false" + buildConfigField "boolean", "FDROID_BUILD", "true" } play { dimension = "type" - buildConfigField "boolean", "PLAY_BUILD", "true" + buildConfigField "boolean", "FDROID_BUILD", "false" } } diff --git a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java index b3fe24c20..d00aad101 100644 --- a/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java +++ b/android/app/src/main/java/chat/rocket/reactnative/MainApplication.java @@ -49,7 +49,7 @@ public class MainApplication extends Application implements ReactApplication, IN protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); - if (BuildConfig.PLAY_BUILD) { + if (!BuildConfig.FDROID_BUILD) { packages.add(new RNNotificationsPackage(MainApplication.this)); } packages.add(new KeyboardInputPackage(MainApplication.this)); diff --git a/app/constants/environment.js b/app/constants/environment.js index 15f70a619..099d27d1c 100644 --- a/app/constants/environment.js +++ b/app/constants/environment.js @@ -1,3 +1,3 @@ import RNConfigReader from 'react-native-config-reader'; -export const isGooglePlayBuild = RNConfigReader.PLAY_BUILD; +export const isFDroidBuild = RNConfigReader.FDROID_BUILD; diff --git a/app/index.js b/app/index.js index d93fa2185..8154208bb 100644 --- a/app/index.js +++ b/app/index.js @@ -36,7 +36,7 @@ import Toast from './containers/Toast'; import InAppNotification from './containers/InAppNotification'; import { ActionSheetProvider } from './containers/ActionSheet'; import debounce from './utils/debounce'; -import { isGooglePlayBuild } from './constants/environment'; +import { isFDroidBuild } from './constants/environment'; RNScreens.enableScreens(); @@ -59,7 +59,7 @@ export default class Root extends React.Component { constructor(props) { super(props); this.init(); - if (isGooglePlayBuild) { + if (!isFDroidBuild) { this.initCrashReport(); } const { width, height, scale } = Dimensions.get('window'); diff --git a/app/notifications/push/index.js b/app/notifications/push/index.js index fc232e06a..7e867801b 100644 --- a/app/notifications/push/index.js +++ b/app/notifications/push/index.js @@ -2,7 +2,7 @@ import EJSON from 'ejson'; import PushNotification from './push'; import store from '../../lib/createStore'; import { deepLinkingOpen } from '../../actions/deepLinking'; -import { isGooglePlayBuild } from '../../constants/environment'; +import { isFDroidBuild } from '../../constants/environment'; export const onNotification = (notification) => { if (notification) { @@ -37,7 +37,7 @@ export const onNotification = (notification) => { export const getDeviceToken = () => PushNotification.getDeviceToken(); export const setBadgeCount = count => PushNotification.setBadgeCount(count); export const initializePushNotifications = () => { - if (isGooglePlayBuild) { + if (!isFDroidBuild) { setBadgeCount(); return PushNotification.configure({ onNotification diff --git a/app/utils/log/index.js b/app/utils/log/index.js index 074026ed1..c772a1618 100644 --- a/app/utils/log/index.js +++ b/app/utils/log/index.js @@ -1,7 +1,7 @@ import { Client } from 'bugsnag-react-native'; import analytics from '@react-native-firebase/analytics'; import crashlytics from '@react-native-firebase/crashlytics'; -import { isGooglePlayBuild } from '../../constants/environment'; +import { isFDroidBuild } from '../../constants/environment'; import config from '../../../config'; import events from './events'; @@ -21,14 +21,14 @@ export const logServerVersion = (serverVersion) => { }; export const logEvent = (eventName, payload) => { - if (isGooglePlayBuild) { + if (!isFDroidBuild) { analytics().logEvent(eventName, payload); leaveBreadcrumb(eventName, payload); } }; export const setCurrentScreen = (currentScreen) => { - if (isGooglePlayBuild) { + if (!isFDroidBuild) { analytics().setCurrentScreen(currentScreen); leaveBreadcrumb(currentScreen, { type: 'navigation' }); } @@ -43,7 +43,7 @@ export default (e) => { } }; }); - if (isGooglePlayBuild) { + if (!isFDroidBuild) { crashlytics().recordError(e); } } else { diff --git a/app/utils/review.js b/app/utils/review.js index 378cc65eb..6eb258115 100644 --- a/app/utils/review.js +++ b/app/utils/review.js @@ -5,7 +5,7 @@ import { isIOS } from './deviceInfo'; import I18n from '../i18n'; import { showErrorAlert } from './info'; import { STORE_REVIEW_LINK } from '../constants/links'; -import { isGooglePlayBuild } from '../constants/environment'; +import { isFDroidBuild } from '../constants/environment'; const store = isIOS ? 'App Store' : 'Play Store'; @@ -76,7 +76,7 @@ const tryReview = async() => { // if ask me later was pressed earlier, we can ask for review only after {{numberOfDays}} days // if there's no review and it wasn't dismissed by the user - if (daysBetween(lastReviewDate, new Date()) >= numberOfDays && !doneReview && isGooglePlayBuild) { + if (daysBetween(lastReviewDate, new Date()) >= numberOfDays && !doneReview && !isFDroidBuild) { setTimeout(askReview, reviewDelay); } }; diff --git a/app/views/SettingsView/index.js b/app/views/SettingsView/index.js index eeeb7a98a..17bddd4f8 100644 --- a/app/views/SettingsView/index.js +++ b/app/views/SettingsView/index.js @@ -38,7 +38,7 @@ import { appStart as appStartAction, ROOT_LOADING } from '../../actions/app'; import { onReviewPress } from '../../utils/review'; import { getUserSelector } from '../../selectors/login'; import SafeAreaView from '../../containers/SafeAreaView'; -import { isGooglePlayBuild } from '../../constants/environment'; +import { isFDroidBuild } from '../../constants/environment'; const SectionSeparator = React.memo(({ theme }) => ( @@ -121,7 +121,7 @@ class SettingsView extends React.Component { AsyncStorage.setItem(CRASH_REPORT_KEY, JSON.stringify(value)); const { toggleCrashReport } = this.props; toggleCrashReport(value); - if (isGooglePlayBuild) { + if (!isFDroidBuild) { loggerConfig.autoNotify = value; analytics().setAnalyticsCollectionEnabled(value); if (value) { @@ -161,7 +161,7 @@ class SettingsView extends React.Component { shareApp = () => { // eslint-disable-next-line no-nested-ternary - Share.share({ message: isAndroid ? (isGooglePlayBuild ? PLAY_MARKET_LINK : FDROID_MARKET_LINK) : APP_STORE_LINK }); + Share.share({ message: isAndroid ? (!isFDroidBuild ? PLAY_MARKET_LINK : FDROID_MARKET_LINK) : APP_STORE_LINK }); } copyServerVersion = () => { @@ -257,7 +257,7 @@ class SettingsView extends React.Component { theme={theme} /> - {isGooglePlayBuild ? ( + {!isFDroidBuild ? ( <> ) : null} - {isGooglePlayBuild ? ( + {!isFDroidBuild ? ( <>