Skip to content
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

Fix removing only fully watched videos from playlist #8259

Merged
merged 7 commits into from May 5, 2022

Conversation

LingYinTianMeng
Copy link
Contributor

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

Before fixing, in the playlist view press "Remove watched', then press "OK", no videos are removed. After fixing, all completely watched videos can be removed.

Before/After Screenshots/Screen Record

  • Before:
before.mp4
  • After:
After.mp4

Fixes the following issue(s)

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.

Due diligence

@opusforlife2 opusforlife2 changed the title Fix Videos can't have "watched" status and/or "Remove watched" doesn't work and/or "playback position" feature is bugged #7563 Fix Videos can't have "watched" status and/or "Remove watched" doesn't work and/or "playback position" feature is bugged Apr 28, 2022
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Thank you! I forgot about this when I improved how stream states are saved

Comment on lines 421 to 432
final StreamStateEntity streamStateEntity = streamStatesIter.next();
final long duration = playlistItem.toStreamInfoItem().getDuration();
boolean isFinished = false;
if (streamStateEntity != null) {
isFinished = streamStateEntity.isFinished(duration);
}
final boolean isNotWatchedItem = (streamStateEntity != null
&& !isFinished);
if (indexInHistory < 0) {
notWatchedItems.add(playlistItem);
} else if (isNotWatchedItem) {
notWatchedItems.add(playlistItem);
Copy link
Member

Choose a reason for hiding this comment

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

The logic was difficult to understand, this is clearer in my opinion (also keep the newline)

Suggested change
final StreamStateEntity streamStateEntity = streamStatesIter.next();
final long duration = playlistItem.toStreamInfoItem().getDuration();
boolean isFinished = false;
if (streamStateEntity != null) {
isFinished = streamStateEntity.isFinished(duration);
}
final boolean isNotWatchedItem = (streamStateEntity != null
&& !isFinished);
if (indexInHistory < 0) {
notWatchedItems.add(playlistItem);
} else if (isNotWatchedItem) {
notWatchedItems.add(playlistItem);
final StreamStateEntity streamStateEntity = streamStatesIter.next();
final long duration = playlistItem.toStreamInfoItem().getDuration();
if (indexInHistory < 0 || (streamStateEntity != null && streamStateEntity.isFinished(duration))) {
notWatchedItems.add(playlistItem);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is indexInHistory < 0 || (streamStateEntity != null && !streamStateEntity.isFinished(duration)), there should be
a "!" before streamStateEntity.isFinished(duration)

Copy link
Member

Choose a reason for hiding this comment

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

Ooops, yes, you are right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I have modified it.

@Stypox Stypox changed the title Fix Videos can't have "watched" status and/or "Remove watched" doesn't work and/or "playback position" feature is bugged Fix removing only fully watched videos from playlist May 2, 2022
Copy link
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

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

Spaces should be kept. Other than that, thanks :-)

@Stypox Stypox merged commit a1435bd into TeamNewPipe:dev May 5, 2022
@sonarcloud
Copy link

sonarcloud bot commented May 5, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@Stypox Stypox mentioned this pull request Jun 24, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants