Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,17 @@ class ManualPlaylistsChooserViewController: PCViewController {
let uuids = dataManager.manualPlaylistUUIDs(for: episode.uuid)
initialSelectedPlaylists = Set(uuids)
} else {
initialSelectedPlaylists = []
// For bulk episodes, find playlists that contain ALL selected episodes
var playlistsContainingAllEpisodes: Set<String> = []
for playlist in manualPlaylists {
let allEpisodesInPlaylist = episodes.allSatisfy { episode in
dataManager.manualPlaylistUUIDs(for: episode.uuid).contains(playlist.uuid)
}
if allEpisodesInPlaylist {
playlistsContainingAllEpisodes.insert(playlist.uuid)
}
}
initialSelectedPlaylists = playlistsContainingAllEpisodes
Comment on lines +146 to +156

@bjtitus bjtitus Feb 27, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could be sped up by iterating over and storing the playlist UUIDs in a Set and intersecting the sets. The more playlists you have the more this matters and in my testing it took quite a few (many dozens + hundreds of episodes) to notice any difference. We could fix this up later or now

Suggested change
// For bulk episodes, find playlists that contain ALL selected episodes
var playlistsContainingAllEpisodes: Set<String> = []
for playlist in manualPlaylists {
let allEpisodesInPlaylist = episodes.allSatisfy { episode in
dataManager.manualPlaylistUUIDs(for: episode.uuid).contains(playlist.uuid)
}
if allEpisodesInPlaylist {
playlistsContainingAllEpisodes.insert(playlist.uuid)
}
}
initialSelectedPlaylists = playlistsContainingAllEpisodes
// For bulk episodes, find playlists that contain ALL selected episodes
let playlistSets = episodes.map { episode in
Set(dataManager.manualPlaylistUUIDs(for: episode.uuid))
}
initialSelectedPlaylists = playlistSets.dropFirst().reduce(playlistSets.first ?? []) { accumulated, uuids in
accumulated.intersection(uuids)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion. Lets do this for next release. Can you please create a ticket for it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I created an implementation on the find playlists containing episode using a direct SQL query here: #4026

I believe that approach could be more efficient when there is a lot of playlist and episodes to check.

}
newSelectedPlaylists = initialSelectedPlaylists
}
Expand Down
Loading