Skip to content
This repository was archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
fix: Hide suggestion shelf layout components everywhere except the li…
Browse files Browse the repository at this point in the history
…brary tab
  • Loading branch information
LisoUseInAIKyrios committed Apr 5, 2024
1 parent 73a2b30 commit a7814f1
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public final class SuggestionsShelfFilter extends Filter {
public SuggestionsShelfFilter() {
addPathCallbacks(
new StringFilterGroup(
null, // Setting is based on navigation state.
Settings.HIDE_SUGGESTIONS_SHELF,
"horizontal_video_shelf.eml",
"horizontal_shelf.eml"
)
Expand All @@ -22,17 +22,19 @@ public SuggestionsShelfFilter() {
@Override
boolean isFiltered(@Nullable String identifier, String path, byte[] protobufBufferArray,
StringFilterGroup matchedGroup, FilterContentType contentType, int contentIndex) {
if (shouldHideSuggestionsShelf() && contentIndex == 0)
if (contentIndex == 0 && shouldHideSuggestionsShelf()) {
return super.isFiltered(path, identifier, protobufBufferArray, matchedGroup, contentType, contentIndex);
}

return false;
}

private static boolean shouldHideSuggestionsShelf() {
return Settings.HIDE_SUGGESTIONS_SHELF.get()
&& NavigationBar.NavigationButton.HOME.isSelected() // Home tab is selected.
&& !PlayerType.getCurrent().isMaximizedOrFullscreen() // The player is not opened.
&& !NavigationBar.isSearchBarActive(); // Search is not active.

// Only filter if the library tab is not selected.
// This check is important as the suggestion shelf layout is used for the library tab playlists.
return !NavigationBar.NavigationButton.libraryOrYouTabIsSelected()
// But if the player is opened while library is selected,
// then still filter any recommendations below the player.
|| PlayerType.getCurrent().isMaximizedOrFullscreen();
}
}

0 comments on commit a7814f1

Please sign in to comment.