Page MenuHomePhabricator

Bug: Category overlay does not refresh after category added
Closed, ResolvedPublic3 Estimated Story Points

Description

I noticed a couple of issues while attempting to edit categories using mobile frontend on Android and Apple devices.

Prequisites

Steps:

  1. Navigated to https://en.wikipedia.beta.wmflabs.org/wiki/Dog
  2. Tapped Categories at the bottom of the article
  3. Added the Dog article to the Pets Category
  4. Tapped Save

Problem

After adding the new category, the user does not see it in the list of categories until the user completely closes the categories page and returns back to categories again.

After selecting save there is an odd sequence of screens. Please see the video. Tapping close(x) should return the user to the article.

~~~There is no way to delete the article from a category using Mobile Frontend.~~~ (by design)

Acceptance criteria

  • There is a lag in categories being available with the API. Thus adding a category should close the category overlay and show a toast saying "Category was successfully added to page" to avoid confusing the end user.
  • This behaviour is encapsulated in a test

Developer notes

Refreshing the entire page is probably the best option here.

QA steps

  • On mobile device navigate to https://en.m.wikipedia.beta.wmflabs.org/wiki/Dog (make sure you are in beta mode!)
  • Tap categories at the bottom of the article
  • Add a category ([[Category:Pets]], [[Category:Not_a_cat]], [[Category:Food]])
  • Tap save
  • Verify that you you are told the save was successful

Event Timeline

I wonder if this is related some how to T151041

Jdlrobson renamed this task from Issues Editing Categories on Mobile Frontend to Issues editing Categories on Mobile Frontend.Apr 17 2017, 7:08 PM
Jdlrobson triaged this task as Medium priority.
Jdlrobson moved this task from Incoming to Triaged but Future on the Web-Team-Backlog board.
Jdlrobson renamed this task from Issues editing Categories on Mobile Frontend to Bug: Category overlay does not refresh after category added.Jun 2 2017, 5:18 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson set the point value for this task to 3.Jun 21 2017, 4:51 PM
Jdlrobson updated the task description. (Show Details)
Jdlrobson added a subscriber: LukBukkit.

This came up during T188451. @LukBukkit helpfully explained what's going on here:

The problem is caused by the CategoryGateway. The _loadCategories function is called by the event handler, but the CategoryGateway is saved as a instance variable of the class, so it has been used before.

When the event listener 'category-added' is called, the Gateway's property 'canContinue' is false because of the first call. The first call to the function 'getCategories' happend when the the CategoryOverlay was loaded at the start.

It's it possible to rerender the full template instead of creating a hacky reload solution?

And there are also problem with the browser history.

Change 478214 had a related patch set uploaded (by LukBukkit; owner: LukBukkit):
[mediawiki/extensions/MobileFrontend@master] Reloads the categories overlay after a category was added

https://gerrit.wikimedia.org/r/478214

I've created a solution which reloads the category list after a addition from the server.

The problem: The list of categories which the the API returns is not immediately updated. This results in a outdated overlay although we refresh it after an addition.

This problem is related to job queues. It depends how fast they can process the update.
That's the reason why I've increased the delay to the refresh to 7,5s.

There is a fix for this (and tests) in https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/MobileFrontend/+/460986/ but it comes with too many other changes. It's possible that useful changes may be teased out.

Change 480998 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Show notification after updating categories

https://gerrit.wikimedia.org/r/480998

Change 478214 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Close the categories overlay after a category is added

https://gerrit.wikimedia.org/r/478214

Change 480998 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Show notification after updating categories

https://gerrit.wikimedia.org/r/480998