fix(YouTube - Hide Shorts components): Hide Shorts suggestions in video player, if all hide Shorts options are enabled

This commit is contained in:
LisoUseInAIKyrios 2024-04-12 20:26:12 +04:00
parent 4fd3cc906d
commit afc073af81
2 changed files with 22 additions and 6 deletions

View File

@ -220,20 +220,34 @@ public final class ShortsFilter extends Filter {
}
private static boolean shouldHideShortsFeedItems() {
final boolean hideHome = Settings.HIDE_SHORTS_HOME.get();
final boolean hideSubscriptions = Settings.HIDE_SHORTS_SUBSCRIPTIONS.get();
final boolean hideSearch = Settings.HIDE_SHORTS_SEARCH.get();
if (hideHome && hideSubscriptions && hideSearch) {
// Shorts suggestions can load in the background if a video is opened and
// then immediately minimized before any suggestions are loaded.
// In this state the player type will show minimized, which makes it not possible to
// distinguish between Shorts suggestions loading in the player and between
// scrolling thru search/home/subscription tabs while a player is minimized.
//
// To avoid this situation for users that never want to show Shorts (all hide Shorts options are enabled)
// then hide all Shorts everywhere including the Library history and Library playlists.
return true;
}
// Must check player type first, as search bar can be active behind the player.
if (PlayerType.getCurrent().isMaximizedOrFullscreen()) {
// For now, consider the under video results the same as the home feed.
return Settings.HIDE_SHORTS_HOME.get();
return hideHome;
}
// Must check second, as search can be from any tab.
if (NavigationBar.isSearchBarActive()) {
return Settings.HIDE_SHORTS_SEARCH.get();
return hideSearch;
}
// Avoid checking navigation button status if all other settings are off.
final boolean hideHome = Settings.HIDE_SHORTS_HOME.get();
final boolean hideSubscriptions = Settings.HIDE_SHORTS_SUBSCRIPTIONS.get();
// Avoid checking navigation button status if all other Shorts should show.
if (!hideHome && !hideSubscriptions) {
return false;
}

View File

@ -216,8 +216,10 @@ public final class NavigationBar {
// Release any threads waiting for the selected nav button.
releaseNavButtonLatch();
} else if (NavigationButton.selectedNavigationButton == button) {
NavigationButton.selectedNavigationButton = null;
Logger.printDebug(() -> "Navigated away from button: " + button);
// Do not clear the selected navigation button, otherwise it's possible
// a background litho thread can check between the clearing of the selected button
// and setting the new button. Instead it should use the last selected nav button.
}
} catch (Exception ex) {
Logger.printException(() -> "navigationTabSelected failure", ex);