smooth-app
smooth-app copied to clipboard
Product search shows no results after swipe-refresh
What
On search product screen, swipe-refresh shows no results, when results are found.
Steps to reproduce the behavior
- Search a product -> shows list of products
- Swipe-refresh -> shows no results
Smartphone model
- Device: Emulator
- OS: API 29
- App Version: SHA 0400c18
I also noticed this today, but this doesn't happen all the time, we need a way to consistently reproduce this
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.
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 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
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.
We should rather remove the button, pull to refresh is very common throughout the app
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 @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
?
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 Yes, Other one is working perfectly, it shows downloading dialog
while it's loading data, after successfully refreshing dialog disappears.
@anshpathania7 Cool! So in a first approach, the fix would be to:
- get rid of the top refresh button - we want only one refresh now
- 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 shouldn't we show some sort of indicator to show if data is being loaded/refreshed or has been loaded successfully?
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.
@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
Alright, I'm working on it right now. Can you assign this to me?