Skip to content

fix(download): hook downloadDeleteEvent in BaseFetchButton to reset UI on cancel#2598

Open
LeC-D wants to merge 1 commit intorecloudstream:masterfrom
LeC-D:fix/download-button-delete-event
Open

fix(download): hook downloadDeleteEvent in BaseFetchButton to reset UI on cancel#2598
LeC-D wants to merge 1 commit intorecloudstream:masterfrom
LeC-D:fix/download-button-delete-event

Conversation

@LeC-D
Copy link
Copy Markdown

@LeC-D LeC-D commented Apr 2, 2026

Fixes #1227

Problem

When a download is cancelled from a notification, the download button UI (in episode list, result screen, etc.) is not updated. The button keeps showing a stale download state instead of resetting.

Root cause

downloadDeleteEvent was implemented as a stub in BaseFetchButton but the event subscription was commented out in onAttachedToWindow / onDetachedFromWindow, so the callback was never invoked.

Fix

  • Implement downloadDeleteEvent(data: Int): when the deleted ID matches persistentId, call resetView() to bring the button back to its initial state.
  • Subscribe to VideoDownloadManager.downloadDeleteEvent in onAttachedToWindow.
  • Unsubscribe in onDetachedFromWindow to avoid memory leaks.

This pattern is identical to how downloadStatusEvent and downloadProgressEvent are already handled in the same class.

AI Usage Disclosure

This fix was developed with AI assistance (GitHub Copilot / Claude for context exploration), per the project's AI Policy. I am fully responsible for understanding and verifying the code. The approach directly mirrors existing patterns already in BaseFetchButton, and the change has been manually reviewed and tested.

Copy link
Copy Markdown
Collaborator

@fire-light42 fire-light42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LeC-D
Copy link
Copy Markdown
Author

LeC-D commented Apr 2, 2026

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 downloadStatusEvent and downloadProgressEvent patterns already in BaseFetchButton, so the change is straightforward and intentional. I've reviewed and tested the logic manually.

Let me know if you have any concerns about the implementation itself!

@LeC-D
Copy link
Copy Markdown
Author

LeC-D commented Apr 2, 2026

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!

@LeC-D
Copy link
Copy Markdown
Author

LeC-D commented Apr 3, 2026

Rebased on upstream master (2026-04-03) to bring the branch back up to date.

@fire-light42
Copy link
Copy Markdown
Collaborator

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 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Download does not get removed when cancelling from a notification.

2 participants