Skip to content
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

Merged
merged 14 commits into from
Mar 28, 2017

Conversation

samouri
Copy link
Contributor

@samouri samouri commented Feb 27, 2017

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:

  1. feed-stream-store now adds is_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.
  2. delete SearchCardAdapter, and all CardFactories from Search/Stream. Which card to choose for search results (or empty recs) now lives fully in post-lifecycle.
  3. moves the class for EmptySearchRecs from search-stream to its own file. I'm hoping to somehow merge this with our RecBlock class someday

There is still more to do in later prs e.g.:

  1. consolidate our two different recs? if not then at least create a new component for empty search result recommendations done
  2. make the clickHandlers / page calls easier to follow.
  3. generalize fluxPostAdapter to work for all postKeys

To Test:

  • KeyboardShortcuts, especially on a gap
  • tag pages, search page empty recs, all x-posts, placeholders, in-stream-recs, most things

@matticbot
Copy link
Contributor

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Feb 27, 2017
@samouri samouri force-pushed the update/reader/reduxify-routing branch from ce5656d to bb617c8 Compare February 27, 2017 19:45
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Feb 27, 2017
@@ -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,
Copy link
Contributor

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?

Copy link
Contributor Author

@samouri samouri Feb 27, 2017

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 } ) {
Copy link
Contributor Author

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 samouri added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Feb 28, 2017
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Feb 28, 2017
@samouri samouri added [Status] In Progress and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Feb 28, 2017
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Feb 28, 2017
@samouri samouri added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Feature] Reader The reader site on Calypso. [Type] Janitorial and removed [Status] In Progress labels Feb 28, 2017
@matticbot
Copy link
Contributor

@samouri This PR needs a rebase

@matticbot matticbot added [Status] Needs Rebase [Size] XL Probably needs to be broken down into multiple smaller issues labels Mar 2, 2017
@samouri samouri force-pushed the update/reader/reduxify-routing branch from 106dab8 to b0eb67a Compare March 7, 2017 16:25
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 7, 2017
@samouri samouri force-pushed the update/reader/reduxify-routing branch from b0eb67a to 944e235 Compare March 7, 2017 16:52
@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 7, 2017
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 ) {
Copy link
Contributor

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.

Copy link
Contributor

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 => ( {
Copy link
Contributor

@blowery blowery Mar 7, 2017

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?

Copy link
Contributor

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 ) );
Copy link
Contributor

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

Copy link
Contributor Author

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

@mtias mtias changed the title Clean up cardpicking logic Reader: clean up cardpicking logic Mar 9, 2017
@samouri samouri merged commit cd6589a into master Mar 28, 2017
@samouri samouri deleted the update/reader/reduxify-routing branch March 28, 2017 18:57
@blowery
Copy link
Contributor

blowery commented Mar 28, 2017

@matticbot matticbot added the [Size] XL Probably needs to be broken down into multiple smaller issues label Mar 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Reader The reader site on Calypso. [Size] XL Probably needs to be broken down into multiple smaller issues [Type] Janitorial
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants