Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions packages/shared/src/components/MainFeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import {
ANONYMOUS_FEED_QUERY,
baseFeedSupportedTypes,
CUSTOM_FEED_QUERY,
feedV2SupportedTypes,
FEED_BY_TAGS_QUERY,
FEED_V2_QUERY,
FOLLOWING_FEED_QUERY,
MOST_DISCUSSED_FEED_QUERY,
MOST_UPVOTED_FEED_QUERY,
SEARCH_POSTS_QUERY,
getFeedV2SupportedTypes,
} from '../graphql/feed';
import { generateQueryKey, OtherFeedPage, RequestKey } from '../lib/query';
import SettingsContext from '../contexts/SettingsContext';
Expand Down Expand Up @@ -61,7 +61,6 @@ import {
discussedFeedVersion,
feature,
featureFeedTagChips,
featureFeedV2Highlights,
followingFeedVersion,
latestFeedVersion,
popularFeedVersion,
Expand Down Expand Up @@ -322,16 +321,6 @@ export default function MainFeedLayout({
feature: customFeedVersion,
shouldEvaluate: feedName === SharedFeedPage.Custom,
});
const shouldEvaluateFeedV2Highlights =
!!user &&
((feedName === SharedFeedPage.MyFeed && !isCustomDefaultFeed) ||
feedName === SharedFeedPage.Search ||
(feedName === SharedFeedPage.CustomForm &&
router.query?.slugOrId === user?.id));
const { value: isFeedV2HighlightsEnabled } = useConditionalFeature({
feature: featureFeedV2Highlights,
shouldEvaluate: shouldEvaluateFeedV2Highlights,
});

const isChipStripPage =
router.pathname === '/' || router.pathname === '/explore/[tag]';
Expand Down Expand Up @@ -424,8 +413,7 @@ export default function MainFeedLayout({
dynamicFeedConfig?.query || feedConfig.query,
dynamicFeedConfig?.queryIfLogged || feedConfig.queryIfLogged || null,
);
const shouldRequestFeedV2Highlights =
query === FEED_V2_QUERY && isFeedV2HighlightsEnabled;
const shouldRequestFeedV2Highlights = query === FEED_V2_QUERY;

return {
requestKey: feedConfig.requestKey,
Expand All @@ -435,7 +423,7 @@ export default function MainFeedLayout({
...dynamicFeedConfig?.variables,
...(shouldRequestFeedV2Highlights
? {
supportedTypes: getFeedV2SupportedTypes(true),
supportedTypes: feedV2SupportedTypes,
highlightsLimit: FEED_V2_HIGHLIGHTS_LIMIT,
}
: {}),
Expand All @@ -460,7 +448,6 @@ export default function MainFeedLayout({
customFeedV,
tokenRefreshed,
feedVersion,
isFeedV2HighlightsEnabled,
]);

const [selectedAlgo, setSelectedAlgo, loadedAlgo] = usePersistentContext(
Expand Down
7 changes: 3 additions & 4 deletions packages/shared/src/graphql/feed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
baseFeedSupportedTypes,
FEED_V2_HIGHLIGHTS_LIMIT,
FEED_V2_QUERY,
getFeedV2SupportedTypes,
feedV2SupportedTypes,
normalizeFeedPage,
} from './feed';

Expand All @@ -20,9 +20,8 @@ describe('normalizeFeedPage', () => {
expect(FEED_V2_HIGHLIGHTS_LIMIT).toBe(5);
});

it('should add highlight to feedV2 supported types only when enabled', () => {
expect(getFeedV2SupportedTypes(false)).toEqual(baseFeedSupportedTypes);
expect(getFeedV2SupportedTypes(true)).toEqual([
it('should always include highlight in feedV2 supported types', () => {
expect(feedV2SupportedTypes).toEqual([
...baseFeedSupportedTypes,
'highlight',
]);
Expand Down
7 changes: 1 addition & 6 deletions packages/shared/src/graphql/feed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,7 @@ const joinedTypes = baseFeedSupportedTypes.join('","');
export const SUPPORTED_TYPES = `$supportedTypes: [String!] = ["${joinedTypes}"]`;
export const FEED_V2_HIGHLIGHTS_LIMIT = 5;

export const getFeedV2SupportedTypes = (
shouldSupportHighlights: boolean,
): string[] =>
shouldSupportHighlights
? [...baseFeedSupportedTypes, 'highlight']
: [...baseFeedSupportedTypes];
export const feedV2SupportedTypes = [...baseFeedSupportedTypes, 'highlight'];

export interface FeedData {
page: Connection<Post>;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/lib/featureManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const upvotedFeedVersion = new Feature('upvoted_feed_version', 2);
export const discussedFeedVersion = new Feature('discussed_feed_version', 2);
export const latestFeedVersion = new Feature('latest_feed_version', 2);
export const customFeedVersion = new Feature('custom_feed_version', 2);
export const featureFeedV2Highlights = new Feature('feed_v2_highlights', false);
export const featurePostPageHighlights = new Feature(
'post_page_highlights',
false,
Expand Down
Loading