Skip to content

Commit

Permalink
Add notification on successful market favorites restoration
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Nov 19, 2017
1 parent 651bc82 commit f310ddd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/assets/locales/locale-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@
"backup_favorites": "Restore favorites using a json file",
"backup_favorites_error": "Could not parse JSON.",
"backup_favorites_finish": "Import favorites",
"backup_favorites_success": "Successfully restored market favorites",
"backupcreate_backup": "Create local wallet backup",
"backupcreate_brainkey": "Create brainkey backup",
"backupcreate_favorites": "Create favorites backup",
Expand Down
20 changes: 13 additions & 7 deletions app/components/Settings/RestoreFavorites.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";
import Translate from "react-translate-component";
import Immutable from "immutable"
import SettingsActions from "actions/SettingsActions";
import { connect } from "alt-react";
import notify from "actions/NotificationActions";
import counterpart from "counterpart";

class RestoreFavorites extends React.Component {
constructor(props){
Expand All @@ -11,7 +11,7 @@ class RestoreFavorites extends React.Component {
this.state = {
json: null,
error: null
}
};
}

upload(evt){
Expand All @@ -33,7 +33,7 @@ class RestoreFavorites extends React.Component {
}

this.setState({json});
this.finish();
// this.finish();
} catch(message) {
this.setState({error: true});
}
Expand All @@ -52,10 +52,16 @@ class RestoreFavorites extends React.Component {

SettingsActions.addStarMarket(quote, base);
}

notify.addNotification({
message: counterpart("settings.backup_favorites_success"),
level: "success",
autoDismiss: 2
});
}

render(){
const { state, props } = this;
const { state } = this;

return <div>
<input
Expand All @@ -68,12 +74,12 @@ class RestoreFavorites extends React.Component {
}}
onChange={this.upload.bind(this)}
/>

{state.error && <h5>
<Translate content="settings.backup_favorites_error" />
</h5>}

{state.json &&
{state.json &&
<p>
<button onClick={this.finish.bind(this)} className="button success">
<Translate content="settings.backup_favorites_finish" />
Expand Down

0 comments on commit f310ddd

Please sign in to comment.