Wp-calypso: Reader: Discover Page "Follow blog" button broken

Created on 1 May 2018  路  3Comments  路  Source: Automattic/wp-calypso

Steps to reproduce

  1. Starting at URL: https://wordpress.com/discover
  2. Try to click the "follow log X" button from within one of the post-cards. I saw it toggle quickly between green and then back to blue.

I would have expected it to stay green (followed). The post cards seem like they aren't paying attention to followed state.

Reader [Size] M [Type] Bug

Most helpful comment

Anyone working on this? I'd like to tackle it

All 3 comments

Anyone working on this? I'd like to tackle it

I investigated this and the problem seems to be deeper than just a broken button

How it looks like:
londr

Probable cause:

The button determines own state by comparing url coming from the reader's post feed reader/posts/items/[id]/discover_metadata/attribution/blog_url (in Redux state tree) which for this example is "http://www.londnr.com" and the url from the list of sites that user follows in reader/follows/items which for this example is "http://www.londnr.com/feed"

So you may actually follow the site, but the button will be blue and not green because these are two different strings. The short period when it's green is probably due to an optimistic update.

I couldn't find a more reliable value to compare like an id. It seems like there is such an id in follows list, but not in the reader's post feed

Solutions:

  1. A dumb one would be to use regex to match the beginning of the string or strip whatever is after the first /. But it's quite fragile and with my limited knowledge I'm not sure of the consequences
  2. Add a more reliable id to reader feed
  3. Fix this url discrepancy on the API level :thinking:

Thank you for the writeup @alexpyzhianov! It helped point me in the right direction. I have a possible solution in https://github.com/Automattic/wp-calypso/pull/25718.

Was this page helpful?
0 / 5 - 0 ratings