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: load a new recommendation after an interaction with a card #5652

Merged

Conversation

bluefuton
Copy link
Contributor

@bluefuton bluefuton commented May 28, 2016

If a user interacts with a recommendation card, a related recommendation card should be loaded and after immediately after it (where available).

How does it work, then?

When a user clicks anywhere on the card, we attempt to grab up to 3 extra recommendations. If we don't have one, we ask the API for new ones.

If we find any, we insert the recommendations at the end of the existing cards.

Note: clicking cards won't always trigger the loading of new recommendations, for example if they're sibling cards of an existing recommendation, or if we already have the recommended sites in the currently loaded cards.

screen shot 2016-06-10 at 17 32 53

Todo

  • Redux: don't accept duplicate recommendations
  • Write test for insertion order

@bluefuton bluefuton added [Status] In Progress [Feature] Reader The reader site on Calypso. labels May 28, 2016
@bluefuton bluefuton added this to the Reader: Cold Start UI milestone May 28, 2016
@bluefuton bluefuton self-assigned this May 28, 2016
@bluefuton bluefuton force-pushed the add/reader/start-load-new-recommendation-on-card-interaction branch from c77704c to 38064d7 Compare May 28, 2016 17:19
meta: 'site,post',
origin_site_ID: originSiteId,
origin_post_ID: originPostId,
number: limit
Copy link
Contributor

@TooTallNate TooTallNate May 29, 2016

Choose a reason for hiding this comment

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

number doesn't currently do anything in the API endpoint FYI.

The LIMIT in the SQL query is currently hard-coded to 20.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

number= is supported now (thanks for adding @TooTallNate!)

@bluefuton bluefuton force-pushed the add/reader/start-load-new-recommendation-on-card-interaction branch 4 times, most recently from 16fc269 to 12b1541 Compare June 3, 2016 17:19
@bluefuton bluefuton 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 Jun 3, 2016
@bluefuton
Copy link
Contributor Author

Ready for 👀 @blowery @TooTallNate

@jancavan
Copy link
Contributor

jancavan commented Jun 3, 2016

@bluefuton not sure how this happened - a new card got recommended, but it's a card that already exists? (See Momsicle one below):

screenshot 2016-06-03 10 33 58

@bluefuton bluefuton 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 Jun 3, 2016
@bluefuton
Copy link
Contributor Author

bluefuton commented Jun 3, 2016

Glitches we've discovered so far:

  • New recs can appear in the wrong position (before the card interacted with instead of after)
  • New recs can appear in the wrong position because display order does not match HTML source order
  • @jancavan has seen a duplicate card appear, not sure how to reproduce yet
  • Make blavatar, site name, and followers clickable - should open site stream

@jancavan
Copy link
Contributor

jancavan commented Jun 3, 2016

@bluefuton Just posting again here for completeness.

I added a 3rd item on the to-do above. They should just count as interactions since they're more prominent and people are likely to click on them vs the post title.

I'm unable to reproduce the duplicate cards.

@jancavan
Copy link
Contributor

jancavan commented Jun 3, 2016

@bluefuton Would it be possible to use the Discover image as a card header even just for seed posts? Then subsequent cards can just use their site's image as header since we can only grab Discover images for seed posts atm?

It looks pretty plain right now - out of 10 cards, there's only 2 with header images and the rest are gray.

@blowery
Copy link
Contributor

blowery commented Jun 6, 2016

@jancavan @bluefuton wasn't there also a plan to fallback to the canonical image on the featured post if present?

@bluefuton
Copy link
Contributor Author

@jancavan re: "make blavatar, site name, and followers clickable" - clicking any of those already counts as a card interaction and should load a new recommendation.

Do you mean to open the full post view (if we have a post) or site stream when clicking those?

@bluefuton
Copy link
Contributor Author

The duplicate cards are coming from the endpoint. They have different recommendation IDs, so there's not much we can do to dedupe in Calypso - we need to fix this on the backend.

@bluefuton
Copy link
Contributor Author

@jancavan let's have a chat about card ordering :) I think we'll need the card display order to match the HTML source order. At the moment new recs are appearing in the wrong spot.

@bluefuton bluefuton force-pushed the add/reader/start-load-new-recommendation-on-card-interaction branch from d981e5f to abee2bb Compare June 6, 2016 14:17
@jancavan
Copy link
Contributor

