From dabba98c0c51c34cd0e760be807bf5b4dc588d89 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 13 Mar 2020 17:05:29 +0100 Subject: [PATCH] Add DHT setting (#130) * dht setting * update setting text --- android | 2 +- src/component/AppNavigator.js | 2 -- src/constants.js | 1 + src/index.js | 1 - src/page/liteFile/index.js | 5 +-- src/page/settings/index.js | 6 ++-- src/page/settings/view.js | 65 ++++++++++++++++++++++------------- 7 files changed, 47 insertions(+), 35 deletions(-) diff --git a/android b/android index b7b6c05..ea8ac78 160000 --- a/android +++ b/android @@ -1 +1 @@ -Subproject commit b7b6c05bd3a61c1cec09a08f1b5c413a68597026 +Subproject commit ea8ac783a8b05db8ab78472efc3fff32dc6869e6 diff --git a/src/component/AppNavigator.js b/src/component/AppNavigator.js index 1154c58..be85fdc 100644 --- a/src/component/AppNavigator.js +++ b/src/component/AppNavigator.js @@ -312,8 +312,6 @@ class AppWithNavigationState extends React.Component { 'hardwareBackPress', function() { const { dispatch, nav, drawerStack } = this.props; - console.log(nav); - if (drawerStack.length > 1) { dispatchNavigateBack(dispatch, nav, drawerStack); return true; diff --git a/src/constants.js b/src/constants.js index bf019b5..fca862e 100644 --- a/src/constants.js +++ b/src/constants.js @@ -44,6 +44,7 @@ const Constants = { SETTING_BACKUP_DISMISSED: 'backupDismissed', SETTING_REWARDS_NOT_INTERESTED: 'rewardsNotInterested', SETTING_DEVICE_WALLET_SYNCED: 'deviceWalletSynced', + SETTING_DHT_ENABLED: 'dhtEnabled', ACTION_DELETE_COMPLETED_BLOBS: 'DELETE_COMPLETED_BLOBS', ACTION_FIRST_RUN_PAGE_CHANGED: 'FIRST_RUN_PAGE_CHANGED', diff --git a/src/index.js b/src/index.js index f64e3e5..5a52168 100644 --- a/src/index.js +++ b/src/index.js @@ -58,7 +58,6 @@ window.__ = __; const globalExceptionHandler = (error, isFatal) => { if (error && NativeModules.Firebase) { - console.log(error); NativeModules.Firebase.logException(!!isFatal, error.message ? error.message : 'No message', JSON.stringify(error)); } }; diff --git a/src/page/liteFile/index.js b/src/page/liteFile/index.js index 49b4570..533d439 100644 --- a/src/page/liteFile/index.js +++ b/src/page/liteFile/index.js @@ -25,7 +25,4 @@ const perform = dispatch => ({ toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)), }); -export default connect( - select, - perform, -)(LiteFilePage); +export default connect(select, perform)(LiteFilePage); diff --git a/src/page/settings/index.js b/src/page/settings/index.js index 01bd9d4..f5353a4 100644 --- a/src/page/settings/index.js +++ b/src/page/settings/index.js @@ -11,6 +11,7 @@ const select = state => ({ backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state), currentRoute: selectCurrentRoute(state), drawerStack: selectDrawerStack(state), + enableDht: makeSelectClientSetting(Constants.SETTING_DHT_ENABLED)(state), keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state), language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state), showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state), @@ -29,7 +30,4 @@ const perform = dispatch => ({ setPlayerVisible: () => dispatch(doSetPlayerVisible(false)), }); -export default connect( - select, - perform -)(SettingsPage); +export default connect(select, perform)(SettingsPage); diff --git a/src/page/settings/view.js b/src/page/settings/view.js index 9573803..8a3a29c 100644 --- a/src/page/settings/view.js +++ b/src/page/settings/view.js @@ -10,28 +10,28 @@ import RNFS from 'react-native-fs'; import settingsStyle from 'styles/settings'; const languageOptions = [ - { code: 'default', name: 'Use device language' }, - { code: 'jv', name: 'Basa Jawa' }, - { code: 'da', name: 'Danish' }, - { code: 'nl', name: 'Dutch' }, - { code: 'en', name: 'English' }, - { code: 'et', name: 'Estonian' }, - { code: 'fr', name: 'French' }, - { code: 'gu', name: 'Gujarati' }, - { code: 'hi', name: 'Hindi' }, - { code: 'id', name: 'Indonesian' }, - { code: 'it', name: 'Italian' }, - { code: 'kn', name: 'Kannada' }, - { code: 'ms', name: 'Malay' }, - { code: 'mr', name: 'Marathi' }, - { code: 'pl', name: 'Polish' }, - { code: 'pt', name: 'Portuguese' }, - { code: 'ro', name: 'Romanian' }, - { code: 'ru', name: 'Russian' }, - { code: 'sk', name: 'Slovak' }, - { code: 'es', name: 'Spanish' }, - { code: 'tr', name: 'Turkish' }, - { code: 'uk', name: 'Ukrainian' }, + { code: 'default', name: 'Use device language' }, + { code: 'jv', name: 'Basa Jawa' }, + { code: 'da', name: 'Danish' }, + { code: 'nl', name: 'Dutch' }, + { code: 'en', name: 'English' }, + { code: 'et', name: 'Estonian' }, + { code: 'fr', name: 'French' }, + { code: 'gu', name: 'Gujarati' }, + { code: 'hi', name: 'Hindi' }, + { code: 'id', name: 'Indonesian' }, + { code: 'it', name: 'Italian' }, + { code: 'kn', name: 'Kannada' }, + { code: 'ms', name: 'Malay' }, + { code: 'mr', name: 'Marathi' }, + { code: 'pl', name: 'Polish' }, + { code: 'pt', name: 'Portuguese' }, + { code: 'ro', name: 'Romanian' }, + { code: 'ru', name: 'Russian' }, + { code: 'sk', name: 'Slovak' }, + { code: 'es', name: 'Spanish' }, + { code: 'tr', name: 'Turkish' }, + { code: 'uk', name: 'Ukrainian' }, ]; class SettingsPage extends React.PureComponent { @@ -151,6 +151,7 @@ class SettingsPage extends React.PureComponent { render() { const { backgroundPlayEnabled, + enableDht, keepDaemonRunning, receiveSubscriptionNotifications, receiveRewardNotifications, @@ -168,6 +169,7 @@ class SettingsPage extends React.PureComponent { const actualReceiveRewardNotifications = this.getBooleanSetting(receiveRewardNotifications, true); const actualReceiveInterestsNotifications = this.getBooleanSetting(receiveInterestsNotifications, true); const actualReceiveCreatorNotifications = this.getBooleanSetting(receiveCreatorNotifications, true); + const actualEnableDht = this.getBooleanSetting(enableDht, false); return ( @@ -305,7 +307,7 @@ class SettingsPage extends React.PureComponent { {__( - 'Enable this option for quicker app launch and to keep the synchronisation with the blockchain up to date.' + 'Enable this option for quicker app launch and to keep the synchronisation with the blockchain up to date.', )} @@ -321,6 +323,23 @@ class SettingsPage extends React.PureComponent { /> + + + + {__('Participate in the data network')} + + {__('Enable DHT (this will take effect upon app and background service restart)')} + + + + { + this.setNativeBooleanSetting(Constants.SETTING_DHT_ENABLED, value); + }} + /> + + );