Skip to content
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

Implement missing equals and hashcode methods for feeditem #7132

Merged
merged 2 commits into from Apr 24, 2024

Conversation

flofriday
Copy link
Contributor

@flofriday flofriday commented Apr 23, 2024

Description

Closes: #7108

The episodes were never removed from the Queue screen or the queue segment on the homescreen because no QueueEventwas emitted.

However, after closer inspection I found that there was already code in DBWriter to remove all such items:

private static void deleteFeedItemsSynchronous(@NonNull Context context, @NonNull List<FeedItem> items) {

With more debugging I discovered that the queue.remove always returned false and never removed any items even if they were structurally equal. Since FeedItem doesn't override equal the two identical items are only equal if they are the same instance which is here never the case and therefore this never finds the matching items in the queue.

By adding the equals method the bug is fixed as the code now works as intended.

Questions:
I implemented equals by just comparing the feedid and id of the item. This is mostly cause I don't want to cyclic equals where a feeditem defines equals with it's feed and the feed with all the items it holds. However, I am not sure if the assumption is save to make that two FeedItems are always equal if those two id's match so maybe someone with more experience can verify that.

Also while we're at it should we implement equals for more classes like the Feed and FeedMedia ?

Checklist

@ByteHamster
Copy link
Member

Good catch! Looks like I broke this in https://github.com/AntennaPod/AntennaPod/pull/6949/files#diff-9c20b246182eef6913022401d63ea1112a36a7c89c123337fff1c50efe11f6af

Adding to Feed and FeedMedia sounds good, thanks!

@ByteHamster
Copy link
Member

Could you please change the target branch to master? Then we can get this directly to the beta releases instead of waiting for the next full release

@flofriday flofriday changed the base branch from develop to master April 24, 2024 06:23
Till 5713b18 many classes like FeedItem
used to inherit from FeedComponent which provided those two methods.
However since that commit the component no longer exists and now the
classes need to implement it on their own.
@flofriday
Copy link
Contributor Author

I now implemented the methods for all the classes that used to inherit from FeedComponent and rebased on master instead of dev.

@ByteHamster ByteHamster merged commit 4bc0b38 into AntennaPod:master Apr 24, 2024
6 checks passed
@ByteHamster
Copy link
Member

Thanks! Will be released in beta3

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.

Episode not removed from Home Queue section when Podcast is deleted
2 participants