MCPcopy Create free account
hub / github.com/dailydotdev/apps / FeedNav

Function FeedNav

packages/shared/src/components/feeds/FeedNav.tsx:83–352  ·  view source on GitHub ↗
({
  inShellBlock = false,
  canShowSignInStrip = false,
}: FeedNavProps)

Source from the content-addressed store, hash-verified

81}
82
83function FeedNav({
84 inShellBlock = false,
85 canShowSignInStrip = false,
86}: FeedNavProps): ReactElement | null {
87 const router = useRouter();
88 const { feedName: rawFeedName } = useActiveFeedNameContext();
89 const feedName = rawFeedName as AllFeedPages;
90 const { sortingEnabled } = useSettingsContext();
91 const { isSortableFeed } = useFeedName({ feedName });
92 const { home, bookmarks, profile } = useActiveNav(feedName);
93 const isMobile = useViewSize(ViewSize.MobileL);
94 const isBelowLaptop = !useViewSize(ViewSize.Laptop);
95 // The notifications bell only belongs to the tablet feed header: phones get it
96 // from the footer nav and laptop+ from the app header. JS-gated (not CSS) so
97 // it never mounts alongside those placements.
98 const isTablet = isBelowLaptop && !isMobile;
99 const isMobileAppHeader = useMobileAppHeader();
100 const { value: feedChipsVariant } = useConditionalFeature({
101 feature: featureFeedChips,
102 shouldEvaluate: isBelowLaptop && !inShellBlock,
103 });
104 const isFeedChipsEnabled = feedChipsVariant !== FeedChipsVariant.None;
105 const [selectedAlgo, setSelectedAlgo] = usePersistentContext(
106 DEFAULT_ALGORITHM_KEY,
107 DEFAULT_ALGORITHM_INDEX,
108 [0, 1],
109 DEFAULT_ALGORITHM_INDEX,
110 );
111 const forYouSort = useForYouSort();
112 // Phones keep Debug in the For you sheet, opened from the lit For you tab,
113 // so the row has no switch to crowd out the tabs.
114 const { isOffered: hasForYouSheet, isExplaining } = useFeedExplainMode({
115 isRecommended: forYouSort.selected === DEFAULT_ALGORITHM_INDEX,
116 });
117 const [isForYouSheetOpen, setIsForYouSheetOpen] = useState(false);
118 const featureTheme = useFeatureTheme();
119 const scrollClassName = useScrollTopClassName({ enabled: !!featureTheme });
120 const { feeds } = useFeeds();
121 const { isCustomDefaultFeed, defaultFeedId } = useCustomDefaultFeed();
122 const sortedFeeds = useSortedFeeds({ edges: feeds?.edges });
123 const isForYouTab =
124 router.pathname === webappUrl || router.pathname === `${webappUrl}my-feed`;
125 const { plusEntryForYou } = usePlusEntry();
126 const showFeedActions =
127 isMobile &&
128 ((sortingEnabled && isSortableFeed) || feedName === SharedFeedPage.Custom);
129 const shouldRenderFeedChips = isBelowLaptop && isFeedChipsEnabled;
130
131 const renderFeedActions = (iconOnly?: boolean) => (
132 <>
133 {sortingEnabled && isSortableFeed && (
134 <Dropdown
135 className={{
136 label: 'hidden',
137 chevron: 'hidden',
138 button: '!px-1',
139 }}
140 shouldIndicateSelected

Callers

nothing calls this directly

Calls 15

useActiveFeedNameContextFunction · 0.90
useSettingsContextFunction · 0.90
useFeedNameFunction · 0.90
useViewSizeFunction · 0.90
useMobileAppHeaderFunction · 0.90
useConditionalFeatureFunction · 0.90
useForYouSortFunction · 0.90
useFeedExplainModeFunction · 0.90
useFeatureThemeFunction · 0.90
useScrollTopClassNameFunction · 0.90
useFeedsFunction · 0.90
useSortedFeedsFunction · 0.90

Tested by

no test coverage detected