smooth-app icon indicating copy to clipboard operation
smooth-app copied to clipboard

Product search shows no results after swipe-refresh

Open WildOrangutan opened this issue 1 year ago • 2 comments

What

On search product screen, swipe-refresh shows no results, when results are found.

Steps to reproduce the behavior

  1. Search a product -> shows list of products
  2. Swipe-refresh -> shows no results

untitled.webm

Smartphone model

  • Device: Emulator
  • OS: API 29
  • App Version: SHA 0400c18

WildOrangutan avatar Oct 01 '22 16:10 WildOrangutan

I also noticed this today, but this doesn't happen all the time, we need a way to consistently reproduce this

M123-dev avatar Oct 04 '22 19:10 M123-dev

Seems like it depends on how many search results are there. If count is small (5 results), I can reproduce it every time. For large count (15 results), refreshing takes longer and I'm not able to reproduce it.

WildOrangutan avatar Oct 04 '22 20:10 WildOrangutan

Looked into this issue, In product_query_page.dart at line 430

 setState(
      // How do we refresh a supplier that has no refresher? With itself.
      () => _model = _getModel(refreshSupplier ?? widget.productListSupplier),
    );

Here the, _model is reassigned, and due to this the listeners on previous Object get overriden by new Object (thus not called ? ).

So widget isn't updated with new data.

I tried calling _asyncLoading externally on existing _model

_model.asyncLoad(notify: true)

And wrapping _getNotEmptyScreen in Consumer widget. This solved the issue.

I had some doubts though regarding _getRefreshAction and refreshList methods. Why are there 2 refresh option? pull to refresh and from action bar?

anshpathania7 avatar Nov 04 '22 18:11 anshpathania7

@anshpathania7 You're right there's something fishy with _getRefreshAction and refreshList methods. If I remember well they should do the same thing (refresh the data from the server) and therefore should call the same code (and that is not the case currently).

monsieurtanuki avatar Nov 05 '22 12:11 monsieurtanuki

@monsieurtanuki yeah instead of two methods, a common single method should be used and is there a need of pull to refresh ? Providing same functionality in two different places seems bit confusing in terms of UX.

anshpathania7 avatar Nov 05 '22 14:11 anshpathania7

We should rather remove the button, pull to refresh is very common throughout the app

M123-dev avatar Nov 05 '22 15:11 M123-dev

We should rather remove the button, pull to refresh is very common throughout the app

@M123-dev Agreed. @anshpathania7 If you're able to reproduce the issue, please try with the button and with the pull-to-refresh. Hopefully one of the code works :)

monsieurtanuki avatar Nov 05 '22 15:11 monsieurtanuki

@monsieurtanuki @M123-dev Both methods are working, pull to refresh doesn't works for smaller list sometimes(because Future is completing after setState). Both refresh methods are different, which one to keep?

Refresh from button, Shows a downloading dialog.

Is this to be moved topull_to_refresh ?

anshpathania7 avatar Nov 05 '22 15:11 anshpathania7

Both methods are working, pull to refresh doesn't works for smaller list sometimes

Then it's not working. Is the other method always working? I understand that the download dialog may be a UX problem, but if the code does work we can make it work while removing the dialog, can't we?

monsieurtanuki avatar Nov 05 '22 17:11 monsieurtanuki

@monsieurtanuki Yes, Other one is working perfectly, it shows downloading dialog while it's loading data, after successfully refreshing dialog disappears.

anshpathania7 avatar Nov 05 '22 17:11 anshpathania7

@anshpathania7 Cool! So in a first approach, the fix would be to:

  1. get rid of the top refresh button - we want only one refresh now
  2. have the pull-to-refresh call the code that works

I don't have access to the app, so I don't see how the pull-to-refresh behaves during refreshing. If we don't display dialog usually, a second step would be not to use the dialog here.

Ready to code, @anshpathania7?

monsieurtanuki avatar Nov 05 '22 17:11 monsieurtanuki

@monsieurtanuki shouldn't we show some sort of indicator to show if data is being loaded/refreshed or has been loaded successfully?

anshpathania7 avatar Nov 05 '22 18:11 anshpathania7

Again, I don't have access to the app. Do something similar to the other pages. But first, fix the refresh bug. Later, you may deal - or not - with the dialog.

monsieurtanuki avatar Nov 05 '22 18:11 monsieurtanuki

@anshpathania7

monsieurtanuki shouldn't we show some sort of indicator to show if data is being loaded/refreshed or has been loaded successfully?

Not fact checked but we should keep the refresh indicator spinning as long as the query is running. This should be the default behavior of the RefreshInficator

Running until the refresh method returned

M123-dev avatar Nov 05 '22 20:11 M123-dev

Alright, I'm working on it right now. Can you assign this to me?

anshpathania7 avatar Nov 06 '22 15:11 anshpathania7