-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reader: clean up cardpicking logic / move off sitestore/feedstore #11618
Conversation
ce5656d
to
bb617c8
Compare
client/reader/list-gap/index.jsx
Outdated
@@ -13,9 +13,10 @@ var FeedStreamStoreActions = require( 'lib/feed-stream-store/actions' ), | |||
var Gap = React.createClass( { | |||
|
|||
propTypes: { | |||
gap: React.PropTypes.object.isRequired, | |||
gap: React.PropTypes.object, | |||
postKey: React.PropTypes.object, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would a gap have a postKey?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
according to client/lib/feed-stream-store/feed-stream.js
, a gap is a type of postKey. I'm still a bit iffy on this logic though
IN_STREAM_RECOMMENDATION, | ||
} from 'reader/follow-button/follow-sources'; | ||
|
||
function EmptySearchRecommendedPosts( { post } ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if its possible to somehow combine this with our other type of RecommendedPost
@samouri This PR needs a rebase |
106dab8
to
b0eb67a
Compare
b0eb67a
to
944e235
Compare
client/reader/utils.js
Outdated
const { blogId, postId } = post.referral; | ||
query += `ref_blog=${ blogId }&ref_post=${ postId }`; | ||
} | ||
|
||
const method = replaceHistory ? 'replace' : 'show'; | ||
if ( post.feed_ID && post.feed_item_ID ) { | ||
page[ method ]( `/read/feeds/${ post.feed_ID }/posts/${ post.feed_item_ID }${ hashtag }${ query }` ); | ||
if ( postKey.blogId && postKey.postId ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should prefer the feed item, not the blog item. blog items are less reliable for jetpack sites.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
though maybe we make this smarter and default to blogs when it's not a vip or something... hrm.
there's prefer_feed
on site objects now. maybe we could use that? See https://public-api.wordpress.com/rest/v1.2/read/sites/fivethirtyeight.com
}; | ||
} | ||
// by throwing out blogId if feed_item_ID exist then we know if its a feed/blog from here on out | ||
const keyMaker = post => ( { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this require a change to the post store?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, we already know if it's a feed or a blog. if it's a blog, it has a blog id. otherwise, it's a feed.
if ( props.postKey.isRecommendationBlock ) { | ||
return null; | ||
} | ||
|
||
const post = PostStore.get( props.postKey ); | ||
if ( ! post || post._state === 'minimal' ) { | ||
defer( () => PostStoreActions.fetchPost( props.postKey ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this'll need to be updated to understand the new post key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more new postKey logic
now that refresh is out the door we have an opportunity to simplify our cardpicking process
The idea here is to consolidate all of the card-picking to the post-lifecycle so that you don't need to go searching through multiple cardfactories/adapters depending on which stream you are looking at to figure out which card is getting chosen (there is still one more layer that happens in the post-normalizer, but thats separate)
Changes this introduces:
feed-stream-store
now addsis_recommendation: true
to any post that comes from a recommendation api. I think ideally in the future we can fully separate out the notion of where the data comes from, how to display it, and how to report metrics on it.SearchCardAdapter
, and allCardFactories
from Search/Stream. Which card to choose for search results (or empty recs) now lives fully in post-lifecycle.There is still more to do in later prs e.g.:
create a new component for empty search result recommendationsdoneTo Test: