File tree 3 files changed +15
-2
lines changed
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 {
23
23
24
24
@action
25
25
onSubmit ( event ) {
26
+ const { storyStore } = this . props ;
27
+
26
28
if ( this . query ) {
27
29
fetchStories ( this . query )
28
- . then ( result => this . props . storyStore . setStories ( result . hits ) )
30
+ . then ( result => storyStore . setStories ( result . hits ) )
31
+ . catch ( storyStore . setError ) ;
29
32
30
33
this . query = '' ;
31
34
}
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ const Stories = ({ storyStore }) =>
29
29
< div className = "stories" >
30
30
< StoriesHeader columns = { COLUMNS } />
31
31
32
+ { storyStore . error && < p className = "error" > Something went wrong ...</ p > }
33
+
32
34
{ ( storyStore . readableStories || [ ] ) . map ( story =>
33
35
< Story
34
36
key = { story . objectID }
Original file line number Diff line number Diff line change @@ -5,13 +5,21 @@ const isNotArchived = (archivedStoryIds) => (story) =>
5
5
6
6
class StoryStore {
7
7
@observable stories = [ ] ;
8
+ @observable error = null ;
8
9
9
10
constructor ( rootStore ) {
10
11
this . rootStore = rootStore ;
11
12
}
12
13
13
- @action setStories = stories =>
14
+ @action setStories = stories => {
14
15
this . stories = stories ;
16
+ this . error = null ;
17
+ }
18
+
19
+ @action setError = error => {
20
+ this . stories = [ ] ;
21
+ this . error = error ;
22
+ }
15
23
16
24
@computed get readableStories ( ) {
17
25
const { archivedStoryIds } = this . rootStore . archiveStore ;
You can’t perform that action at this time.
0 commit comments