Add DHT setting #130

Merged
akinwale merged 4 commits from dht into master 2020-03-13 17:05:30 +01:00
7 changed files with 47 additions and 35 deletions

@ -1 +1 @@
Subproject commit b7b6c05bd3a61c1cec09a08f1b5c413a68597026 Subproject commit ea8ac783a8b05db8ab78472efc3fff32dc6869e6

View file

@ -312,8 +312,6 @@ class AppWithNavigationState extends React.Component {
'hardwareBackPress', 'hardwareBackPress',
function() { function() {
const { dispatch, nav, drawerStack } = this.props; const { dispatch, nav, drawerStack } = this.props;
console.log(nav);
if (drawerStack.length > 1) { if (drawerStack.length > 1) {
dispatchNavigateBack(dispatch, nav, drawerStack); dispatchNavigateBack(dispatch, nav, drawerStack);
return true; return true;

View file

@ -44,6 +44,7 @@ const Constants = {
SETTING_BACKUP_DISMISSED: 'backupDismissed', SETTING_BACKUP_DISMISSED: 'backupDismissed',
SETTING_REWARDS_NOT_INTERESTED: 'rewardsNotInterested', SETTING_REWARDS_NOT_INTERESTED: 'rewardsNotInterested',
SETTING_DEVICE_WALLET_SYNCED: 'deviceWalletSynced', SETTING_DEVICE_WALLET_SYNCED: 'deviceWalletSynced',
SETTING_DHT_ENABLED: 'dhtEnabled',
ACTION_DELETE_COMPLETED_BLOBS: 'DELETE_COMPLETED_BLOBS', ACTION_DELETE_COMPLETED_BLOBS: 'DELETE_COMPLETED_BLOBS',
ACTION_FIRST_RUN_PAGE_CHANGED: 'FIRST_RUN_PAGE_CHANGED', ACTION_FIRST_RUN_PAGE_CHANGED: 'FIRST_RUN_PAGE_CHANGED',

View file

@ -58,7 +58,6 @@ window.__ = __;
const globalExceptionHandler = (error, isFatal) => { const globalExceptionHandler = (error, isFatal) => {
if (error && NativeModules.Firebase) { if (error && NativeModules.Firebase) {
console.log(error);
NativeModules.Firebase.logException(!!isFatal, error.message ? error.message : 'No message', JSON.stringify(error)); NativeModules.Firebase.logException(!!isFatal, error.message ? error.message : 'No message', JSON.stringify(error));
} }
}; };

View file

@ -25,7 +25,4 @@ const perform = dispatch => ({
toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)), toggleFullscreenMode: mode => dispatch(doToggleFullscreenMode(mode)),
}); });
export default connect( export default connect(select, perform)(LiteFilePage);
select,
perform,
)(LiteFilePage);

View file

@ -11,6 +11,7 @@ const select = state => ({
backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state), backgroundPlayEnabled: makeSelectClientSetting(SETTINGS.BACKGROUND_PLAY_ENABLED)(state),
currentRoute: selectCurrentRoute(state), currentRoute: selectCurrentRoute(state),
drawerStack: selectDrawerStack(state), drawerStack: selectDrawerStack(state),
enableDht: makeSelectClientSetting(Constants.SETTING_DHT_ENABLED)(state),
keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state), keepDaemonRunning: makeSelectClientSetting(SETTINGS.KEEP_DAEMON_RUNNING)(state),
language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state), language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state),
showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state), showNsfw: makeSelectClientSetting(SETTINGS.SHOW_NSFW)(state),
@ -29,7 +30,4 @@ const perform = dispatch => ({
setPlayerVisible: () => dispatch(doSetPlayerVisible(false)), setPlayerVisible: () => dispatch(doSetPlayerVisible(false)),
}); });
export default connect( export default connect(select, perform)(SettingsPage);
select,
perform
)(SettingsPage);

View file

