Skip to content
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

Implement Realm.User.push() #2995

Merged
merged 2 commits into from
Jun 30, 2020
Merged

Implement Realm.User.push() #2995

merged 2 commits into from
Jun 30, 2020

Conversation

RedBeard0531
Copy link
Contributor

What, How & Why?

This closes # ???

☑️ ToDos

  • 📝 Changelog entry
  • [ ] 📝 Compatibility label is updated or copied from previous entry
  • 🚦 Tests
  • [ ] 📝 Public documentation PR created or is not necessary
  • [ ] 💥 Breaking label has been applied or is not necessary

If this PR adds or changes public API's:

  • typescript definitions file is updated
  • jsdoc files updated
  • Chrome debug API is updated if API is available on React Native

@RedBeard0531 RedBeard0531 requested a review from kneth June 22, 2020 10:13
@@ -6,6 +6,7 @@ NOTE: This version bumps the Realm file format to version 11. It is not possible

### Enhancements
* Added RemoteMongoClient functionality to `Realm.User`
* Added Push functionality to `Realm.User`
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we can elaborate a bit more what this is (in end user terms). (I can see we also missed to do that with RemoteMongoClient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, I don't actually know what "Push" does in end user terms. This sounds like a good thing to have our Docs team work on so that they can ensure that release notes use consistent terminology with the rest of the documentation.

}

template<typename T>
void UserClass<T>::push_deregister(ContextType ctx, ObjectType this_object, Arguments& args, ReturnValue &return_value) {
Copy link
Contributor

@bmunkholm bmunkholm Jun 22, 2020

Choose a reason for hiding this comment

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

What's the difference to the "register" function above? They look identical.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😬 Yikes! That would be a bug. It is supposed to be calling deregister_device() on like 343.

Copy link
Contributor

Choose a reason for hiding this comment

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

So seems like the tests needs an update as well then ;-)
Isn't it possible to reuse some of that code so it's clear where there is supposed to be a difference :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The API for deregisterDevice changed upsteam in object-store, so I'll add an update to the submodule to this PR so we use the new API realm/realm-object-store@1f3290a#diff-b215f5f5ce1cec59d075f06fbab4510e

Isn't it possible to reuse some of that code so it's clear where there is supposed to be a difference

Probably. I have some ideas on refactors that can clean these repetitive methods up a bit, but so far I've only done the promisify() part on the JS side. I'll probably make a separate PR to clean up the CPP side at some point.

@kraenhansen
Copy link
Member

I don't have a good suggestion on how to resolve this, but since Realm Web does not currently have an implementation of the push service we would have an issue if Realm Web gets released with these types.

In principle we should strive to have feature parity between platforms, but I remember having a discussion with @jsflax about the (lack of) need for this service in Realm Web (since it runs in the more ephemeral browser, than an app installed on the users phone):

  • If we choose to implement the push service for Realm Web, we could hold back this PR and merge the implementation in Realm Web into this branch before it gets merged to v10.
  • If we choose not to implement the push service for Realm Web, we need to ensure this property on the User is properly merged with Merge Realm JS and Realm Web types #2950 such that it will only be exported from Realm JS. And we should probably update the JSdocs to specify that this is not supported in "Realm Web".


auto credentials = realm::app::AppCredentials::function(payload_json);
auto credentials = realm::app::AppCredentials::function(payload_bson.operator const bson::BsonDocument&());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upstream object-store changed the parameter type.

promisify(func) {
return new Promise((resolve, reject) => {
func((...cbargs) => {
if (cbargs.length < 1 || cbargs.length > 2)
Copy link
Contributor

Choose a reason for hiding this comment

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

So only 1 or 2 arguments? Maybe [1, 2].includes(cbargs.length)?

* return promisify(cb => this._floop(how, why, cb));
* }
*/
promisify(func) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice simplification!!

@@ -216,7 +216,7 @@ struct JavaScriptNetworkTransport : public JavaScriptNetworkTransportWrapper<T>
case app::HttpMethod::get: return "GET";
case app::HttpMethod::put: return "PUT";
case app::HttpMethod::post: return "POST";
case app::HttpMethod::del: return "DEL";
case app::HttpMethod::del: return "DELETE";
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, my mistake - sorry.

@RedBeard0531 RedBeard0531 merged commit 893fd6b into v10 Jun 30, 2020
@RedBeard0531 RedBeard0531 deleted the ms/push branch June 30, 2020 10:13
@@ -371,6 +371,10 @@ declare namespace Realm {
linkCredentials(credentials: Credentials): Promise<void>;
callFunction(name: string, args: any[]): Promise<any>;
refreshCustomData(): Promise<Object>;
push(serviceName: string): {
Copy link
Member

Choose a reason for hiding this comment

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

@RedBeard0531 Going over this code when merging it with my changes (kh/v10-merged-types) I realize that we might want to have this serviceName be optional and provide a default name.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants