-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: update UI when download status changes #113
Conversation
@@ -81,7 +81,7 @@ class DownloadManagerImpl @Inject constructor( | |||
override val progressUpdates: MutableMap<String, DownloadProgressUpdate> = mutableMapOf() | |||
override val progressUpdateRelay: Subject<DownloadProgressUpdate> = ReplaySubject.createWithSize(20) | |||
|
|||
private var workManagerListener: LiveData<Pair<List<WorkInfo>, Map<String?, Playable>>>? = null | |||
private var workManagerListener: LiveData<Pair<List<WorkInfo>, Map<String?, String>>>? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was very tempted to wrap one or both of these Strings with an inline class in order to make it clear what is what. I can be a little type-happy at times though, so I held off. It might be interesting to use some value classes for things like UUIDs throughout the app though. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work fixing this!
@@ -159,7 +162,8 @@ class DownloadManagerImpl @Inject constructor( | |||
|
|||
episodeManager.findPlayableByUuid(episodeUUID)?.let { | |||
episodeManager.updateDownloadTaskId(it, null) | |||
if (!episode.isDownloaded && it.episodeStatus != EpisodeStatusEnum.NOT_DOWNLOADED) { | |||
val episode = episodeManager.findPlayableByUuid(episodeUUID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for getting the episode out of the database again after the updateDownloadTaskId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, there is not. I just totally overlooked that we already had the episode here as it
. 🤦 Thanks for catching that! 🙇 I've addressed this in 6684ff9.
Description
Fixes #112
When a download is started by adding something to the up next queue (because of the auto download setting), if you switch from an unmetered to a metered connection, the download status still shows that the download is in progress even though the download has actually been paused.
This is occurring because the download is listening for episode changes and putting those episodes into a map keyed on the download task id. That map is not updated however, unless there is a new/removed/changed uuid. As a result, that episode instance's
episodeStatus
remains in "waiting for wifi" even once the download starts. Then when the download stops, the app checks if theepisodeStatus
needs updating to "waiting for wifi", but because it checks against the outdated episode instance contained in the map, it doesn't think theepisodeStatus
needs to be updated even though theepisodeStatus
of the episode in the db should be updated.This PR addresses that issue by instead retrieving the "current" episode from the database to see if the
episodeStatus
needs to be updated. In addition, I have changed theid -> episode
to instead be anid -> uuid
map to help avoid us from making this mistake again in the future.Test Steps
Checklist