diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index 64408fad2..55101a168 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -66,6 +66,7 @@ "pincode": "PIN code", "reset": "Reset", "nsfw_content": "NSFW Content", + "default_footer": "Default Footer", "nsfw": { "always_show": "Always show", "always_hide": "Always hide", diff --git a/src/realm/realm.js b/src/realm/realm.js index d81108da6..3d8793fa3 100644 --- a/src/realm/realm.js +++ b/src/realm/realm.js @@ -45,13 +45,14 @@ const draftSchema = { const settingsSchema = { name: SETTINGS_SCHEMA, properties: { - language: { type: 'string', default: null }, - isDarkTheme: { type: 'bool', default: false }, currency: { type: 'string', default: null }, + isDarkTheme: { type: 'bool', default: false }, + isDefaultFooter: { type: 'bool', default: true }, + language: { type: 'string', default: null }, notification: { type: 'bool', default: true }, + nsfw: { type: 'string', default: null }, server: { type: 'string', default: null }, upvotePercent: { type: 'string', default: null }, - nsfw: { type: 'string', default: null }, }, }; @@ -358,6 +359,17 @@ export const setTheme = isDarkTheme => new Promise((resolve, reject) => { } }); +export const setDefaultFooter = isDefaultFooter => new Promise((resolve, reject) => { + try { + realm.write(() => { + settings[0].isDefaultFooter = isDefaultFooter; + resolve(true); + }); + } catch (error) { + reject(error); + } +}); + export const setUpvotePercent = percent => new Promise((resolve, reject) => { try { realm.write(() => { diff --git a/src/redux/actions/applicationActions.js b/src/redux/actions/applicationActions.js index b539dce52..a70389e87 100644 --- a/src/redux/actions/applicationActions.js +++ b/src/redux/actions/applicationActions.js @@ -5,6 +5,7 @@ import { CLOSE_PIN_CODE_MODAL, IS_CONNECTED, IS_DARK_THEME, + IS_DEFAULT_FOOTER, IS_LOGIN_DONE, IS_NOTIFICATION_OPEN, LOGIN, @@ -14,8 +15,8 @@ import { SET_API, SET_CURRENCY, SET_LANGUAGE, - SET_UPVOTE_PERCENT, SET_NSFW, + SET_UPVOTE_PERCENT, } from '../constants/constants'; export const login = payload => ({ @@ -83,6 +84,11 @@ export const setNsfw = payload => ({ type: SET_NSFW, }); +export const isDefaultFooter = payload => ({ + payload, + type: IS_DEFAULT_FOOTER, +}); + /** * MW */ diff --git a/src/redux/constants/constants.js b/src/redux/constants/constants.js index 17015c5ba..5d196d439 100644 --- a/src/redux/constants/constants.js +++ b/src/redux/constants/constants.js @@ -11,6 +11,7 @@ export const IS_DARK_THEME = 'IS_DARK_THEME'; export const IS_LOGGED_IN = 'IS_LOGGED_IN'; export const IS_LOGIN_DONE = 'IS_LOGIN_DONE'; export const IS_NOTIFICATION_OPEN = 'IS_NOTIFICATION_OPEN'; +export const IS_DEFAULT_FOOTER = 'IS_DEFAULT_FOOTER'; export const LOGIN = 'LOGIN'; export const LOGOUT = 'LOGOUT'; export const LOGOUT_DONE = 'LOGOUT_DONE'; diff --git a/src/redux/reducers/applicationReducer.js b/src/redux/reducers/applicationReducer.js index bb60404cd..f20cd0c30 100644 --- a/src/redux/reducers/applicationReducer.js +++ b/src/redux/reducers/applicationReducer.js @@ -3,6 +3,7 @@ import { CLOSE_PIN_CODE_MODAL, IS_CONNECTED, IS_DARK_THEME, + IS_DEFAULT_FOOTER, IS_LOGIN_DONE, IS_NOTIFICATION_OPEN, LOGIN, @@ -12,8 +13,8 @@ import { SET_API, SET_CURRENCY, SET_LANGUAGE, - SET_UPVOTE_PERCENT, SET_NSFW, + SET_UPVOTE_PERCENT, } from '../constants/constants'; const initialState = { @@ -26,6 +27,7 @@ const initialState = { isActive: false, isConnected: true, // internet connectivity isDarkTheme: false, + isDefaultFooter: true, isLoggedIn: false, // Has any logged in user. isLoginDone: false, isLogingOut: false, @@ -107,6 +109,10 @@ export default function (state = initialState, action) { return Object.assign({}, state, { nsfw: action.payload, }); + case IS_DEFAULT_FOOTER: + return Object.assign({}, state, { + isDefaultFooter: action.payload, + }); default: return state; } diff --git a/src/screens/application/container/applicationContainer.js b/src/screens/application/container/applicationContainer.js index de686332b..2f951b51c 100644 --- a/src/screens/application/container/applicationContainer.js +++ b/src/screens/application/container/applicationContainer.js @@ -39,6 +39,7 @@ import { setAuthStatus, removeSCAccount, setExistUser, + setDefaultFooter, } from '../../../realm/realm'; import { getUser } from '../../../providers/steem/dsteem'; import { setPushToken } from '../../../providers/esteem/esteem'; @@ -247,6 +248,7 @@ class ApplicationContainer extends Component { if (response.language !== '') dispatch(setLanguage(response.language)); if (response.server !== '') dispatch(setApi(response.server)); if (response.upvotePercent !== '') dispatch(setUpvotePercent(Number(response.upvotePercent))); + if (response.isDefaultFooter !== '') dispatch(setDefaultFooter(response.isDefaultFooter)); if (response.notification !== '') { dispatch(isNotificationOpen(response.notification)); Push.setEnabled(response.notification); diff --git a/src/screens/editor/container/editorContainer.js b/src/screens/editor/container/editorContainer.js index a9e7f7fdd..dd7a8ce95 100644 --- a/src/screens/editor/container/editorContainer.js +++ b/src/screens/editor/container/editorContainer.js @@ -293,7 +293,7 @@ class EditorContainer extends Component { _submitPost = async (fields) => { const { - navigation, currentAccount, pinCode, intl, + navigation, currentAccount, pinCode, intl, isDefaultFooter, } = this.props; if (currentAccount) { @@ -533,9 +533,10 @@ class EditorContainer extends Component { } const mapStateToProps = state => ({ + currentAccount: state.account.currentAccount, + isDefaultFooter: state.account.isDefaultFooter, isLoggedIn: state.application.isLoggedIn, pinCode: state.account.pin, - currentAccount: state.account.currentAccount, }); export default connect(mapStateToProps)(injectIntl(EditorContainer)); diff --git a/src/screens/settings/container/settingsContainer.js b/src/screens/settings/container/settingsContainer.js index 4996886a5..bcc6beff4 100644 --- a/src/screens/settings/container/settingsContainer.js +++ b/src/screens/settings/container/settingsContainer.js @@ -7,23 +7,25 @@ import { Client } from 'dsteem'; // Realm import { - setTheme, - setLanguage as setLanguage2DB, - setCurrency as setCurrency2DB, - setServer, - setNotificationIsOpen, getExistUser, + setCurrency as setCurrency2DB, + setDefaultFooter, + setLanguage as setLanguage2DB, + setNotificationIsOpen, setNsfw as setNsfw2DB, + setServer, + setTheme, } from '../../../realm/realm'; // Services and Actions import { - setLanguage, - isNotificationOpen, - setCurrency, - setApi, isDarkTheme, + isDefaultFooter, + isNotificationOpen, openPinCodeModal, + setApi, + setCurrency, + setLanguage, setNsfw, } from '../../../redux/actions/applicationActions'; import { toastNotification } from '../../../redux/actions/uiAction'; @@ -150,6 +152,11 @@ class SettingsContainer extends Component { dispatch(isDarkTheme(action)); setTheme(action); break; + + case 'default_footer': + dispatch(isDefaultFooter(action)); + // setDefaultFooter(action); + break; default: break; } @@ -231,14 +238,15 @@ class SettingsContainer extends Component { } const mapStateToProps = state => ({ - selectedLanguage: state.application.language, + isDarkTheme: state.application.isDarkTheme, + isDefaultFooter: state.application.isDefaultFooter, + isLoggedIn: state.application.isLoggedIn, + isNotificationSettingsOpen: state.application.isNotificationOpen, + nsfw: state.application.nsfw, selectedApi: state.application.api, selectedCurrency: state.application.currency, - isDarkTheme: state.application.isDarkTheme, - isNotificationSettingsOpen: state.application.isNotificationOpen, - isLoggedIn: state.application.isLoggedIn, + selectedLanguage: state.application.language, username: state.account.currentAccount && state.account.currentAccount.name, - nsfw: state.application.nsfw, }); export default connect(mapStateToProps)(SettingsContainer); diff --git a/src/screens/settings/screen/settingsScreen.js b/src/screens/settings/screen/settingsScreen.js index 4bda6243b..f9aa1f6d4 100644 --- a/src/screens/settings/screen/settingsScreen.js +++ b/src/screens/settings/screen/settingsScreen.js @@ -1,4 +1,4 @@ -import React, { PureComponent } from 'react'; +import React, { PureComponent, Fragment } from 'react'; import { ScrollView, View } from 'react-native'; import { injectIntl } from 'react-intl'; @@ -36,13 +36,14 @@ class SettingsScreen extends PureComponent { handleOnChange, intl, isDarkTheme, + isDefaultFooter, isLoggedIn, isNotificationSettingsOpen, + nsfw, selectedApi, selectedCurrency, selectedLanguage, serverList, - nsfw, } = this.props; return ( @@ -116,17 +117,28 @@ class SettingsScreen extends PureComponent { handleOnChange={handleOnChange} /> {!!isLoggedIn && ( - + + + + )}