@@ -25,23 +25,25 @@ class Api {
2525 const finalArr = [ ] ;
2626 categories ( )
2727 . then ( ( categoriesData ) => {
28- Object . keys ( categoriesData ) . map ( ( key ) => {
29- const title = key ;
30- const newTitle = title . charAt ( 0 ) . toUpperCase ( ) + title . slice ( 1 ) ;
31- return finalArr . push ( { id : categoriesData [ key ] , title : newTitle , thumbnail : undefined } ) ;
32- // we have to add Thumbnail (both - to Firebase and app)
28+ Object . keys ( categoriesData ) . map ( ( key , index ) => {
29+ const categoryObject = categoriesData [ key ] ;
30+ return finalArr . push ( {
31+ id : index + 1 ,
32+ title : categoryObject . title ,
33+ thumbnail : categoryObject . thumbnail ,
34+ } ) ;
3335 } ) ;
3436 return finalArr ;
3537 } )
3638 . then ( ( nextData ) => {
3739 const newArray = [ ] ;
3840 nextData . map ( ( key , index ) => sites ( key . title )
3941 . then ( ( siteData ) => {
40- const itemsArray = [ ] ; // helper Array to store all formatted items
42+ const itemsArray = [ ] ;
4143 Object . keys ( siteData ) . map ( ( key1 , index1 ) => itemsArray . push ( {
4244 id : `${ finalArr [ index ] . id } _${ index1 } ` ,
4345 title : siteData [ key1 ] . title ,
44- url : `http:// ${ siteData [ key1 ] . url } ` , // for now it will produce bad URL for links starting with http:// or https:// [needs to be changed in database]
46+ url : siteData [ key1 ] . url ,
4547 thumbnail : siteData [ key1 ] . thumbnail ,
4648 } ) ) ;
4749 newArray . push ( { ...finalArr [ index ] , items : itemsArray } ) ;
0 commit comments