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 SparseItemUtil so we don't enqueue twice #8127

Merged
merged 1 commit into from
Apr 7, 2022
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
9 changes: 5 additions & 4 deletions app/src/main/java/org/schabi/newpipe/util/SparseItemUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static void fetchItemInfoIfSparse(@NonNull final Context context,
// if the duration is >= 0 (provided that the item is not a livestream) and there is an
// uploader url, probably all info is already there, so there is no need to fetch it
callback.accept(new SinglePlayQueue(item));
return;
}

// either the duration or the uploader url are not available, so fetch more info
Expand All @@ -80,12 +81,12 @@ public static void fetchUploaderUrlIfSparse(@NonNull final Context context,
@NonNull final String url,
@Nullable final String uploaderUrl,
@NonNull final Consumer<String> callback) {
if (isNullOrEmpty(uploaderUrl)) {
fetchStreamInfoAndSaveToDatabase(context, serviceId, url,
streamInfo -> callback.accept(streamInfo.getUploaderUrl()));
} else {
if (!isNullOrEmpty(uploaderUrl)) {
callback.accept(uploaderUrl);
return;
}
fetchStreamInfoAndSaveToDatabase(context, serviceId, url,
streamInfo -> callback.accept(streamInfo.getUploaderUrl()));
}

/**
Expand Down