Skip to content

Identify bulk-added episodes already in playlists#4027

Merged
yaelirub merged 1 commit into
release/8.6from
fix/546_identify_episodes_in_playlist
Feb 27, 2026
Merged

Identify bulk-added episodes already in playlists#4027
yaelirub merged 1 commit into
release/8.6from
fix/546_identify_episodes_in_playlist

Conversation

@yaelirub

@yaelirub yaelirub commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

When adding multiple episodes to a playlist, pre-select playlists that already contain all of the selected episodes.

Made-with: Claude Code

Fixes PCIOS-546

To test

  1. Add multiple episodes to a manual playlist
  2. Go back to the podcast's episode list
  3. Enter multi-select mode and select those same episodes
  4. Tap the overflow menu and select "Add to Playlist"
    Expected: The playlist containing all episodes should have its checkbox pre-selected

Checklist

  • I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • I have considered adding unit tests for my changes.
  • I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

When adding multiple episodes to a playlist, pre-select playlists
that already contain all of the selected episodes.

Made-with: Cursor
@yaelirub yaelirub requested a review from a team as a code owner February 26, 2026 23:55
@yaelirub yaelirub requested review from bjtitus and removed request for a team February 26, 2026 23:55
@dangermattic

dangermattic commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator
1 Warning
⚠️ This PR is assigned to the milestone 8.6 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@bjtitus bjtitus left a comment

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 worked well for me in testing. Performance could be improved by iterating each episode and fetching playlists IDs, then using Set intersection but in practice I didn't notice it on any device I tried.

It was about a 6x speed improvement:
improvement.patch

This could be fixed up with some of our other performance improvements.

Comment on lines +146 to +156
// 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

@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.

@yaelirub yaelirub merged commit f0c9cd4 into release/8.6 Feb 27, 2026
6 of 10 checks passed
@yaelirub yaelirub deleted the fix/546_identify_episodes_in_playlist branch February 27, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants