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

Function MainFeedLayout

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

Source from the content-addressed store, hash-verified

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