language-transfer / lt-app

React Native application for Language Transfer
https://www.languagetransfer.org/
Other
291 stars 26 forks source link

Re-populate the queue when downloads finish #10

Open SyntaxBlitz opened 4 years ago

SyntaxBlitz commented 4 years ago

If the user begins downloading a bunch of tracks, then starts listening to the course before these downloads finish, the tracks will stream from the server even once the course audio is downloaded to the phone.

This can be kinda crappy if the user has "download only on wi-fi" set, starts a bunch of downloads, starts listening to the course, and then leaves their home once a bunch of tracks have downloaded. It's a safe assumption that the downloaded audio will be used, but in fact the audio will still stream from the server.

This is because we don't update existing tracks in the queue when a download completes. The queue is wiped whenever the user presses the stop button, navigates to a different screen in the app, or kills the app, but listening straight through will prevent the queue from being updated.

A fix for this would observe download-finish events and splice the lesson from the queue (assuming it's in there), replacing it with a track object that has the local URL.

The same issue applies to deleted downloads in the queue.