Skip to content

Commit dc8f69d

Browse files
authored
Bug/bust cache after recipe creation (#14)
* 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
1 parent 7b66a48 commit dc8f69d

15 files changed

Lines changed: 129 additions & 123 deletions

File tree

modules/browse/components/ListRecipes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const ListRecipes = ({ data, format }) => {
1212
return recipe.photo_thumbnail;
1313
} else {
1414
const images = ['fish', 'fried-eggs', 'pizza', 'soup', 'steak'];
15-
return '/images/' + images[Math.floor(Math.random(0) * images.length)] + '.png';
15+
return '/images/' + images[Math.floor(Math.random(0) * images.length)] + '.jpg';
1616
}
1717
};
1818

modules/browse/constants/SearchConstants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
export default {
33
BROWSE_SEARCH_RESULTS: 'BROWSE_SEARCH_RESULTS',
44
BROWSE_SEARCH_LOADING: 'BROWSE_SEARCH_LOADING',
5+
BROWSE_RESET_SEARCH_RESULTS: 'BROWSE_RESET_SEARCH_RESULTS',
56
};

modules/browse/reducers/SearchReducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ function search(state = { results: {}, loading: true }, action) {
1515
results: { ...state.results, ...newSearch },
1616
loading: false
1717
};
18+
case SearchConstants.BROWSE_RESET_SEARCH_RESULTS:
19+
return { results: {}, loading: false };
1820
default:
1921
return state;
2022
}

modules/common/demo/data.json

Lines changed: 122 additions & 122 deletions
Large diffs are not rendered by default.

modules/recipe_form/actions/RecipeFormActions.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { request } from '../../common/CustomSuperagent';
22
import RecipeFormConstants from '../constants/RecipeFormConstants';
3+
import SearchConstants from '../../browse/constants/SearchConstants';
34
import StatusConstants from '../constants/StatusConstants';
45
import { serverURLs } from '../../common/config'
56
import validation from './validation'
@@ -109,6 +110,7 @@ export const save = (data, event) => {
109110
message: 'Recipe save!',
110111
alert: 'alert-success'
111112
});
113+
dispatch({ type: SearchConstants.BROWSE_RESET_SEARCH_RESULTS });
112114
if (typeof event === 'function') event(res.body);
113115
})
114116
.catch(err => {
@@ -129,6 +131,7 @@ export const save = (data, event) => {
129131
message: 'Recipe save!',
130132
alert: 'alert-success'
131133
});
134+
dispatch({ type: SearchConstants.BROWSE_RESET_SEARCH_RESULTS });
132135
if (typeof event === 'function') event(res.body);
133136
}
134137
})

public/images/fish.jpg

7.59 KB
Loading

public/images/fish.png

-59.5 KB
Binary file not shown.

public/images/fried-eggs.jpg

7.44 KB
Loading

public/images/fried-eggs.png

-60.2 KB
Binary file not shown.

public/images/pizza.jpg

7.74 KB
Loading

0 commit comments

Comments
 (0)