Skip to content

Commit

Permalink
Set cloud wallet login to default, improve settings switching logic
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Oct 13, 2017
1 parent beda749 commit 6e098b6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
4 changes: 3 additions & 1 deletion app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,9 @@
}
},
"settings": {
"passwordLogin": "Login using a cloud wallet",
"passwordLogin": "Login mode",
"cloud_login": "Cloud Wallet Login",
"local_wallet": "Local Wallet Login",
"inverseMarket": "Market orientation preference",
"unit": "Preferred unit of account",
"confirmMarketOrder": "Ask for confirmation of market orders",
Expand Down
20 changes: 11 additions & 9 deletions app/components/Settings/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ class Settings extends React.Component {
if (np.settings.get("passwordLogin") !== this.props.settings.get("passwordLogin")) {
const currentEntries = this._getMenuEntries(this.props);
const menuEntries = this._getMenuEntries(np);
if (currentEntries.length < menuEntries.length) {
this.setState({
activeSetting: this.state.activeSetting + (menuEntries.length - currentEntries.length)
});
}
const currentActive = currentEntries[this.state.activeSetting];
const newActiveIndex = menuEntries.indexOf(currentActive);
const newActive = menuEntries[newActiveIndex];
this.setState({
menuEntries
});

if (this.state.activeSetting > (menuEntries.length - 1)) {
if (newActiveIndex && newActiveIndex !== this.state.activeSetting) {
this.setState({
activeSetting: menuEntries.indexOf(currentActive)
});
} else if (!newActive || this.state.activeSetting > (menuEntries.length - 1)) {
this.setState({
activeSetting: 0
});
Expand Down Expand Up @@ -139,7 +140,9 @@ class Settings extends React.Component {
case "showSettles":
case "showAssetPercent":
case "passwordLogin":
SettingsActions.changeSetting({setting, value: e.target.value === "yes" });
let reference = defaults[setting][0];
if (reference.translate) reference = reference.translate;
SettingsActions.changeSetting({setting, value: e.target.value === reference });
break;

case "unit":
Expand Down Expand Up @@ -174,7 +177,6 @@ class Settings extends React.Component {
render() {
let {settings, defaults} = this.props;
const {menuEntries, activeSetting, settingEntries} = this.state;

let entries;
let activeEntry = menuEntries[activeSetting] || menuEntries[0];
switch (activeEntry) {
Expand Down
4 changes: 2 additions & 2 deletions app/components/Settings/SettingsEntry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class SettingsEntry extends React.Component {
}

render() {
let {defaults, setting, settings, apiServer} = this.props;
let {defaults, setting, settings} = this.props;
let options, optional, confirmButton, value, input, selected = settings.get(setting);
let noHeader = false;

Expand Down Expand Up @@ -97,7 +97,7 @@ export default class SettingsEntry extends React.Component {


if (defaults) {
options = defaults.map((entry, index) => {
options = defaults.map((entry) => {
let option = entry.translate ? counterpart.translate(`settings.${entry.translate}`) : entry;
if (setting === "unit") {
option = <AssetName name={entry} />;
Expand Down
6 changes: 3 additions & 3 deletions app/stores/SettingsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SettingsStore {
walletLockTimeout: 60 * 10,
themes: "darkTheme",
disableChat: false,
passwordLogin: false
passwordLogin: true
});

// If you want a default value to be translated, add the translation to settings in locale-xx.js
Expand Down Expand Up @@ -88,8 +88,8 @@ class SettingsStore {
"olDarkTheme"
],
passwordLogin: [
{translate: "yes"},
{translate: "no"}
{translate: "cloud_login"},
{translate: "local_wallet"}
]
// confirmMarketOrder: [
// {translate: "confirm_yes"},
Expand Down

0 comments on commit 6e098b6

Please sign in to comment.