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

Function MainFeedLayout

packages/shared/src/components/MainFeedLayout.tsx:379–1277  ·  view source on GitHub ↗
({
  feedName: feedNameProp,
  searchQuery,
  isSearchOn,
  children,
  searchChildren,
  shortcuts,
  navChildren,
  isFinder,
  onNavTabClick,
  pageHeaderContent,
}: MainFeedLayoutProps)

Source from the content-addressed store, hash-verified

377];
378
379export default function MainFeedLayout({
380 feedName: feedNameProp,
381 searchQuery,
382 isSearchOn,
383 children,
384 searchChildren,
385 shortcuts,
386 navChildren,
387 isFinder,
388 onNavTabClick,
389 pageHeaderContent,
390}: MainFeedLayoutProps): ReactElement {
391 const { sortingEnabled, loadedSettings } = useContext(SettingsContext);
392 const { user, isTokenValid } = useContext(AuthContext);
393 const { alerts } = useContext(AlertContext);
394 const { numCards: feedSpacinessCards } = useContext(FeedContext);
395 const feedWidthStyle = {
396 '--num-cards': feedSpacinessCards.eco,
397 '--feed-gap': '1.5rem',
398 } as CSSProperties;
399 const router = useRouter();
400 const [tab, setTab] = useState(ExploreTabs.Popular);
401 const feedName = getFeedName(feedNameProp, {
402 hasFiltered: !alerts?.filter,
403 hasUser: !!user,
404 });
405 const { isCustomDefaultFeed, defaultFeedId } = useCustomDefaultFeed();
406 const isLaptop = useViewSize(ViewSize.Laptop);
407 // Explore's hub is in the server HTML for phones, shown by CSS: the
408 // server cannot know the screen, so it and the first client render emit
409 // it, and wider screens drop it once they have mounted.
410 const [hasMounted, setHasMounted] = useState(false);
411 const isPhoneWidth = useViewSize(ViewSize.MobileL) && !isLaptop;
412 useEffect(() => {
413 setHasMounted(true);
414 }, []);
415 const isPhone = useIsPhone();
416 const isLaptopLayout = useLaptopLayout();
417 const feedVersion = useFeature(feature.feedVersion);
418 const { time, contentCurationFilter, postTypesFilter } =
419 useSearchContextProvider();
420 const isExtension = checkIsExtension();
421 const isExploreRoot =
422 !isExtension && isRootView(ShellRoot.Explore, router?.pathname ?? '');
423 const isHomePage = router.pathname === webappUrl;
424 const {
425 isUpvoted,
426 isPopular,
427 isAnyExplore,
428 isExploreLatest,
429 isSortableFeed,
430 isCustomFeed,
431 isSearch: isSearchPage,
432 } = useFeedName({
433 feedName,
434 });
435 useTrackQuestClientEvent({
436 eventType: ClientQuestEventType.VisitExplorePage,

Callers

nothing calls this directly

Calls 15

getFeedNameFunction · 0.90
useViewSizeFunction · 0.90
useIsPhoneFunction · 0.90
useLaptopLayoutFunction · 0.90
useFeatureFunction · 0.90
checkIsExtensionFunction · 0.90
isRootViewFunction · 0.90
useFeedNameFunction · 0.90
useTrackQuestClientEventFunction · 0.90
useFeedLayoutFunction · 0.90
useConditionalFeatureFunction · 0.90
getSearchPageProviderFunction · 0.90

Tested by

no test coverage detected