0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Visitng a deleted brew will now remove it from your recent list

This commit is contained in:
Scott Tolksdorf
2016-08-20 12:33:11 -04:00
parent 6b337b5d69
commit 90c695c005
2 changed files with 26 additions and 3 deletions

View File

@@ -4,7 +4,7 @@
- Added in a license file
- Updated the welcome text
- Added in a much better Error page
- If you visit a deleted brew, it will now remove it from your recent list. (Thanks u/sIllverback!)
### Friday, 29/07/2016 - v2.2.7
- Adding in descriptive note blocks. (Thanks calculuschild!)

View File

@@ -122,6 +122,12 @@ module.exports = {
}),
both : React.createClass({
getDefaultProps: function() {
return {
errorId : null
};
},
getInitialState: function() {
return {
showDropdown: false,
@@ -131,9 +137,26 @@ module.exports = {
},
componentDidMount: function() {
var edited = JSON.parse(localStorage.getItem(EDIT_KEY) || '[]');
var viewed = JSON.parse(localStorage.getItem(VIEW_KEY) || '[]');
if(this.props.errorId){
edited = _.filter(edited, (edit) => {
return edit.id !== this.props.errorId;
});
viewed = _.filter(viewed, (view) => {
return view.id !== this.props.errorId;
});
localStorage.setItem(EDIT_KEY, JSON.stringify(edited));
localStorage.setItem(VIEW_KEY, JSON.stringify(viewed));
}
this.setState({
edit : JSON.parse(localStorage.getItem(EDIT_KEY) || '[]'),
view : JSON.parse(localStorage.getItem(VIEW_KEY) || '[]')
edit : edited,
view : viewed
});
},