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
[video][music] Hide play-related context menu items for party mode pl… #23919
[video][music] Hide play-related context menu items for party mode pl… #23919
Conversation
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.
Sorry to be the usual pain in the ass but IMO I think both of the new checks you added for video and music could be useful elsewhere in the future or at least make sense in a method of is own (reused then in IsItemPlayable
). Mind creating a new method in each class HasPartyModePlaylist(item)
or similar for now to make it easier to move elsewhere (if needed) in the future?
@enen92 thanks for asking, but my answer is no. :-) Let my explain: I have a multi-step strategy here, mainly for getting complexity down to something managable for me. What I'm doing is to refactor all the playback/queue related functionality for video and music from currently lots of different source code units in a first step to two implementations, one for music, one for video. This already reduces code copies a lot. Only if I'm done with this first step I can judge on what exactly needs to be done to do the final step, to get down from two implementation, still containing code duplicates to one base carrying the common things for video and music + two (small) specializations, one for music one for video. Until then, I will not start to factor out some of the duplicates, because this might be something that needs to be reverted later. |
Maybe I've explained myself wrong. The request is not to avoid duplicates or concentrate these checks elsewhere is just to reduce the complexity of the already existing checks. Also it doesn't go against your refactoring strategy.
^^ ok, so the 5 lines below are checking if a music party mode playlist exists... I don't really understand why you refuse to create a simple private method (or even on an anonymous namespace) on each class where you simple name it according to what you're checking and dump those code blocks (the actual logic) inside.... I.e., if I am interesting in knowing why something is not playable I am interested in knowing it is not playable because the item is an empty party mode playlist. I am not interested in knowing the business logic around what makes/means an empty party mode playlist (even more if that involves the usage of multiple subsystems). |
@enen92 then I indeed misread your initial comment.
Now that I understand what you mean, yes, that ofc. makes perfect sense. Will change this (anon namespace for now) and keep in mind as a pattern for the future. |
@enen92 I have my difficulties for this particular case to find a method name reflecting the actual functionality. We must not invert the semantics here. I need something I can early return on return false. A positive check will not work (without rewriting even more code.). A "positive check" will not be of help here. Do you have an idea? |
The reason I ask for this is because I also have difficulties understanding what you're doing. Care to explain what you are actually trying to check?
|
Well, it is exactly what that comment says: Check for the partymode playlist item, nothing to play if it does not exist. Rephrased: Only if a party mode playlist exists it can be played. The problem is the general code flow here, which cannot easily changed. I cannot work with something like IsPartymodePlaylistExisting() return true; Because there will be other checks below that will return true after this method returned false. Yes, maybe all bad design, but really, compared to what we had before I started this refactoring (I must be crazy), we are way better now.
|
I have a suggestion @enen92: Come up with a diff as I have no clue how to name the block of code you want me to factor out and I will happily apply the change. It is not a |
Maybe: bool IsNonExistingUserPartyModePlaylist(const CFileItem& item)
{
if (!item.IsSmartPlayList())
return false;
const std::string path{item.GetPath()};
const auto profileManager = CServiceBroker::GetSettingsComponent()->GetProfileManager();
return ((profileManager->GetUserDataItem("PartyMod-Video.xsp") == path) &&
!CFileUtils::Exists(path));
} if (IsNonExistingUserPartyModePlaylist(item)
return false; Fine for you? |
…party mode playlists.
23e6b3b
to
05fddad
Compare
Updated PR with |
…aylists if not existing.
In video or music window, the node "Playlists" contains always an entry "Party mode playlist" (see screen shot below). What happens when clicking on this entry depends on whether there already was a party mode playlist created. If yes, the content of that list will be displayed in the respective window, if not, a dialog to create the playlist will be opened. If no playlist exists (yet) and you open the context menu of the "Party mode playlist" item, it should not contain any playback related items, because there is nothing to play. This is, what this PR does: hiding those context menu entries in case there is no party mode playlist yet.
Runtime-tested on macOS and Android, latest Kodi master.
@enen92 a quick code review would be nice.