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

#3015 fix insurance policy outgoing sync formatting #3030

Merged

Conversation

wlthomson
Copy link
Contributor

Fixes #3015.

Change summary

Fixes formatting of policy numbers synced from mobile to desktop.

Testing

Steps to reproduce or otherwise test the changes of this PR:

  • Policies with personal numbers are correctly formatted after being synced from mobile to desktop (familyNumber-personalNumber).
  • Policies without personal numbers are correctly formatted after being synced from mobile to desktop (familyNumber).

Related areas to think about

N/A.

Copy link
Contributor

@josh-griffin josh-griffin left a comment

Choose a reason for hiding this comment

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

im confused a little bit soz!

@@ -2,7 +2,8 @@ import Realm from 'realm';

export class InsurancePolicy extends Realm.Object {
get policyNumber() {
return `${this.policyNumberPerson} ${this.policyNumberFamily}`;
if (!this.policyNumberPerson) return this.policyNumberFamily;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I believe that just means it can't be set to null or undefined? As it's a primitive I think it makes more sense to have it initialised to a falsey but non-null value?

To make it more explicit can do:

policyNumberPerson: { type: 'string', default: '' };

but I think the above is equivalent to the existing declaration?

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know so I did a quick test with:

UIDatabase.write(() => {
      const insuranceProvider = UIDatabase.update('InsuranceProvider', {
        id: '1',
      });

      UIDatabase.update('InsurancePolicy', { id: '1', insuranceProvider });
    });

And got the error "Missing value for property InsurancePolicy.policyNumberFamily" - so I believe you need to explicitly set the default. Also doesn't say anything in the docs about defaults being set for primitives automatically: https://realm.io/docs/javascript/latest/#default-property-values

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, looks like I misinterpreted the examples in the docs (I guess that includes implicitly on construction).

eeb4b8c.

Copy link
Contributor

@josh-griffin josh-griffin left a comment

Choose a reason for hiding this comment

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

lgtm-elmo

@wlthomson wlthomson merged commit d29cdb2 into release/v5.1.2 Jul 21, 2020
@wlthomson wlthomson deleted the #3015-fix-insurance-policy-outgoing-sync-formatting branch July 21, 2020 01:47
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