Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions client/blocks/reader-feed-item/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFeedQuery } from '@automattic/api-queries';
import { readFeedQuery, readFeedSiteQuery } from '@automattic/api-queries';
import { recordTrainTracksInteract, recordTrainTracksRender } from '@automattic/calypso-analytics';
import { ExternalLink } from '@automattic/components';
import { Reader, SubscriptionManager } from '@automattic/data-stores';
Expand Down Expand Up @@ -77,7 +77,9 @@ export default function ReaderFeedItem( props: ReaderFeedItemProps ): JSX.Elemen
...readFeedQuery( feedId ),
enabled: queryFeed,
} );
const { data: site, isLoading: isSiteLoading } = Reader.useReadFeedSiteQuery( Number( blogId ) );
const { data: site, isLoading: isSiteLoading } = useQuery(
readFeedSiteQuery( Number( blogId ) )
);

// Reader feed item fields to show in the UI.
const description = isWpcomFeed ? site?.description : feed?.description;
Expand Down
6 changes: 4 additions & 2 deletions client/reader/stream/customer-council-banner.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Reader, SubscriptionManager } from '@automattic/data-stores';
import { readFeedSiteQuery } from '@automattic/api-queries';
import { SubscriptionManager } from '@automattic/data-stores';
import { useQuery } from '@tanstack/react-query';
import Banner from 'calypso/components/banner';
import { navigate } from 'calypso/lib/navigate';
import { useSelector } from 'calypso/state';
Expand All @@ -15,7 +17,7 @@ export const CustomerCouncilBanner = ( { translate } ) => {
data: p2,
isFetched: checkedAlreadySubscribed,
isFetching: checkingAlreadySubscribed,
} = Reader.useReadFeedSiteQuery( Number( CUSTOMER_COUNCIL_P2_ID ) );
} = useQuery( readFeedSiteQuery( Number( CUSTOMER_COUNCIL_P2_ID ) ) );
const alreadySubscribed = p2?.is_following;

const isAutomattician = useSelector( isA8cTeamMember );
Expand Down
1 change: 1 addition & 0 deletions packages/api-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export * from './products';
export * from './products';
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

packages/api-core/src/index.ts currently exports ./products twice (two identical export * from './products'; lines). Since this PR is already touching the barrel in this area (adding ./read-sites), it’s a good opportunity to drop the duplicate export to keep the entrypoint clean and avoid confusion about where exports come from.

Suggested change
export * from './products';

Copilot uses AI. Check for mistakes.
export * from './plans';
export * from './read-feeds';
export * from './read-sites';
export * from './read-teams';
export * from './site';
export * from './site-activity-log';
Expand Down
14 changes: 14 additions & 0 deletions packages/api-core/src/read-sites/fetchers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { addQueryArgs } from '@wordpress/url';
import { wpcom } from '../wpcom-fetcher';
import type { ReadFeedSiteResponse } from './types';

const fields = [ 'ID', 'name', 'title', 'URL', 'icon', 'is_following', 'description' ].join( ',' );
const options = [ 'is_mapped_domain', 'unmapped_url', 'is_redirect' ].join( ',' );

export const fetchReadFeedSite = ( siteId: number ): Promise< ReadFeedSiteResponse > => {
return wpcom.req.get( {
path: addQueryArgs( `/read/sites/${ siteId }`, { fields, options } ),
apiVersion: '1.1',
method: 'GET',
} );
};
2 changes: 2 additions & 0 deletions packages/api-core/src/read-sites/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './fetchers';
export * from './types';
9 changes: 9 additions & 0 deletions packages/api-core/src/read-sites/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export interface ReadFeedSiteResponse {
ID: number;
URL: string;
description: string;
feed_ID: number;
feed_URL?: string;
icon?: { ico: string; img: string };
is_following: boolean;
}
1 change: 1 addition & 0 deletions packages/api-queries/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export * from './plans';
export * from './plugin';
export * from './products';
export * from './read-feed';
export * from './read-site';
export * from './site-activity-log';
export * from './site-activity-log-backup';
export * from './site-address-change';
Expand Down
10 changes: 10 additions & 0 deletions packages/api-queries/src/read-site.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { fetchReadFeedSite } from '@automattic/api-core';
import { queryOptions } from '@tanstack/react-query';

export const readFeedSiteQuery = ( siteId?: number ) => {
return queryOptions( {
queryKey: [ 'read', 'sites', siteId ],
queryFn: () => fetchReadFeedSite( siteId! ),
enabled: typeof siteId === 'number' && siteId > 0,
} );
};
2 changes: 0 additions & 2 deletions packages/data-stores/src/reader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,4 @@ export {
SiteSubscriptionsSortBy,
} from './constants';
export { callApi, isErrorResponse, isSiteSubscriptionDetails, isValidId } from './helpers';
export { useReadFeedSiteQuery } from './queries';

export * from './types';
1 change: 0 additions & 1 deletion packages/data-stores/src/reader/queries/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export { default as usePendingPostSubscriptionsQuery } from './use-pending-post-subscriptions-query';
export { default as usePendingSiteSubscriptionsQuery } from './use-pending-site-subscriptions-query';
export { default as usePostSubscriptionsQuery } from './use-post-subscriptions-query';
export { default as useReadFeedSiteQuery } from './use-read-feed-site-query';
export { default as useSiteSubscriptionDetailsQuery } from './use-site-subscription-details-query';
export {
default as useSiteSubscriptionsQuery,
Expand Down

This file was deleted.

Loading