WordPress-iOS icon indicating copy to clipboard operation
WordPress-iOS copied to clipboard

Bug: Stats Widget does not load when a new site appears after refreshing "My Site" tab

Open staskus opened this issue 2 years ago • 6 comments

Expected behavior

Stats Widget should load when a new site appears after refreshing "My Site" tab.

Actual behavior

Stats Widget stays in the error state when a new site appears after refreshing "My Site" tab. Removing and readding Stats Widget does not help.

Steps to reproduce the behavior

  1. Create WordPress account without any site
  2. Log In into the app
  3. Add WordPress "Stats Widget" (All Time / This Week / Today) on the home screen
  4. Go to WordPress.com website and create a new site
  5. Return to the app
  6. Open "My Site" tab
  7. Pull to Refresh
  8. New site information loads
  9. Got to Home screen
  10. Notice Stats widget not reloading

The Stats Widget doesn't even reload after:

  • Removing and readding Stats Widget
  • Visiting Stats view in the app
Tested on iPhone 13 mini, iOS 15.4, WPiOS 20.2

Workaround

Log out and log in again in the app with the same account.

Video

https://user-images.githubusercontent.com/4062343/174753506-5c1adecd-a6b3-40d8-9781-085cf2b2566b.mov

Technical Details

Pull to Refresh triggers syncBlogs() in MySiteViewController. When updateDefaultBlogIfNeeded in AccountService is called, account.primaryBlogID does not exist yet. Therefore Default Site ID is not saved to userDefaults in the process with WPStatsHomeWidgetsUserDefaultsSiteIdKey. Stats Widget relies on Default Site ID value. There could possibly be more values that are set during login but are not set during this pull to refresh action, this is the main concern.

Check updateBlogWithRemoteBlog in BlogService. There's already a detection of a new blog. It might make sense to throw siteCreated notification there.

staskus avatar Jun 21 '22 08:06 staskus

Hi @staskus, the video above seems to be broken for me, is it working for you?

Screen Shot 2022-06-24 at 12 21 29

guarani avatar Jun 24 '22 16:06 guarani

After posting the above comment, the video above started displaying correctly 🤷. So please ignore the above comment.

guarani avatar Jun 24 '22 16:06 guarani

Note: Consider the opposite case.

  1. In the app log in to account that has a site
  2. Add a widget
  3. Remove a site on the site
  4. Return to the app
  5. Pull to refresh the site tab

Expected result:

"No site" view is shown Stats widget show "No site" state

Actual result:

Nothing changes in the app, the deleted site is still shown.

Workaround:

Click on the site dropdown. Then the view refreshes and "No site" state is shown on "My site" tab

staskus avatar Jun 30 '22 10:06 staskus

Hi @staskus, your above description sounds like a bug, primarily affecting the app (not the widget), where pull-to-refresh on the My Site screen doesn't remove the site when the site is deleted. It looks like this should be a separate issue, would you agree?

guarani avatar Jun 30 '22 17:06 guarani

Hi @staskus, your above description sounds like a bug, primarily affecting the app (not the widget), where pull-to-refresh on the My Site screen doesn't remove the site when the site is deleted. It looks like this should be a separate issue, would you agree?

Hey, @guarani, yes I agree. I'll create a separate issue.

staskus avatar Jul 04 '22 06:07 staskus

Fails
:no_entry_sign: Please add a feature label to this issue. e.g. 'Stats'

Generated by :no_entry_sign: dangerJS