Skip to content

Fixes #3027 Category search does not work properly [current master] #3034

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

Conversation

ashishkumar468
Copy link
Collaborator

Description (required)
Clear previous categories search result only when the new search results are non-empty

Fixes #3027 Category search does not work properly [current master]

What changes did you make and why?
Clear previous categories search result only when the new search results are non-empty

Tests performed (required)

Tested betaDebug on Pixel Api 27

* Clear previous categories search result only when the new search results are non-empty
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ A review job has been created and sent to the PullRequest network.


Check the status or cancel PullRequest code review here.

@codecov-io
Copy link

Codecov Report

Merging #3034 into 2.11-release will increase coverage by 0.01%.
The diff coverage is 66.66%.

Impacted file tree graph

@@               Coverage Diff               @@
##           2.11-release   #3034      +/-   ##
===============================================
+ Coverage          4.43%   4.45%   +0.01%     
===============================================
  Files               259     259              
  Lines             12261   12264       +3     
  Branches           1051    1051              
===============================================
+ Hits                544     546       +2     
  Misses            11678   11678              
- Partials             39      40       +1
Impacted Files Coverage Δ
...commons/upload/categories/CategoriesPresenter.java 72.58% <66.66%> (-0.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6673725...8a4d0aa. Read the comment docs.

@neslihanturan neslihanturan changed the title Fixes #3027 Fixes #3027 Category search does not work properly [current master] Jun 24, 2019
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

Some questions about what you're doing here. Thanks!


Reviewed with ❤️ by PullRequest

@@ -20,6 +17,9 @@
import javax.inject.Singleton;
import timber.log.Timber;

import static fr.free.nrw.commons.di.CommonsApplicationModule.IO_THREAD;
Copy link

Choose a reason for hiding this comment

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

Do you have a style guideline document, or stylizer tool, for this project? Different projects calls for different import orders.

@@ -61,7 +61,6 @@ class CategoriesPresenterTest {
categoriesPresenter?.searchForCategories("test")
verify(view)?.showProgress(true)
verify(view)?.showError(null)
verify(view)?.setCategories(null)
Copy link

Choose a reason for hiding this comment

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

Why should this test case be removed?

@@ -20,6 +17,9 @@
import javax.inject.Singleton;
import timber.log.Timber;

import static fr.free.nrw.commons.di.CommonsApplicationModule.IO_THREAD;
import static fr.free.nrw.commons.di.CommonsApplicationModule.MAIN_THREAD;
Copy link

Choose a reason for hiding this comment

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

This change as coded seems to be primarily about not clearing search results. But that's not the issue you're citing for the change, so it's unclear to me why you are making this change. And it doesn't seem like this change would fix that issue. Can you explain?

@@ -92,10 +93,14 @@ public void searchForCategories(String query) {
s -> categoryItems.add(s),
Timber::e,
() -> {
view.setCategories(categoryItems);
if (null != categoryItems && categoryItems.size() > 0) {
Copy link

Choose a reason for hiding this comment

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

Can categoryItems be null? (I don't see how it would be.) If so, then the isEmpty check on line 103 will crash. If not, then checking is unnecessary here.

@@ -75,7 +77,6 @@ public void searchForCategories(String query) {
.doOnSubscribe(disposable -> {
view.showProgress(true);
view.showError(null);
view.setCategories(null);
Copy link

Choose a reason for hiding this comment

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

why are you removing this?

@@ -39,6 +39,8 @@

private CompositeDisposable compositeDisposable;

private List<CategoryItem> lastShownCategoryItems=new ArrayList<>();
Copy link

Choose a reason for hiding this comment

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

Are you planning to use the items in this list for anything beyond checking if the list is empty?

If not, then all you need is a boolean, which will also have lower memory impact.

Should this be cleared when the view is attached/detached?

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.

2 participants