Skip to content

Commit

Permalink
fix(YouTube - Return YouTube Dislike): Do not prefetch Shorts shelf i…
Browse files Browse the repository at this point in the history
…tems on app startup
  • Loading branch information
LisoUseInAIKyrios committed Dec 17, 2023
1 parent 869b209 commit 697c2aa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ public static void preloadVideoId(@NonNull String videoId, boolean isShortAndOpe
return;
}

final boolean videoIdIsShort = VideoInformation.lastVideoIdIsShort();
final boolean videoIdIsShort = VideoInformation.lastPlayerResponseIsShort();
// Shorts shelf in home and subscription feed causes player response hook to be called,
// and the 'is opening/playing' parameter will be false.
// This hook will be called again when the Short is actually opened.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public final class VideoInformation {

@NonNull
private static volatile String playerResponseVideoId = "";
private static volatile boolean playerResponseVideoIdIsShort;
private static volatile boolean videoIdIsShort;

/**
Expand Down Expand Up @@ -82,6 +83,7 @@ public static boolean playerParametersAreShort(@NonNull String parameters) {
*/
public static String newPlayerResponseSignature(@NonNull String signature, boolean isShortAndOpeningOrPlaying) {
final boolean isShort = playerParametersAreShort(signature);
playerResponseVideoIdIsShort = isShort;
if (!isShort || isShortAndOpeningOrPlaying) {
if (videoIdIsShort != isShort) {
videoIdIsShort = isShort;
Expand Down Expand Up @@ -206,11 +208,17 @@ public static String getPlayerResponseVideoId() {
return playerResponseVideoId;
}

/**
* @return If the last player response video id was a Short.
* Includes Shorts shelf items appearing in the feed that are not opened.
* @see #lastVideoIdIsShort()
*/
public static boolean lastPlayerResponseIsShort() {
return playerResponseVideoIdIsShort;
}

/**
* @return If the last player response video id _that was opened_ was a Short.
* <p>
* Note: This value returned may not match the status of {@link #getPlayerResponseVideoId()}
* since that includes player responses for videos not opened.
*/
public static boolean lastVideoIdIsShort() {
return videoIdIsShort;
Expand Down

0 comments on commit 697c2aa

Please sign in to comment.