daviddeutsch / yt-sanegrid

YouTube abandoned the subscription grid view. This has made a lot of people very angry and been widely regarded as a bad move.
http://daviddeutsch.github.io/yt-sanegrid/
GNU General Public License v3.0
37 stars 10 forks source link

Promises fix #151

Open kalaspuffar opened 9 years ago

kalaspuffar commented 9 years ago

Hi again David.

Had some time to sit and code on yt-sane again and tried to get it to a working copy where you could load videos and reload so you get the latest in the list.

First I merged your changes from gh-pages into the master branch.

Found another place where youtube changed the API from doc to value on the channel response and that made it not load. Later I looked into all the promises handling and found some places where you saved the promises object in an array instead of the promise which in turn didn't trigger the $q.all method later.

Also moved a $q.all trigger so it was insured to have promises to wait for.

Lastly I found that you couldn't ask the API for 200 videos in one go so I chunked up the question to ask for 10 videos each time. Might be few but I just wanted to get it to work.

Looked at the code this morning and realized that I had a problem with scopes in the chunking function. So I added an angular forEach instead with a function scope so I could get a new scope for my deferrer. This code needs to be refactored to look nicer but it seems to work and I get new videos into my list when I push update. It work but slowly. :)

Hope this code is useful for your future development.

Best regards Daniel