fix(download): remove deleted/cancelled items from the Downloads list in real time (#1227)#2598
fix(download): remove deleted/cancelled items from the Downloads list in real time (#1227)#2598LeC-D wants to merge 2 commits into
Conversation
fire-light42
left a comment
There was a problem hiding this comment.
Please review our AI Policy https://github.com/recloudstream/cloudstream/blob/master/AI-POLICY.md
|
Hi @fire-light42, thanks for pointing to the AI policy. To be transparent: this fix was developed with AI assistance (GitHub Copilot / Claude for context exploration). I'm fully responsible for understanding and verifying the code — the approach directly mirrors the existing Let me know if you have any concerns about the implementation itself! |
|
Updated the PR description to include the AI usage disclosure directly in the body, as required by the AI Policy. Thanks for flagging this, @fire-light42! |
|
Rebased on upstream |
|
Thank you for your contribution! I will test and review soon. The code looks good, but getting these things right can be tricky. Do not concern yourself with merge conflicts or keeping the branch up to date, I will resolve any conflicts if necessary 👍 |
|
I can not replicate the stale download state. |
…ecloudstream#1227) Issue recloudstream#1227 reports that cancelled downloads keep showing as episode/movie cards on the Downloads page. The previous change only hooked downloadDeleteEvent in BaseFetchButton, which resets the download *button* on the result page but never touches the Downloads list itself. Observe VideoDownloadManager.downloadDeleteEvent at the activity-scoped DownloadViewModel so both DownloadFragment (headers) and DownloadChildFragment (children) drop the deleted item in real time, with no manual refresh. The handler also keeps multi-select state consistent. Uses thread-safe LiveData postValue since the event fires on the downloader's background thread. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Quick status update to clear up confusion about what this PR actually does — the original title/description undersold its scope. The code already covers the full #1227 fix (2 files, the diff hasn't changed):
Together this hooks @fire-light43 — I think the earlier difficulty reproducing came from the old description, which pointed at the button rather than the Downloads list. The #1227 symptom is on the list. Repro:
I've updated the title and description to match. Happy to attach a before/after recording if that helps. |
Fixes #1227.
Problem
When a download is cancelled or deleted,
VideoDownloadManager.downloadDeleteEventfires — but until now only the download button (BaseFetchButton) listened to it. The Downloads page itself never reacted, so a deleted episode/movie card stayed on screen until the user navigated away and back. That stale card is the actual bug reported in #1227 ("UI still showing episodes/movies that were deleted").Fix
DownloadViewModel— the core #1227 fix. Subscribes todownloadDeleteEventat the activity-scoped (shared) ViewModel level and removes the deleted id from the header + child lists live, so bothDownloadFragment(headers) andDownloadChildFragment(children) refresh with no manual reload. It also clears the id from multi-select state. UsespostValueonly, since the event fires on the downloader's background thread. This hooks the event "to update the UI in case of deletion from any source" (result page, queue, notification, …), as the issue asks.BaseFetchButton— resets the button viaresetView()on a matchingpersistentId; subscription wired inonAttached/DetachedFromWindow, mirroring the existingdownloadStatusEventhandling. This keeps an on-screen download button from showing a stale state after a deletion elsewhere.How to reproduce (the #1227 symptom)
I'm happy to attach a before/after screen recording if useful.