Skip to content

Restrict duplicate video additions and implement DiffUtil to prevent list flickering and crashes during playlist pagination. - #13981

Closed
Ayush32-ai wants to merge 3 commits into
TeamNewPipe:devfrom
Ayush32-ai:dev
Closed

Ayush32-ai wants to merge 3 commits into
TeamNewPipe:devfrom
Ayush32-ai:dev

Conversation

@Ayush32-ai

@Ayush32-ai Ayush32-ai commented Nov 1, 2026 •

Copy link
Copy Markdown

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

This PR fixes duplicate videos being added to local playlists and improves how playlist items are updated.

  • Added a check in PlaylistAppendDialog.java to prevent adding a video if it's already in the selected playlist. A Toast message is shown when the video is already there.
  • Added cleanTimingFromUrl() in LocalPlaylistManager.kt to remove timestamp parameters from video URLs. This makes sure the same video is recognized even if it has a different start time, such as ?t=30s or #t=1m.
  • Updated getPlaylistDuplicates() and appendToPlaylist() to check for duplicates before adding items to the database.
  • Added unit tests for duplicate detection in LocalPlaylistManagerDuplicateTest.kt.
  • Updated PlaylistFragment.java and LocalPlaylistFragment.java to use DiffUtil instead of refreshing the entire list whenever the data changes.
  • Added InfoItemDiffCallback.kt and LocalItemDiffCallback.kt, along with tests for InfoItemDiffCallback.kt.
  • Handled repeated stream URLs in InfoItemDiffCallback.kt using occurrence-based indexing so identical URLs are matched correctly and don't cause incorrect moves or index-related crashes.

Before/After Screenshots/Screen Record

  • Before: Duplicate videos could be added to playlists, and refreshing the list could cause flickering or other issues.
  • After: Duplicate additions are blocked, and playlist updates are handled more efficiently.

Fixes the following issue(s)

Relies on the following changes

  • None.

Testing/QA

Devices
  • Nothing Phone (2a)
Steps for testing
  • Added a video to a local playlist and tried adding it again to check that duplicates are blocked.
  • Checked duplicate detection for URLs with different timestamp parameters.
  • Tested playlist updates, including loading and pagination, to check that items are updated correctly.
  • Ran the unit tests for duplicate detection and DiffUtil.
APK for testing

The debug APK is available under the Checks tab of the PR, in the CI artifacts.

Due diligence

WhatsApp Image 2026-11-01 at 04 00 11

@github-actions github-actions Bot added size/large PRs with less than 750 changed lines template-ignored labels Nov 1, 2026
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Please link this PR to an existing issue you are assigned to. This PR might be closed if the details of this PR were not agreed upon beforehand.

@Ayush32-ai

Copy link
Copy Markdown
Author

@TobiGr Please check the code and pull request.

@TobiGr TobiGr closed this Nov 1, 2026
@Ayush32-ai

Copy link
Copy Markdown
Author

@TobiGr suggestion regarding my pull request.

@github-actions github-actions Bot reopened this Nov 1, 2026
@sonarqubecloud

sonarqubecloud Bot commented Nov 1, 2026

Copy link
Copy Markdown

@TobiGr

TobiGr commented Nov 1, 2026

Copy link
Copy Markdown
Member
  1. The PR contains tons of changes which are in no way related to the goal
  2. The contents of the PR were not discussed beforehand
  3. The PR contains more than one change
  4. The PR and/or parts of the original PR description are AI generated.

We need to enfore strict contibution guidelines to keep the workload manageble.

@Ayush32-ai Ayush32-ai closed this Nov 1, 2026
@theimpulson theimpulson added the spam This change violates contribution guidelines of NewPipe. label Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/large PRs with less than 750 changed lines spam This change violates contribution guidelines of NewPipe. template-ignored

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playlist crash when deleting a Video after fully watched

3 participants