Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

firebase_database support for onDisconnect#578

Closed
rmarau wants to merge 0 commit intoflutter:masterfrom
rmarau:master
Closed

firebase_database support for onDisconnect#578
rmarau wants to merge 0 commit intoflutter:masterfrom
rmarau:master

Conversation

@rmarau
Copy link
Copy Markdown

@rmarau rmarau commented May 18, 2018

Adds support for OnDisconnect mimicking Android's api.

FirebaseDatabase.instance.reference().child("path").onDisconnect().set(1).then ...
FirebaseDatabase.instance.reference().child("path").onDisconnect().cancel().then ...
FirebaseDatabase.instance.reference().child("path").onDisconnect().remove().then ...
FirebaseDatabase.instance.reference().child("path").onDisconnect().update().then ...

Tested ok with android and ios.

@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@Hixie
Copy link
Copy Markdown
Contributor

Hixie commented May 29, 2018

cc @collinjackson for review

@rmarau
Copy link
Copy Markdown
Author

rmarau commented Jun 1, 2018

Hi
What's the status on this PR?
Is the CLA a blocking issue? What's the meaning of "but unable to verify author consent". Did I miss anyhting?

I would like to see this upstream. Is there anything I can do?

@Hixie
Copy link
Copy Markdown
Contributor

Hixie commented Jun 1, 2018

@rmarau The cla issue appears to be that two accounts were used to write the commits, @demarcoHome and @rmarau. We need both to say that they are ok with submitting their code in this PR.

The actual PR itself then needs to be reviewed, which can be done by @collinjackson, @kroikie, or @bparrishMines.

Looking at the code quickly myself my first guess would be that we'll need to add tests before it can be submitted.

@rmarau
Copy link
Copy Markdown
Author

rmarau commented Jun 1, 2018

Thanks for the update.

I'm ok with the use of these commits as a contribution to this project (flutter-plugins).

@kroikie kroikie self-assigned this Jun 14, 2018
}];
} else if ([@"OnDisconnect#set" isEqualToString:call.method]) {
[getReference(database, call.arguments) onDisconnectSetValue:call.arguments[@"value"]
andPriority:call.arguments[@"priority"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since priority could not exist here we should check for it and use the appropriate setValue method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

My experience in Obj-C is not that great. Will need help on this.
I applied the same pattern as for DatabaseReference#set where priority is also optional.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see, @rmarau you are correct. In a future PR we should update both this and DatabaseReference#set to check for priority since having null priority removes previously set priorities.

if (priority != null) {
reference
.onDisconnect()
.setValue(value, (double) priority, new DefaultCompletionListener(result));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this can be either a String or a double we should not cast this to double without checking.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Correct.
At some point I tried to take a similar approach as in DataReference.setValue.
Priority argument comes as dynamic from dart and mapped as Object to java.
Now the difference is in the android API: OnDisconnect.setValue holds 3 signatures for the priority argument, being: double, Map and String, whereas DataReference.setValue is more generic and exposes a single signature with Object. Will update to

if (priority instanceof String) {
  reference.onDisconnect()
    .setValue(value, (String) priority, new DefaultCompletionListener(result));
} else if (priority instanceof Double) {
  reference.onDisconnect()
    .setValue(value, (double) priority, new DefaultCompletionListener(result));
} else if (priority instanceof Map) {
  reference.onDisconnect()
    .setValue(value, (Map) priority, new DefaultCompletionListener(result));
}

@kroikie
Copy link
Copy Markdown
Contributor

kroikie commented Jun 14, 2018

@rmarau Could you also add some tests for these new methods?

@rmarau
Copy link
Copy Markdown
Author

rmarau commented Jun 15, 2018

Added tests.
I'm getting this error in the incremental_build.sh analyze

Cannot find a merge base for the current branch to run an incremental build...

Tried to rebase the code and the PR is now a mess.

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

@kroikie
Copy link
Copy Markdown
Contributor

kroikie commented Jun 15, 2018

@rmarau I forced existing changes to new commit. You should be able to continue work on this PR now. Thanks for your help.

@Hixie
Copy link
Copy Markdown
Contributor

Hixie commented Jun 26, 2018

@rmarau Will you have the opportunity to integrate the above review comments? It's totally fine if you don't have time to do this, we'd be happy to (eventually) take care of it. Thanks for your contribution!

@rmarau
Copy link
Copy Markdown
Author

rmarau commented Jun 27, 2018

@Hixie I did integrate the comments. The PR has a single commit because I messed with a master rebase and kroikie helped by cleaning up to a single commit.
What I did from the comments:

  • Implemented the tests
  • checked the priority issue in Android

As for the comment on the IOS implementation, I explained that I dont have the skills/time for that.
I can add now that I partially disagree with the comment. I followed the programming pattern already in the file and adapted for onDisconnect. If there is an issue regarding priority then setValue should also be reviewed. IMHO

You are free to take it from here.
Let me know if I can add submthing on my reach/time.

@kroikie kroikie closed this Jul 9, 2018
@kroikie kroikie mentioned this pull request Jul 9, 2018
@kroikie
Copy link
Copy Markdown
Contributor

kroikie commented Jul 9, 2018

@rmarau closed this PR by mistake, opened another one with your changes. Thanks for you contributions I hope to land them here soon.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants