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: Update action button link of an empty list of a user profile #98706

Merged

Conversation

mehmoodak
Copy link
Member

@mehmoodak mehmoodak commented Jan 21, 2025

Related to https://github.com/Automattic/loop/issues/351

Proposed Changes

The issue was that on an empty list page, the "Back to Following" button with link /read was being displayed even when navigating from a user profile. This PR fixes this by updating the implementation to display a "Back to User Profile" button with link /read/users/:id/lists instead, allowing users to easily navigate back to the user profile.

Other than this I have also refactored ListEmptyContent to functional component so for easier review each commit can be reviewed separately.

Before After
image image

Why are these changes being made?

To improve the navigation.

Testing Instructions

  • Go to /read/list/artemiosans/a-third-list.
  • Verify action button is showing "Back to Following" text with link /read.
  • Go to the Lists tab of any user profile (example: /read/users/218803706/lists.
  • Click on a list that have no posts yet (example: A Third List).
  • Verify action button is showing "Back to User Profile" text with link /read/users/:id/lists.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
    • For UI changes, have we tested the change in various languages (for example, ES, PT, FR, or DE)? The length of text and words vary significantly between languages.
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

@mehmoodak mehmoodak self-assigned this Jan 21, 2025
@matticbot
Copy link
Contributor

matticbot commented Jan 21, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Async-loaded Components (~66 bytes added 📈 [gzipped])

name                                   parsed_size           gzip_size
async-load-calypso-reader-list-stream       -215 B  (-1.4%)      +66 B  (+1.4%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@matticbot
Copy link
Contributor

matticbot commented Jan 21, 2025

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • blaze-dashboard
  • notifications
  • odyssey-stats
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug loop-351/update-action-link-on-empty-user-profile-list on your sandbox.

@mehmoodak mehmoodak force-pushed the loop-351/update-action-link-on-empty-user-profile-list branch from bdd3e9a to ac8eff3 Compare January 21, 2025 18:50
@mehmoodak mehmoodak marked this pull request as ready for review January 21, 2025 19:06
@mehmoodak mehmoodak requested a review from a team as a code owner January 21, 2025 19:06
@matticbot matticbot added the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 21, 2025
Copy link
Member

@DustyReagan DustyReagan left a comment

Choose a reason for hiding this comment

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

This part doesn't seem to be working for me on Calypso Live. I'm still seeing "Back to Follow" with a link to /read.

  • Go to the Lists tab of any user profile (example: /read/users/218803706/lists.
  • Click on a list that have no posts yet (example: A Third List).
  • Verify action button is showing "Back to User Profile" text with link /read/users/:id/lists.

Could we always link to the list owner's "Lists" page now? Is there any reason we should link to /read now that we have a user profile page?

@mehmoodak
Copy link
Member Author

This part doesn't seem to be working for me on Calypso Live.

It is fixed now.

Could we always link to the list owner's "Lists" page now? Is there any reason we should link to /read now that we have a user profile page

If I navigate to the list from User Profile then its better to show /users/:id/lists link and if I navigate from sidebar then its better to show /read link.

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

I can see the button content updating and the href changing, but it loads into a wsod for me currently.

Repro:

  • visited /read/users/218803706/lists
  • clicked on "A third list" and let the empty list load. (URL on third list /read/list/artemiosans/a-third-list?last_page=/read/users/218803706/lists)
  • clicked on "Back to user profile". This is a WSOD as it loads /read/list/artemiosans/%2Fread%2Fusers%2F218803706%2Flists instead of /read/users/218803706/lists

Note - the above is on calypso live. When running the branch locally im seeing the query param added to the url, but the button content and href not changing (continues to go to following). 😕

Are you seeing either of these issues?

client/reader/list-stream/empty.tsx Outdated Show resolved Hide resolved
client/reader/list-stream/empty.tsx Outdated Show resolved Hide resolved
@mehmoodak mehmoodak force-pushed the loop-351/update-action-link-on-empty-user-profile-list branch from ec3f72a to 1249bb2 Compare January 22, 2025 19:04
@mehmoodak
Copy link
Member Author

mehmoodak commented Jan 22, 2025

I can see the button content updating and the href changing, but it loads into a wsod for me currently.

This should be fixed now (1249bb2).

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

Confirming this works as expected on calypso.live now.

Also left some more thoughts on the events and removing the param.

client/reader/list-stream/empty.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

This part doesn't seem to be working for me on Calypso Live.

Note - the above is on calypso live. When running the branch locally im seeing the query param added to the url, but the button content and href not changing (continues to go to following). 😕

I was finding more inconsistent issues across calypso live and local just now, I think we might have a race condition. (edit - or not, another issue i noted in a more recent comment below). Essentially, the react app can start loading that route and component before the window href is updated. So this component can start loading before last_page is present in window.location.search. That could be why we sometimes see the "following" button when we wouldn't expect and param still in the window. We may need to look at route data in the app instead.

Secondary to this, another issue il note in comment.

client/reader/list-stream/empty.tsx Outdated Show resolved Hide resolved
@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Jan 23, 2025

Ok, lets take a step back from my race condition comment etc for now... i have seen similar before but that may not be the problem here.

What I am seeing @mehmoodak, is that sometimes when clicking to view an empty list (even the same empty list from your profile) different components may render:

So when it loads the <ListMissing> component instead for whatever reason, the param stays in the url and button remains to point to follow. 😵 So I think the main inconsistency we have been seeing is related to which of those components gets rendered.

(edit: i wonder if #98766 may help resolve that inconsistency, but I imagine we may want to share this handling in both of the components to be thorough regardless).

@mehmoodak
Copy link
Member Author

What I am seeing @mehmoodak, is that sometimes when clicking to view an empty list (even the same empty list from your profile) different components may render:

I have also noticed two components get rendered for different conditions.

  1. ListMissing when list is not found
  2. ListEmptyContent when there are no posts in list

While navigating to lists from User Profile we are sure that the list is already present and that's why I only changes ListEmptyContent

i wonder if #98766 may help resolve that inconsistency, but I imagine we may want to share this handling in both of the components to be thorough regardless

I also had same thoughts but still the main reason of not making changes is because we are sure that the list is already there.

client/reader/list-stream/empty.tsx Fixed Show resolved Hide resolved
@Addison-Stavlo
Copy link
Contributor

navigating to lists from User Profile we are sure that the list is already present

We should be, but my testing (and Dusty's further above) both seem to show inconsistency with this. In testing this PR, going from the user profile into a list has shown both/either component for me at times... which has been the confusion around the inconsistency of this change working or not.

I assuming and hoping that other PR resolves this though, so maybe a rebase may make everything test consistent now.

@mehmoodak
Copy link
Member Author

maybe a rebase may make everything test consistent now.

Done. Please have a look again.

Copy link
Member

@DustyReagan DustyReagan left a comment

Choose a reason for hiding this comment

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

It's working consistently for me!

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

This tests much more consistently for me now! 🎉 Thanks for working on this.

For non-empty lists, navigating from a users profile lists page into a non-empty list we leave the query arg around in the window url as we use that stream and view posts back and forth:

param-in-url

We should probably remove it there as well, although happy to move that into a followup if preferred or help if needed. It would just be good to get done before we flag everything for production.

client/reader/user-profile/views/lists.tsx Outdated Show resolved Hide resolved
@Addison-Stavlo
Copy link
Contributor

Addison-Stavlo commented Jan 24, 2025

It looks like we could actually just use getPreviousRoute selector instead of the query param altogether, that could simplify this a bit.

related slack discussion - p1737737583590569/1737735616.726339-slack-C083J8DHLLD

@mehmoodak
Copy link
Member Author

It looks like we could actually just use getPreviousRoute selector instead of the query param altogether, that could simplify this a bit.

  • 5dab2ae - Replaced last_page query param with getPreviousRoute selector.
  • b223ca4 - Use this opportunity to refactor getPreviousRoute to TypeScript.

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

I like it being much more simple now. 😄 I think we have to make some minor adjustments though.

Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

This tests well for me now! And quite a simplicity from where we were before, Looks good!

@mehmoodak mehmoodak merged commit 00535d3 into trunk Jan 24, 2025
13 checks passed
@mehmoodak mehmoodak deleted the loop-351/update-action-link-on-empty-user-profile-list branch January 24, 2025 18:55
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 24, 2025
@a8ci18n
Copy link

a8ci18n commented Jan 24, 2025

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/17208885

Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday.

Thank you @mehmoodak for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Jan 26, 2025

Translation for this Pull Request has now been finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants