File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,12 @@ class SearchStories extends Component {
2323
2424 @action
2525 onSubmit ( event ) {
26+ const { storyStore } = this . props ;
27+
2628 if ( this . query ) {
2729 fetchStories ( this . query )
28- . then ( result => this . props . storyStore . setStories ( result . hits ) )
30+ . then ( result => storyStore . setStories ( result . hits ) )
31+ . catch ( storyStore . setError ) ;
2932
3033 this . query = '' ;
3134 }
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ const Stories = ({ storyStore }) =>
2929 < div className = "stories" >
3030 < StoriesHeader columns = { COLUMNS } />
3131
32+ { storyStore . error && < p className = "error" > Something went wrong ...</ p > }
33+
3234 { ( storyStore . readableStories || [ ] ) . map ( story =>
3335 < Story
3436 key = { story . objectID }
Original file line number Diff line number Diff line change @@ -5,13 +5,21 @@ const isNotArchived = (archivedStoryIds) => (story) =>
55
66class StoryStore {
77 @observable stories = [ ] ;
8+ @observable error = null ;
89
910 constructor ( rootStore ) {
1011 this . rootStore = rootStore ;
1112 }
1213
13- @action setStories = stories =>
14+ @action setStories = stories => {
1415 this . stories = stories ;
16+ this . error = null ;
17+ }
18+
19+ @action setError = error => {
20+ this . stories = [ ] ;
21+ this . error = error ;
22+ }
1523
1624 @computed get readableStories ( ) {
1725 const { archivedStoryIds } = this . rootStore . archiveStore ;
You can’t perform that action at this time.
0 commit comments