@ -10,28 +10,28 @@ import RNFS from 'react-native-fs';
import settingsStyle from 'styles/settings'; import settingsStyle from 'styles/settings';
const languageOptions = [ const languageOptions = [
{ code: 'default', name: 'Use device language' }, { code: 'default', name: 'Use device language' },
{ code: 'jv', name: 'Basa Jawa' }, { code: 'jv', name: 'Basa Jawa' },
{ code: 'da', name: 'Danish' }, { code: 'da', name: 'Danish' },
{ code: 'nl', name: 'Dutch' }, { code: 'nl', name: 'Dutch' },
{ code: 'en', name: 'English' }, { code: 'en', name: 'English' },
{ code: 'et', name: 'Estonian' }, { code: 'et', name: 'Estonian' },
{ code: 'fr', name: 'French' }, { code: 'fr', name: 'French' },
{ code: 'gu', name: 'Gujarati' }, { code: 'gu', name: 'Gujarati' },
{ code: 'hi', name: 'Hindi' }, { code: 'hi', name: 'Hindi' },
{ code: 'id', name: 'Indonesian' }, { code: 'id', name: 'Indonesian' },
{ code: 'it', name: 'Italian' }, { code: 'it', name: 'Italian' },
{ code: 'kn', name: 'Kannada' }, { code: 'kn', name: 'Kannada' },
{ code: 'ms', name: 'Malay' }, { code: 'ms', name: 'Malay' },
{ code: 'mr', name: 'Marathi' }, { code: 'mr', name: 'Marathi' },
{ code: 'pl', name: 'Polish' }, { code: 'pl', name: 'Polish' },
{ code: 'pt', name: 'Portuguese' }, { code: 'pt', name: 'Portuguese' },
{ code: 'ro', name: 'Romanian' }, { code: 'ro', name: 'Romanian' },
{ code: 'ru', name: 'Russian' }, { code: 'ru', name: 'Russian' },
{ code: 'sk', name: 'Slovak' }, { code: 'sk', name: 'Slovak' },
{ code: 'es', name: 'Spanish' }, { code: 'es', name: 'Spanish' },
{ code: 'tr', name: 'Turkish' }, { code: 'tr', name: 'Turkish' },
{ code: 'uk', name: 'Ukrainian' }, { code: 'uk', name: 'Ukrainian' },
]; ];
class SettingsPage extends React.PureComponent { class SettingsPage extends React.PureComponent {
@ -151,6 +151,7 @@ class SettingsPage extends React.PureComponent {
render() { render() {
const { const {
backgroundPlayEnabled, backgroundPlayEnabled,
enableDht,
keepDaemonRunning, keepDaemonRunning,
receiveSubscriptionNotifications, receiveSubscriptionNotifications,
receiveRewardNotifications, receiveRewardNotifications,
@ -168,6 +169,7 @@ class SettingsPage extends React.PureComponent {
const actualReceiveRewardNotifications = this.getBooleanSetting(receiveRewardNotifications, true); const actualReceiveRewardNotifications = this.getBooleanSetting(receiveRewardNotifications, true);
const actualReceiveInterestsNotifications = this.getBooleanSetting(receiveInterestsNotifications, true); const actualReceiveInterestsNotifications = this.getBooleanSetting(receiveInterestsNotifications, true);
const actualReceiveCreatorNotifications = this.getBooleanSetting(receiveCreatorNotifications, true); const actualReceiveCreatorNotifications = this.getBooleanSetting(receiveCreatorNotifications, true);
const actualEnableDht = this.getBooleanSetting(enableDht, false);
return ( return (
<View style={settingsStyle.container}> <View style={settingsStyle.container}>
@ -305,7 +307,7 @@ class SettingsPage extends React.PureComponent {
</Text> </Text>
<Text style={settingsStyle.description}> <Text style={settingsStyle.description}>
{__( {__(
'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.',
)} )}
</Text> </Text>
</View> </View>
@ -321,6 +323,23 @@ class SettingsPage extends React.PureComponent {
/> />
</View> </View>
</View> </View>
<View style={settingsStyle.row}>
<View style={settingsStyle.switchText}>
<Text style={settingsStyle.label}>{__('Participate in the data network')}</Text>
<Text style={settingsStyle.description}>
{__('Enable DHT (this will take effect upon app and background service restart)')}
</Text>
</View>
<View style={settingsStyle.switchContainer}>
<Switch
value={actualEnableDht}
onValueChange={value => {
this.setNativeBooleanSetting(Constants.SETTING_DHT_ENABLED, value);
}}
/>
</View>
</View>
</ScrollView> </ScrollView>
</View> </View>
); );