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

Function useFeedLayout

packages/shared/src/hooks/useFeedLayout.ts:116–168  ·  view source on GitHub ↗
({
  feedRelated = true,
}: UseFeedLayoutProps = {})

Source from the content-addressed store, hash-verified

114};
115
116export const useFeedLayout = ({
117 feedRelated = true,
118}: UseFeedLayoutProps = {}): UseFeedLayoutReturn => {
119 const isLaptopSize = useViewSize(ViewSize.Laptop);
120 const isLaptop = isLaptopSize;
121 const { feedName } = useActiveFeedNameContext();
122 const { insaneMode } = useContext(SettingsContext);
123 const { isSearchPageLaptop } = useSearchResultsLayout();
124
125 const isPostFeedPage = PostFeedPages.has(feedName as OtherFeedPage);
126
127 const isListMode = isSearchPageLaptop || insaneMode;
128
129 const shouldUseListFeedLayoutOnProfilePages = UserProfileFeedPages.has(
130 feedName as UserProfileFeedType,
131 );
132
133 const isFeedIncludedInListLayout = FeedLayoutMobileFeedPages.has(
134 feedName as OtherFeedPage,
135 );
136
137 const shouldUseListFeedLayoutOnMobileTablet =
138 !isLaptop && isFeedIncludedInListLayout;
139
140 const shouldUseListMode =
141 (isListMode && isLaptop && isFeedIncludedInListLayout) || isPostFeedPage;
142
143 const shouldUseListFeedLayout = feedRelated
144 ? shouldUseListFeedLayoutOnMobileTablet ||
145 shouldUseListFeedLayoutOnProfilePages ||
146 shouldUseListMode
147 : isListMode || !isLaptop;
148
149 const shouldUseCommentFeedLayout = feedName === OtherFeedPage.Discussed;
150
151 const FeedPageLayoutComponent = getFeedPageLayoutComponent({
152 shouldUseListMode,
153 shouldUseListFeedLayoutOnMobileTablet,
154 shouldUseCommentFeedLayout,
155 isSearchPageLaptop,
156 });
157
158 return {
159 shouldUseListFeedLayout,
160 shouldUseCommentFeedLayout,
161 FeedPageLayoutComponent,
162 isListMode,
163 shouldUseListMode,
164 screenCenteredOnMobileLayout:
165 shouldUseListFeedLayoutOnMobileTablet &&
166 !UserProfileFeedPages.has(feedName as UserProfileFeedType),
167 };
168};

Callers 15

MainLayoutComponentFunction · 0.90
BookmarkFeedLayoutFunction · 0.90
FeedFunction · 0.90
FeedItemComponentFunction · 0.90
MainFeedLayoutFunction · 0.90
SearchResultsLayoutFunction · 0.90
MarketingCtaVideoFunction · 0.90
FeedExploreHeaderFunction · 0.90
PostTagsFunction · 0.90
MyFeedHeadingFunction · 0.90
FeedContainerFunction · 0.90
HorizontalFeedFunction · 0.90

Calls 4

useViewSizeFunction · 0.90
useActiveFeedNameContextFunction · 0.90
useSearchResultsLayoutFunction · 0.90

Tested by

no test coverage detected