@@ -9,16 +9,17 @@ import Drawer from "./Drawer";
99import Title from "./Title" ;
1010import TopSites from "./TopSites" ;
1111import { TitleLoader } from "./LoadingSpinner" ;
12- import { thumbSourceLink , KEY_MAP , APOD_API_URL , API_KEY } from "../utilities" ;
12+ import { KEY_MAP , APOD_API_URL } from "../utilities" ;
1313import {
1414 adjacentDate ,
1515 isToday ,
1616 today ,
1717 randomDate ,
18- MIN_APOD_DATE
18+ MIN_APOD_DATE ,
1919} from "../utilities/dateUtility" ;
2020import HistoryHelper from "../utilities/history" ;
2121import Preload from "../utilities/preload-utility" ;
22+ import HistoryRow from "./HistoryRow" ;
2223
2324const MAX_ERROR_TRIES = 3 ;
2425const ERROR_MESSAGE = "NASA APOD Error: Please reload or try Again Later" ;
@@ -31,17 +32,18 @@ class Apod extends Component {
3132 selection : string ,
3233 isHighRes : bool ,
3334 showTopSites : bool ,
35+ showHistoryRow : bool ,
3436 showTodayOptions : shape ( {
3537 count : number ,
3638 limit : number ,
37- isLimitOn : bool
39+ isLimitOn : bool ,
3840 } ) ,
3941 favorites : objectOf (
4042 shape ( {
4143 url : string ,
42- title : string
44+ title : string ,
4345 } )
44- )
46+ ) ,
4547 } ;
4648
4749 state = {
@@ -50,14 +52,14 @@ class Apod extends Component {
5052 isLoading : true ,
5153 isImageHD : false ,
5254 hasLoadingError : false ,
53- videoUrl : undefined
55+ videoUrl : undefined ,
5456 } ;
5557
5658 componentDidMount ( ) {
5759 const bypassLoadCount = true ;
5860 const {
5961 selection,
60- showTodayOptions : { count, limit, isLimitOn }
62+ showTodayOptions : { count, limit, isLimitOn } ,
6163 } = this . props ;
6264
6365 const chooseRandom =
@@ -74,7 +76,7 @@ class Apod extends Component {
7476 this . setState ( { isLoading : true , response : undefined } ) ;
7577 } ;
7678
77- specificDate = date => {
79+ specificDate = ( date ) => {
7880 this . getImage ( date ) ;
7981 } ;
8082
@@ -120,7 +122,11 @@ class Apod extends Component {
120122
121123 getImage = ( date , errorCount = 0 ) => {
122124 this . setLoading ( ) ;
123- const params = { date, api_key : API_KEY } ;
125+ const params = {
126+ date,
127+ image_thumbnail_size : 450 ,
128+ absolute_thumbnail_url : true ,
129+ } ;
124130 axios . get ( APOD_API_URL , { params } ) . then (
125131 ( { data } ) => this . loadApod ( data ) ,
126132 ( ) => this . errorApod ( errorCount )
@@ -139,22 +145,22 @@ class Apod extends Component {
139145
140146 saveFavorite = ( ) => {
141147 const { favorites } = this . props ;
142- const { date, title } = this . state . response ;
148+ const { date, title, image_thumbnail } = this . state . response ;
143149
144150 if ( ! favorites || ! favorites [ date ] ) {
145151 chrome . storage . sync . set ( {
146152 apodFavorites : {
147153 ...favorites ,
148154 [ date ] : {
149155 title,
150- imgUrl : thumbSourceLink ( date )
151- }
152- }
156+ imgUrl : image_thumbnail ,
157+ } ,
158+ } ,
153159 } ) ;
154160 }
155161 } ;
156162
157- loadApod = response => {
163+ loadApod = ( response ) => {
158164 const { isHighRes } = this . props ;
159165 historyHelper . add ( response ) ;
160166 if ( response . media_type === "video" ) {
@@ -164,7 +170,7 @@ class Apod extends Component {
164170 response,
165171 videoUrl,
166172 apodImage : undefined ,
167- isLoading : false
173+ isLoading : false ,
168174 } ) ;
169175 } catch ( err ) {
170176 console . log ( err ) ;
@@ -175,7 +181,7 @@ class Apod extends Component {
175181 }
176182 } ;
177183
178- errorApod = errorCount => {
184+ errorApod = ( errorCount ) => {
179185 if ( errorCount >= MAX_ERROR_TRIES ) {
180186 this . setState ( { hasLoadingError : true } ) ;
181187 } else {
@@ -206,7 +212,7 @@ class Apod extends Component {
206212 response,
207213 isImageHD,
208214 isLoading : false ,
209- apodImage : loadedImage
215+ apodImage : loadedImage ,
210216 } ) ;
211217 } ;
212218
@@ -216,14 +222,14 @@ class Apod extends Component {
216222 } ;
217223
218224 render ( ) {
219- const { favorites, showTopSites } = this . props ;
225+ const { favorites, showTopSites, showHistoryRow } = this . props ;
220226 const {
221227 response,
222228 apodImage,
223229 isImageHD,
224230 isLoading,
225231 hasLoadingError,
226- videoUrl
232+ videoUrl,
227233 } = this . state ;
228234
229235 const handlers = {
@@ -244,7 +250,7 @@ class Apod extends Component {
244250 } ,
245251 NEXT_HISTORY : ( ) => {
246252 this . recallHistory ( true ) ;
247- }
253+ } ,
248254 } ;
249255
250256 const dateNavigation = {
@@ -253,11 +259,11 @@ class Apod extends Component {
253259 current : this . current ,
254260 random : this . random ,
255261 forceHighDef : this . forceHighDef ,
256- saveFavorite : this . saveFavorite
262+ saveFavorite : this . saveFavorite ,
257263 } ;
258264
259265 const headerStyle = {
260- justifyContent : showTopSites ? "space-between" : "flex-end"
266+ justifyContent : showTopSites ? "space-between" : "flex-end" ,
261267 } ;
262268
263269 return (
@@ -286,8 +292,14 @@ class Apod extends Component {
286292 response = { response }
287293 favorites = { favorites }
288294 specificDate = { this . specificDate }
289- historyHelper = { historyHelper }
290295 />
296+ { showHistoryRow && (
297+ < HistoryRow
298+ historyHelper = { historyHelper }
299+ specificDate = { this . specificDate }
300+ activeResponse = { response }
301+ />
302+ ) }
291303 </ div >
292304 </ GlobalHotKeys >
293305 ) ;
0 commit comments