JonWash86 / Bonsai-Radio

A playlist management application which leverages the spotify and last.fm apis to bring joy to music nerds
http://www.bonsairadio.com
1 stars 1 forks source link

kill the allCallSongs global variable by not fetching spotify data until we're done processing last.fm api responses #14

Closed jrheard closed 5 years ago

jrheard commented 5 years ago

the main trick here is to wait until we're done getting responses to our last.fm api requests before we start kicking off spotify requests and building playlist dropdowns with event handlers and templating code that requires last.fm data in order to function.

note that this means that the playlist dropdown will now be empty for several seconds until our last.fm history has been processed. this could be mitigated by:

  1. disabling the dropdown until it's been populated and having it say "please wait" or something, then (in an else clause of the if(response.next) if statement in the success function in getPlaylistTracks()?) enabling it once we're done processing spotify api respones
  2. (eventually!) using localstorage to cache last.fm history so that the app initializes relatively instantly after the first pageload instead of always fetching the entire 4-week last.fm history

i've clicked around and verified that the app looks sane locally on my machine, but you know it better than i do - if i missed anything, or if my approach seems insane, or if you see bugs or have feedback / etc, please say so!