Skip to content

Commit

Permalink
Bug/bust cache after recipe creation (#14)
Browse files Browse the repository at this point in the history
* Bust the cache after a recipe is created so users can see that recipe

* using jpg images with exact same size and format as the one the server with serve
  • Loading branch information
RyanNoelk authored Jun 5, 2018
1 parent 7b66a48 commit dc8f69d
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 123 deletions.
2 changes: 1 addition & 1 deletion modules/browse/components/ListRecipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const ListRecipes = ({ data, format }) => {
return recipe.photo_thumbnail;
} else {
const images = ['fish', 'fried-eggs', 'pizza', 'soup', 'steak'];
return '/images/' + images[Math.floor(Math.random(0) * images.length)] + '.png';
return '/images/' + images[Math.floor(Math.random(0) * images.length)] + '.jpg';
}
};

Expand Down
1 change: 1 addition & 0 deletions modules/browse/constants/SearchConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
export default {
BROWSE_SEARCH_RESULTS: 'BROWSE_SEARCH_RESULTS',
BROWSE_SEARCH_LOADING: 'BROWSE_SEARCH_LOADING',
BROWSE_RESET_SEARCH_RESULTS: 'BROWSE_RESET_SEARCH_RESULTS',
};
2 changes: 2 additions & 0 deletions modules/browse/reducers/SearchReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ function search(state = { results: {}, loading: true }, action) {
results: { ...state.results, ...newSearch },
loading: false
};
case SearchConstants.BROWSE_RESET_SEARCH_RESULTS:
return { results: {}, loading: false };
default:
return state;
}
Expand Down
244 changes: 122 additions & 122 deletions modules/common/demo/data.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions modules/recipe_form/actions/RecipeFormActions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { request } from '../../common/CustomSuperagent';
import RecipeFormConstants from '../constants/RecipeFormConstants';
import SearchConstants from '../../browse/constants/SearchConstants';
import StatusConstants from '../constants/StatusConstants';
import { serverURLs } from '../../common/config'
import validation from './validation'
Expand Down Expand Up @@ -109,6 +110,7 @@ export const save = (data, event) => {
message: 'Recipe save!',
alert: 'alert-success'
});
dispatch({ type: SearchConstants.BROWSE_RESET_SEARCH_RESULTS });
if (typeof event === 'function') event(res.body);
})
.catch(err => {
Expand All @@ -129,6 +131,7 @@ export const save = (data, event) => {
message: 'Recipe save!',
alert: 'alert-success'
});
dispatch({ type: SearchConstants.BROWSE_RESET_SEARCH_RESULTS });
if (typeof event === 'function') event(res.body);
}
})
Expand Down
Binary file added public/images/fish.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/fish.png
Binary file not shown.
Binary file added public/images/fried-eggs.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/fried-eggs.png
Binary file not shown.
Binary file added public/images/pizza.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/pizza.png
Binary file not shown.
Binary file added public/images/soup.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/soup.png
Binary file not shown.
Binary file added public/images/steak.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/steak.png
Binary file not shown.

0 comments on commit dc8f69d

Please sign in to comment.