-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add sync button to playlist screen #534
Conversation
Thanks for the PR! |
added summary (lemme know if you want some screenshots or a video) @Chaphasilor it is similar, however my understanding of #460 is that it will sync every single parent (which i think could be an album or playlist) that exists on the downloads screen. The difference here is this lives solely on the playlist screen (not albums), this also removes any songs that are no longer part of the playlist anymore (need to test some edge cases with this tho). This also only syncs whatever playlist you are currently viewing (not all the playlists like the other button) |
@shayaantx okay, got it. Would there be a way to re-use some of the code from the other PR to keep things organized? Or are you already doing that? |
@Chaphasilor the only clean way I see to reuse that code would to not reuse it and replace that code with this code (since this removes items too) I can try to refactor it and see what I can come up with it |
Okay, then maybe you could split the logic into a separate file and function(s) so that it's easier to replace the existing code later on. Once I get around to testing this out, we can try to get this merged 😁 |
Not sure why the build it failing. I'll take a look soon! |
@Chaphasilor I was looking into the case where you have a downloaded item shared across playlists/album so it won't remove the downloaded item as long as the user synced both album and playlist (or playlist and playlist or album and album etc etc) So the user would have to had to press sync on the album/playlist with the song, then also sync on the other, then the DownloadSong::requiredBy won't be empty. I also wasn't passing "deleteFor" to DownloadsHelper::deleteDownloads() which was making it always remove it everytime (I fixed this in my recent push). I refactored it out as requested, still looking into possibly reusing this logic for the SyncDownloads stuff (just been busy - will try to look more this weekend) |
That sounds great! My own big PR got merged in recently so I'll be taking a look at the other open PRs soon, including yours. Should I wait until you looked into the reusability? |
Yea I'll repost once once I've figured out the reusability part |
@Chaphasilor so I refactored a few things locally:
However I found one issue, specifically with the delete part of the logic. If you recall before I mentioned I wasn't using "deletedFor" attribute when DownloadsHelper::deleteDownloads() This particular function always removes whatever the deletedFor value is from the parent caches (_downloadedParentsBox for example). This results in every sync removing the parent item (which basically makes the app look like nothing was downloaded) I'm investigating the best way to address this, basically seems like I might need to refactor some of the delete logic to be separate so I don't delete parent unless the user asks to delete the entire downloaded album/playlist and in the sync logic just delete items (unless they sync and the album/playlist is empty) |
Ah I see, that makes sense. I haven't looked at the code yet, but maybe adding a I'm not familiar with the downloading stuff myself, maybe @jmshrv has some additional input... |
@Chaphasilor yea I did something like that locally, need to test it a bit, then ill repush
|
Awesome! Looking forward to testing it out 😁 |
@Chaphasilor i tested out the changes with my own usage (seems fine), let me know if you find anything weird Behavior now:
|
@shayaantx I'd prefer that in the case where the playlist/album has not been downloaded and the delete icon is not shown, you show the download icon instead of the sync icon. The sync icon could be mistaken for a refresh icon, leaving users confused about how they can download the playlist :) Regarding the outdate requiredBy reference, that is expected behavior I think. Only thing I'm wondering about for the "Sync All" button, say that Playlist A removes a requiredBy for a certain song and Playlist B adds one for the same song, while syncing we should try to first update all "requiredBy"s and only then start deleting song. |
Did some quick testing, so far everything works 😁 |
Nice, I still need to change those buttons that you mentioned
This might be hard to do, need to think about it |
@Chaphasilor ok I made a slight modification to show the download button only if album/playlist hasn't been downloaded yet then if you click download, the buttons state updates, and you get a delete/sync button |
… yet (for album/playlist
Does your implementation add the new downloads to the downloads "queue"? So that it shows up on the "Downloads" screen as |
I would assume this issue has always existed, cause looking at original code there is nothing explicit for that (that looks to all be within the downloads helper). I've changed the stuff above that (i.e., what to download and what to remove) I will also mention that button (sync button on downloads screen), doesn't really do anything with UI when you click it, however I see it sync-ing my downloads if I leave the screen and come back. |
Yeah, the UI part also needs some work. But that's a different story... Is this PR ready to merge from your side? |
Just fixed the conflicts after merging #197, please let me know if I made a mistake anywhere! |
@shayaantx I noticed that if I download an album and then enable offline mode, it doesn't show up in the albums list until I restart the app. Can you reproduce? |
Another thing I noticed: if I delete an album but a track from that album is still in a playlist, the track stays downloaded on the device, but the album image does not. So the track is missing the album image, which isn't ideal. Not sure if that is in-scope for this PR though... Edit: this also results in a null check exception when trying to go to the album |
Thats the thing I mentioned earlier about refreshing a bit more aggressively. So if you do following:
So when the tab is in focus, its not doing a fresh load (offline enabled or not) - at least this is what I've seen.
Lemme investigate this |
Ahh okay I see, yeah that sounds like it could be improved. But I think we can get this merged first, since it's not a regression! |
Up to you boss, I can still look into the images removing kerfuffle too, doesn't matter to me. |
Yeah the album covers fix would be nice. But no need to look into the refreshing :) |
How are you reproducing it? Are you
If I follow above steps I can't seem to reproduce the behavior you described, however when I debug the code, it seems to delete the image, but the UI doesn't reflect it - dunno, but it def seems like it is executing the remove download image future erroneously
This is the download jellyfin items function snippet, basically if the song already exists, it will basically put the song in all the cache/collections/requiredBy fields then continues to next item. What's missing here is adding requiredby updates to the downloaded image itself (if it exists) for the item we are downloading (which already exists). So this seems like an existing bug cause I didn't change this logic - but I can push a commit to fix 2moro or sometime this weekend. |
What I did (iirc) was:
Could also be that I did 1 and 2 in reverse order... If you could figure out how to fix it, that would be awesome! 😁 |
@Chaphasilor I think I need to rewrite this entire download/remove function to make sense of this, like the way downloadImage gets managed is with requiredBy collection as well (however the ids we pass into this are song ids themselves). This is behavior I'm seeing so far: You can see above the playlist loses parent image, but retains song images. I saw some more weird logic (not sure if its from debugging), where after deleting first playlist, the downloaded song was missing - but I can't reproduce that without breakpoints (maybe the futures weren't executing properly cause of my breakpoints) Now if you modify steps to reproduce: You will get the entire shared song missing (this doesn't happen with the main sync button), but more cause the downloads helper does a hard delete in deleteDownloadChildren (which I kind of workaround in the download sync helper), the lil bit below
I dunno honestly, things get weird deleting, and all these collections used randomly everywhere to maintain persistent state isn't great. There seems like a greater need for a simpler model to store this data imo, but I'm super lazy :) |
Lemme debug it some more and see what I come up with |
…delete it, cause its shared...
@Chaphasilor ok I fixed the 2nd bug I mentioned by taking out the logic out of deleteDownloadChildren() that just deletes the song not including the deleteFor parameter (as that parameter causes the issue in this case and caused me some other problems down the line). The only annoying part is I duplicated that logic in a new method deleteSong(), cause the existing method honestly should be dismantled. I'm still not able to reproduce the first issue you mentioned, maybe I can add push some logging changes, and you reproduce and post logs? |
I'll try to repro it with your changes first, I'll take a look at those tomorrow! Sorry for not responding earlier... |
fyi the recent change isn't for your reported issue (although I think* that happens with this entire PR), its for when someone manually deletes a single shared song |
Repro is here: 2023-12-18-08-53-25_1.mp4It really is just:
|
@Chaphasilor oh you meant the cover image of the playlist/album not the individual track right? Cause I can reproduce the cover image disappearing with these steps, but the individual song still retains its image |
Actually no, at the end on the songs tab you can see the song is missing the cover. The album is also missing the cover, but since it's deleted it disappears right after refreshing anyway... |
FYI I've gone a different direction with this one, basically trying to decouple the download storage (which I'm calling the download store or whatever) from the downloads helper while trying to refactor how all this storage works and hopefully in the end these type of cases become easier (I hope) It is also possible I give up and just fix this specific use case :), but it really seems like all the Hive boxes shouldn't be all over the downloads helper cause then its always a case of did I put the right object in the right collection in new or existing methods (just makes seeing the downloaded songs and assets relationships much nicer I think). Lemme know if this is overkill too |
@shayaantx are you aware of the planned changes to the download functionality? Also discussed here: #213 Best read through it and make sure you're not putting in too much effort for something that will be completely re-built eventually :) |
Lol agree with all those bullet points, yea maybe I won't go into this I guess - I'll go back to trying to fix this specific edge case |
Also, #568 just dropped, take a look at this. That is a bigger project though and will probably take a bit longer to hit stable, so don't worry about your changes becoming obsolete :) We can get this PR merged as soon as you're happy with it! |
Yea that PR completely removes the downloads helper, which this PR hinges on Looking at that PR I see _syncDownload() does what appears to be a much easier to grok way of downloading, no idea how it would affect this PR So I guess you could merge it in this current state and Komodo5197 could merge in these changes into his or we could wait till he is done and merge this? |
I'd merge this first. The other PR should be rebased anyway. So we'll leave out the missing covers for now? It's not a huge deal anyway... |
fyi @Chaphasilor merged dec8e85 to resolve conflicts |
Merged. Merry Christmas 🎄 |
Downloads playlists on the playlist screen (will add anything missing and remove anything that doesn't exist in playlist anymore that is downloaded)