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

Function FeedNav

packages/shared/src/components/feeds/FeedNav.tsx:60–235  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58);
59
60function FeedNav(): ReactElement | null {
61 const router = useRouter();
62 const { feedName: rawFeedName } = useActiveFeedNameContext();
63 const feedName = rawFeedName as AllFeedPages;
64 const { sortingEnabled } = useSettingsContext();
65 const { isSortableFeed } = useFeedName({ feedName });
66 const { home, bookmarks } = useActiveNav(feedName);
67 const isMobile = useViewSize(ViewSize.MobileL);
68 const isBelowLaptop = !useViewSize(ViewSize.Laptop);
69 const { value: feedChipsVariant } = useConditionalFeature({
70 feature: featureFeedChips,
71 shouldEvaluate: isBelowLaptop,
72 });
73 const isFeedChipsEnabled = feedChipsVariant === FeedChipsVariant.V2;
74 const [selectedAlgo, setSelectedAlgo] = usePersistentContext(
75 DEFAULT_ALGORITHM_KEY,
76 DEFAULT_ALGORITHM_INDEX,
77 [0, 1],
78 DEFAULT_ALGORITHM_INDEX,
79 );
80 const featureTheme = useFeatureTheme();
81 const scrollClassName = useScrollTopClassName({ enabled: !!featureTheme });
82 const { feeds } = useFeeds();
83 const { isCustomDefaultFeed, defaultFeedId } = useCustomDefaultFeed();
84 const sortedFeeds = useSortedFeeds({ edges: feeds?.edges });
85 const isForYouTab =
86 router.pathname === webappUrl || router.pathname === `${webappUrl}my-feed`;
87 const { plusEntryForYou } = usePlusEntry();
88 const showStickyButton =
89 isMobile &&
90 ((sortingEnabled && isSortableFeed) || feedName === SharedFeedPage.Custom);
91
92 const urlToTab: Record<string, string> = useMemo(() => {
93 const customFeeds = sortedFeeds.reduce<Record<string, string>>(
94 (acc, { node: feed }) => {
95 const isEditingFeed =
96 router.query.slugOrId === feed.id &&
97 router.pathname.endsWith('/edit');
98 let feedPath = `${webappUrl}feeds/${feed.id}`;
99
100 if (
101 !isEditingFeed &&
102 isCustomDefaultFeed &&
103 feed.id === defaultFeedId
104 ) {
105 feedPath = `${webappUrl}`;
106 }
107
108 const urlPath = `${feedPath}${isEditingFeed ? '/edit' : ''}`;
109
110 acc[urlPath] = feed.flags?.name || `Feed ${feed.id}`;
111
112 return acc;
113 },
114 {},
115 );
116
117 const forYouTab = isCustomDefaultFeed ? `${webappUrl}my-feed` : webappUrl;

Callers

nothing calls this directly

Calls 14

useActiveFeedNameContextFunction · 0.90
useSettingsContextFunction · 0.90
useFeedNameFunction · 0.90
useViewSizeFunction · 0.90
useConditionalFeatureFunction · 0.90
useFeatureThemeFunction · 0.90
useScrollTopClassNameFunction · 0.90
useFeedsFunction · 0.90
useSortedFeedsFunction · 0.90
useActiveNavFunction · 0.85
usePersistentContextFunction · 0.85
useCustomDefaultFeedFunction · 0.85

Tested by

no test coverage detected