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

Function useFeedLayout

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

Source from the content-addressed store, hash-verified

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

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