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

Function MainFeedLayout

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

Source from the content-addressed store, hash-verified

224];
225
226export default function MainFeedLayout({
227 feedName: feedNameProp,
228 searchQuery,
229 isSearchOn,
230 children,
231 searchChildren,
232 shortcuts,
233 navChildren,
234 isFinder,
235 onNavTabClick,
236}: MainFeedLayoutProps): ReactElement {
237 useScrollRestoration();
238 const { sortingEnabled, loadedSettings } = useContext(SettingsContext);
239 const { user, tokenRefreshed } = useContext(AuthContext);
240 const { alerts } = useContext(AlertContext);
241 const { numCards: feedSpacinessCards } = useContext(FeedContext);
242 const router = useRouter();
243 const [tab, setTab] = useState(ExploreTabs.Popular);
244 const feedName = getFeedName(feedNameProp, {
245 hasFiltered: !alerts?.filter,
246 hasUser: !!user,
247 });
248 const { isCustomDefaultFeed, defaultFeedId } = useCustomDefaultFeed();
249 const isLaptop = useViewSize(ViewSize.Laptop);
250 const { isV2 } = useLayoutVariant();
251 const feedVersion = useFeature(feature.feedVersion);
252 const { time, contentCurationFilter } = useSearchContextProvider();
253 const isExtension = checkIsExtension();
254 const isHomePage = router.pathname === webappUrl;
255 const {
256 isUpvoted,
257 isPopular,
258 isAnyExplore,
259 isExploreLatest,
260 isSortableFeed,
261 isCustomFeed,
262 isSearch: isSearchPage,
263 } = useFeedName({
264 feedName,
265 });
266 useTrackQuestClientEvent({
267 eventType: ClientQuestEventType.VisitExplorePage,
268 enabled: feedName === OtherFeedPage.Explore,
269 });
270 useTrackQuestClientEvent({
271 eventType: ClientQuestEventType.VisitDiscussionsPage,
272 enabled: feedName === OtherFeedPage.Discussed,
273 });
274 const {
275 shouldUseListFeedLayout: shouldUseListFeedLayoutRaw,
276 shouldUseCommentFeedLayout,
277 FeedPageLayoutComponent: FeedPageLayoutComponentRaw,
278 } = useFeedLayout();
279
280 // SSR renders /explore/[tag] with FeedPageLayoutMobile. On client hydration with
281 // a laptop viewport the layout swaps to FeedPage, which causes a hydration
282 // Done just for explore tag for now to avoid impact other pages
283 const isExploreTag = feedName === OtherFeedPage.ExploreTag;

Callers

nothing calls this directly

Calls 15

useScrollRestorationFunction · 0.90
getFeedNameFunction · 0.90
useViewSizeFunction · 0.90
useLayoutVariantFunction · 0.90
useFeatureFunction · 0.90
checkIsExtensionFunction · 0.90
useFeedNameFunction · 0.90
useTrackQuestClientEventFunction · 0.90
useFeedLayoutFunction · 0.90
useConditionalFeatureFunction · 0.90
useSearchIdFunction · 0.90
useFeedsFunction · 0.90

Tested by

no test coverage detected