-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Subscriptions section available on Reader sidebar with Popula…
…r sites section (#96954) * In Reader recent screen replaced `ReaderListFollowedSites` component with `ReaderPopularSitesSidebar` * Added `title` prop in `ReaderPopularSitesSidebar` component to make `title` implementation consistent. * Removed the unused `ReaderListFollowedSites` component.
- Loading branch information
Showing
8 changed files
with
101 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { translate } from 'i18n-calypso'; | ||
import { useEffect } from 'react'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { Dispatch } from 'redux'; | ||
import { RecommendedSite } from 'calypso/state/data-layer/wpcom/read/recommendations/sites'; | ||
import { | ||
RecommendedSitesRequestAction, | ||
requestRecommendedSites, | ||
} from 'calypso/state/reader/recommended-sites/actions'; | ||
import { getReaderRecommendedSites } from 'calypso/state/reader/recommended-sites/selectors'; | ||
import { READER_RECENT_SIDEBAR_POPULAR_SITES } from '../follow-sources'; | ||
import ReaderPopularSitesSidebar from '../stream/reader-popular-sites-sidebar'; | ||
|
||
export const RECOMMENDED_SITES_SEED = Math.floor( Math.random() * 10001 ); | ||
|
||
function ReaderStreamSidebar(): JSX.Element | null { | ||
const dispatch = useDispatch< Dispatch< RecommendedSitesRequestAction > >(); | ||
const recommendedSites = useSelector( ( state ) => { | ||
return getReaderRecommendedSites< RecommendedSite >( state, RECOMMENDED_SITES_SEED ) || []; | ||
} ); | ||
|
||
useEffect( () => { | ||
// Avoid fetching recommended sites if they are already present in the store. | ||
if ( recommendedSites.length > 0 ) { | ||
return; | ||
} | ||
|
||
dispatch( requestRecommendedSites( { seed: RECOMMENDED_SITES_SEED, number: 10 } ) ); | ||
}, [ dispatch, recommendedSites ] ); | ||
|
||
if ( recommendedSites.length === 0 ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<ReaderPopularSitesSidebar | ||
followSource={ READER_RECENT_SIDEBAR_POPULAR_SITES } | ||
items={ recommendedSites.map( ( s ) => { | ||
return { | ||
blogId: s.blogId, | ||
feed_ID: s.feedId, | ||
feed_URL: s.feedUrl, | ||
site_name: s.title, | ||
site_description: s.description, | ||
site_icon: s.icon, | ||
url: s.url, | ||
}; | ||
} ) } | ||
title={ translate( 'Popular sites' ) } | ||
/> | ||
); | ||
} | ||
|
||
export default ReaderStreamSidebar; |
157 changes: 0 additions & 157 deletions
157
client/reader/stream/reader-list-followed-sites/index.jsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters