Skip to content

Batch updates and empty lists #477

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

Closed
wants to merge 7 commits into from
Closed

Conversation

puf
Copy link
Contributor

@puf puf commented Dec 27, 2016

Fixes #458 and #118. Ready for a first review, but don't merge yet.

Copy link

@morganchen12 morganchen12 left a comment

Choose a reason for hiding this comment

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

Approving with one nit, but wait for @samtstern's approval before merging.

Also, question: For batching updates, why provide an onReady to mark the end of database changes but not an equivalent method to indicate the start of database changes?

sendCurrentMessage();
}
});
// Allow hitting the Send keyon the soft keyboard to send the message

Choose a reason for hiding this comment

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

nit: space between 'key' and 'on'

…t it can be moved elsewhere.

Renamed ChatTouchListener to RecyclerSwipeListener.
Encapsulated all callbacks into an interface, that is now implemented by the ChatActivity. This also removed the need for the swipe listener to have access to the adapter.
Correctly reset the ViewHolder subview positions when an item is deleted.
@SUPERCILEX
Copy link
Collaborator

Hey @puf,
I really love this PR, but onReady will be inconsistently called when offline. If a new ref is created offline and subscribed to via a ValueEventListener Query (such as .orderByValue().equalTo(1)), onDataChanged will never be called while offline whereas onChildAdded will. Because of this, I don't think this PR should be merged until that issue is addressed because it could leave users waiting indefinitely for an onReady call that will never come. I've already contacted Firebase support, but since you work on the database, I was hoping you could speed up the fix.

A mcve with plain old ValueEventListener/ChildEventListeners: https://github.com/SUPERCILEX/issue-mcve/blob/46f41526ab047f24241ac548b8ba6dd04b98cc42/app/src/main/java/com/supercilex/myapplication/MainActivity.java#L32
@puf If you would like, I can create a mcve with your PR to show you that onReady will not always be called when offline.

@puf
Copy link
Contributor Author

puf commented Jan 4, 2017

Great find @SUPERCILEX . Agreed on holding off on merging until we figure this one out.

Unfortunately this is part of the behavior of the underlying SDK and not something we can change in FirebaseUI. It is not even something we can fix in the SDK, at least not without reworking a large part of the API surface.

On the lower level we have no knowledge whether the ValueListener is listening for a single document (where we have a hard guarantee that we will never fire with incomplete results) or it is listening on a collection (where incomplete results are acceptable, as long as each individual child is complete).

Can you tell support to ping me on the case?

@SUPERCILEX
Copy link
Collaborator

@puf Yes, I told support to ping you.

@puf That's a real bummer for the internal api, but I still have hope because I've been using a hack to get around this problem in my app. In my mvce, if you ask the ValueEventListener for the parent database instead of the query once while online, that entire ref is cached and queries will work offline. From what you explained above, caching the parent ref guarantees complete results which is why it works.

Here's what I mean:

// 1. While online, add a listener to the root ref:
mRef.addValueEventListener(this);
// 2. Go back to querying and it will work offline and online:
mRef.orderByValue().equalTo(1).addValueEventListener(this);

@puf Couldn't you guys do some sort of cache hack where if a query is executed offline and returns no results, you guys query the parent ref and use a for loop with getChildren to filter the results and return the proper query? If that doesn't work for the native Firebase apis, couldn't we use a similar hack for FirebaseArray?

@puf
Copy link
Contributor Author

puf commented Jan 9, 2017 via email

@SUPERCILEX
Copy link
Collaborator

@puf sounds reasonable so we just wait for you guys to fix it on the SDK side.

@puf
Copy link
Contributor Author

puf commented Jan 9, 2017 via email

@samtstern samtstern modified the milestone: 1.2.0 Jan 10, 2017
@samtstern
Copy link
Contributor

I am going to start doing QA on version 1.1.0 as there are many important fixes in there and it's been longer than expected. I have targeted this PR for 1.2.0 which will be the next minor release.

@samtstern samtstern removed this from the 1.2.0 milestone Feb 21, 2017
@samtstern
Copy link
Contributor

@puf going to close this. Here are the changes in this PR, as I see it:

  • Batch events in the adapters.
  • Soft keyboard and swipe support in the sample app.

We've already implemented the former (with your help) and the latter is really cool but not critical to the library. Since this has been open for many months and is currently not mergeable there's not much to do with it. If you ever get some extra time (unlikely, I know) and want to get the app changes merge-able again then I'm happy to make these changes.

@samtstern samtstern closed this Apr 26, 2017
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.

4 participants