Skip to content

Conversation

@apicellaj
Copy link
Contributor

Proposed fix for issue #1698 (also affects selecting "Photos" from Navigation Drawer)

@AndyScherzinger
Copy link
Member

@mario can you test this please? I would but for some reason favorites (only have 1 file) loads forever (only displaying "loading...")...

also cc @tobiasKaminsky

@tobiasKaminsky
Copy link
Member

I tested it successfully 👍, but I am unsure regarding the impact of directly executing instead of using the pool.
@mario what do you think?

@mario
Copy link
Contributor

mario commented Oct 26, 2017

It used to be this way. It didn't work. Then we changed it. Then it worked. Now it doesn't work again xD

Will check...

@mario mario self-assigned this Oct 26, 2017
@mario
Copy link
Contributor

mario commented Oct 26, 2017

So both ways work for me. However, the real issue seems to be this:

10-25 18:26:55.025 5964-6013/com.nextcloud.client D/OwnCloudClient #1: REQUEST SEARCH /server/remote.php/dav
10-25 18:26:56.788 5964-6013/com.nextcloud.client D/OwnCloudClient #1: REQUEST SEARCH /server/remote.php/dav

Search is issued twice no matter the executor...

@mario
Copy link
Contributor

mario commented Oct 26, 2017

@AndyScherzinger
Copy link
Member

Now also related to #1732 but I can't test it :( since Fav/Photos don't work for me and I don't have the time to investigate atm. 😢

@alexanderdd
Copy link

Came here because of the photos showing up twice. Curious as to how this story continues :+)

@tobiasKaminsky
Copy link
Member

10-25 18:26:55.025 5964-6013/com.nextcloud.client D/OwnCloudClient #1: REQUEST SEARCH /server/remote.php/dav
10-25 18:26:56.788 5964-6013/com.nextcloud.client D/OwnCloudClient #1: REQUEST SEARCH /server/remote.php/dav

Search is issued twice no matter the executor...

With latest app master and latest server master I cannot reproduce this: I only see one "request search" and only one search execuction:

remoteOperation = new SearchOperation(event.getSearchQuery(), event.getSearchType());

What kind of environment did you used?

@ChrisDeath
Copy link

Btw. for me its only shown twice the first time i enter Favorites. Refreshing then there (pulling down the list) removes the duplicates...maybe it helps for testing.

@AndyScherzinger
Copy link
Member

@tobiasKaminsky @mario I found the cause for the double search inside of OCFileListFragment...

@Override
    public void onActivityCreated(Bundle savedInstanceState) {
        ...
        if (searchEvent != null && savedInstanceState == null) {
            onMessageEvent(searchEvent);
        }
        ...
    }

and

@Override
    public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
        ...
        if (searchEvent != null) {
            onMessageEvent(searchEvent);
        }
        ...
    }

So whenever you click on Favorites in the drawer the onActivityCreated gets called and right after onViewStateRestored gets called, both then triggering the search.

So we either:

  • need to know in which of the two cases this should actually happen and remove the other event
  • have a nasty quick fix by checking the list within the adapter...see OCFileListAdapter
private void parseVirtuals(ArrayList<Object> objects, ExtendedListFragment.SearchType searchType) {
        ...
        for (int i = 0; i < objects.size(); i++) {
            ...

                if (!onlyImages || MimeTypeUtil.isImage(ocFile)) {
                    mFiles.add(ocFile);
                }
               ...

where we replace it by:
if (!mFiles.contains(ocFile) && !onlyImages || MimeTypeUtil.isImage(ocFile))) {

I think i'd be nice if we fix the double calling since the other solution just throughs away the second result since all the elements will already be in the list the second time...

@tobiasKaminsky
Copy link
Member

Closing this in favor of #2490, thanks to @AndyScherzinger :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants