mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 04:41:43 +03:00
Merge pull request #670 from esteemapp/feature/defaultFooter
Default Feature [PART 1] [FOR NEXT RELEASE]
This commit is contained in:
commit
09b6086796
@ -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",
|
||||
|
@ -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(() => {
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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';
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
@ -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 && (
|
||||
<SettingsItem
|
||||
title={intl.formatMessage({
|
||||
id: 'settings.pincode',
|
||||
})}
|
||||
text={intl.formatMessage({
|
||||
id: 'settings.reset',
|
||||
})}
|
||||
type="button"
|
||||
actionType="pincode"
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
<Fragment>
|
||||
<SettingsItem
|
||||
title={intl.formatMessage({
|
||||
id: 'settings.default_footer',
|
||||
})}
|
||||
type="toggle"
|
||||
actionType="default_footer"
|
||||
isOn={isDefaultFooter}
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
<SettingsItem
|
||||
title={intl.formatMessage({
|
||||
id: 'settings.pincode',
|
||||
})}
|
||||
text={intl.formatMessage({
|
||||
id: 'settings.reset',
|
||||
})}
|
||||
type="button"
|
||||
actionType="pincode"
|
||||
handleOnChange={handleOnChange}
|
||||
/>
|
||||
</Fragment>
|
||||
)}
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
Loading…
Reference in New Issue
Block a user