jancavan commented Jun 6, 2016

wasn't there also a plan to fallback to the canonical image on the featured post if present?

I thought this was what we were already doing, but cleared this up with @bluefuton.

@TooTallNate Can we use the site header then fallback will be Discover featured image (for seed posts) then featured post image?

Do you mean to open the full post view (if we have a post) or site stream when clicking those?

Blavatar, site name, and followers should jump to the site's stream.

@blowery
Copy link
Contributor

blowery commented Jun 6, 2016

#5564 will expose canonical_image on the post object, which should help.

@jancavan
Copy link
Contributor

jancavan commented Jun 6, 2016

@bluefuton tried different ways to fix the ordering for cards to flow from L to R instead of Top to Bottom, but it's really not possible with plain CSS. Either we:

  1. Figure out how to do it using JS or,
  2. Just append new recs to the bottom of the original set

Let's just go with (2). With the current size of the cards, it's hard to make the connection between the card the you clicked and new cards that show up, especially in smaller viewports.

@bluefuton
Copy link
Contributor Author

bluefuton commented Jun 7, 2016

  • Remove "insert after parent" rec behaviour and add new recs at end of list
  • Retrieve up to 3 new recs after card interaction (currently 1)
  • Retrieve up to 20 new recs when fetching seeds

@bluefuton bluefuton force-pushed the add/reader/start-load-new-recommendation-on-card-interaction branch from f82051c to d463183 Compare June 7, 2016 13:17
@bluefuton
Copy link
Contributor Author

Thanks @jancavan. New recommendations are now appended to the end of the list 👍

@jancavan
Copy link
Contributor

jancavan commented Jun 9, 2016

Card sorting issue has been addressed in: #5944 👏

@bluefuton bluefuton force-pushed the add/reader/start-load-new-recommendation-on-card-interaction branch 2 times, most recently from ace3196 to cb9c1ec Compare June 10, 2016 16:24
@bluefuton bluefuton 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 Jun 10, 2016
@jancavan
Copy link
Contributor

Are we using Discover featured image as fallback yet @bluefuton?

This post has a Discover image, but it's showing the gray background:
screenshot 2016-06-10 11 13 49

@bluefuton
Copy link
Contributor Author

Are we using Discover featured image as fallback yet @bluefuton?

No, we don't have access to it in the API response at the moment. We'll either have to add the discover post to meta or pull it out as header_image in the endpoint when we don't have a site header. One for another PR though.

return Object.assign( {}, state, keyBy( action.recommendations, 'ID' ) );
// Filter out any recommendations we already have
const newRecommendations = filter( action.recommendations, ( incomingRecommendation ) => {
if ( findIndex( state, ( existingRecommendation ) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this can just be return ! find( state, { ID: incomingRecommendation.ID } ) if you use lodash/find?

if you don't like the negative in the boolean you could use lodash/reject instead. reject( state, { ID: incomingRecommendation.ID } )

@bluefuton
Copy link
Contributor Author

bluefuton commented Jun 13, 2016

  • Don't serialize recommendations (just respond with the default state from SERIALIZE, or use new utils/createReducer)

@bluefuton bluefuton added [Status] Needs Author Reply and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jun 13, 2016
- store interacted cards in the Redux tree
- get child recommendation ID for card where available
- only fetch 1 recommendation from API in recordRecommendationInteraction()
- don't accept duplicate recommendations
- add test for recommendation insertion order
@bluefuton bluefuton force-pushed the add/reader/start-load-new-recommendation-on-card-interaction branch from cb9c1ec to 4840cb0 Compare June 13, 2016 16:53
@bluefuton bluefuton force-pushed the add/reader/start-load-new-recommendation-on-card-interaction branch from 4840cb0 to f539fd8 Compare June 13, 2016 16:55
@bluefuton bluefuton added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] Needs Author Reply labels Jun 13, 2016
@blowery
Copy link
Contributor

blowery commented Jun 13, 2016

Looks good! ship away.

@blowery blowery added [Status] Ready to Merge and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Jun 13, 2016
@bluefuton bluefuton merged commit 2e08e6a into master Jun 13, 2016
@bluefuton bluefuton deleted the add/reader/start-load-new-recommendation-on-card-interaction branch June 13, 2016 19:16
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants