()
| 130 | } |
| 131 | |
| 132 | loadData() { |
| 133 | this.updateState({ |
| 134 | isLoading: true, |
| 135 | showBottomButton: false, |
| 136 | }); |
| 137 | this.cancelable = makeCancelable(fetch(this.genFetchUrl(this.state.inputKey))); |
| 138 | this.cancelable.promise |
| 139 | .then((response)=>response.json()) |
| 140 | .then((responseData)=> { |
| 141 | if (!this || !responseData || !responseData.items || responseData.items.length === 0) { |
| 142 | this.refs.toast.show(this.state.inputKey + ' nothing found.', DURATION.LENGTH_SHORT); |
| 143 | this.updateState({isLoading: false, rightButtonText: 'Go',}); |
| 144 | return; |
| 145 | } |
| 146 | this.items = responseData.items; |
| 147 | this.getFavoriteKeys(); |
| 148 | if (!this.checkKeyIsExist(this.keys, this.state.inputKey)) { |
| 149 | this.updateState({showBottomButton: true,}) |
| 150 | } |
| 151 | }) |
| 152 | .catch((error)=> { |
| 153 | this.updateState({ |
| 154 | isLoading: false, |
| 155 | rightButtonText: 'Go', |
| 156 | }); |
| 157 | }); |
| 158 | } |
| 159 | |
| 160 | updateFavorite() { |
| 161 | this.getFavoriteKeys(); |
nothing calls this directly
no test coverage detected