Commit 371c9f4f authored by valzav's avatar valzav
Browse files

rename user settigs to user preferences

parent 1699be14
......@@ -121,8 +121,8 @@ class Settings extends React.Component {
handleLanguageChange = (event) => {
const locale = event.target.value;
const user_settings = {...this.props.user_settings, locale}
this.props.updateUserSettings(user_settings)
const user_preferences = {...this.props.user_preferences, locale}
this.props.setUserPreferences(user_preferences)
}
render() {
......@@ -133,7 +133,7 @@ class Settings extends React.Component {
const {profile_image, name, about, location, website} = this.state
const {follow, account, isOwnAccount, user_settings} = this.props
const {follow, account, isOwnAccount, user_preferences} = this.props
const following = follow && follow.getIn(['getFollowingAsync', account.name]);
const ignores = isOwnAccount && following && following.get('ignore_result')
......@@ -141,7 +141,7 @@ class Settings extends React.Component {
<div className="row">
<div className="small-12 medium-6 large-4 columns">
<label>{tt('g.choose_language')}
<select defaultValue={user_settings.locale} onChange={this.handleLanguageChange}>
<select defaultValue={user_preferences.locale} onChange={this.handleLanguageChange}>
<option value="en">English</option>
<option value="es">Spanish</option>
</select>
......@@ -235,7 +235,7 @@ export default connect(
let metaData = account ? o2j.ifStringParseJSON(account.json_metadata) : {}
if (typeof metaData === 'string') metaData = o2j.ifStringParseJSON(metaData); // issue #1237
const profile = metaData && metaData.profile ? metaData.profile : {};
const user_settings = state.app.get('user_settings').toJS();
const user_preferences = state.app.get('user_preferences').toJS();
return {
account,
......@@ -244,7 +244,7 @@ export default connect(
isOwnAccount: username == accountname,
profile,
follow: state.global.get('follow'),
user_settings,
user_preferences,
...ownProps
}
},
......@@ -257,8 +257,8 @@ export default connect(
const options = {type: 'account_update', operation, successCallback, errorCallback}
dispatch(transaction.actions.broadcastOperation(options))
},
updateUserSettings: (payload) => {
dispatch({type: 'UPDATE_USER_SETTINGS', payload})
setUserPreferences: (payload) => {
dispatch({type: 'SET_USER_PREFERENCES', payload})
}
})
)(Settings)
......@@ -21,7 +21,7 @@ const defaultState = Map({
message: 0,
receive: 0
}),
user_settings: Map({
user_preferences: Map({
locale: null,
nsfwPref: 'warn'
})
......@@ -62,8 +62,8 @@ export default function reducer(state = defaultState, action) {
}
res = res.set('notificounters', Map(nc));
}
if (action.type === 'UPDATE_USER_SETTINGS') {
res = res.set('user_settings', Map(action.payload));
if (action.type === 'SET_USER_PREFERENCES') {
res = res.set('user_preferences', Map(action.payload));
}
return res;
}
......@@ -4,7 +4,7 @@ import g from 'app/redux/GlobalReducer'
import {takeEvery, takeLatest} from 'redux-saga';
import tt from 'counterpart';
import {api} from 'steem';
import {updateUserSettings} from 'app/utils/ServerApiClient';
import {setUserPreferences} from 'app/utils/ServerApiClient';
const wait = ms => (
new Promise(resolve => {
......@@ -62,10 +62,10 @@ export function* getContent({author, permlink, resolve, reject}) {
}
}
function* saveUserSettings({payload}) {
yield updateUserSettings(payload);
function* saveUserPreferences({payload}) {
yield setUserPreferences(payload);
}
function* watchUserSettingsUpdates() {
yield* takeLatest('UPDATE_USER_SETTINGS', saveUserSettings);
yield* takeLatest('SET_USER_PREFERENCES', saveUserPreferences);
}
......@@ -83,10 +83,10 @@ export function saveCords(x, y) {
fetch('/api/v1/save_cords', request);
}
export function updateUserSettings(settings) {
export function setUserPreferences(settings) {
if (!process.env.BROWSER || window.$STM_ServerBusy) return Promise.resolve();
const request = Object.assign({}, request_base, {body: JSON.stringify({csrf: window.$STM_csrf, settings})});
return fetch('/api/v1/update_user_settings', request);
return fetch('/api/v1/setUserPreferences', request);
}
if (process.env.BROWSER) {
......
......@@ -413,11 +413,11 @@ export default function useGeneralApi(app) {
this.body = JSON.stringify({status: 'ok'});
});
router.post('/update_user_settings', koaBody, function *() {
router.post('/setUserPreferences', koaBody, function *() {
const params = this.request.body;
const {csrf, settings} = typeof(params) === 'string' ? JSON.parse(params) : params;
if (!checkCSRF(this, csrf)) return;
console.log('-- /update_user_settings -->', this.session.user, this.session.uid, settings);
console.log('-- /setUserPreferences -->', this.session.user, this.session.uid, settings);
if (!this.session.user) {
this.body = 'missing user id';
this.status = 500;
......@@ -436,7 +436,7 @@ export default function useGeneralApi(app) {
}
this.body = JSON.stringify({status: 'ok'});
} catch (error) {
console.error('Error in /update_user_settings api call', this.session.uid, error);
console.error('Error in /setUserPreferences api call', this.session.uid, error);
this.body = JSON.stringify({error: error.message});
this.status = 500;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment