adopted-ember-addons / ember-data-model-fragments

Ember Data addon to support nested JSON documents
MIT License
370 stars 114 forks source link

fix: prevent You attempted to update _tracking on Tag issue on Ember-data 4.5+ #482

Closed VincentMolinie closed 9 months ago

VincentMolinie commented 9 months ago

I realised we had an issue on, that I reproduce pretty easily in my app with Ember-data 4.6. The RecordState is registered when we create a new Model. For a classic native model, the RecordState will be build after all the initial value of the attributes have been set. But with fragments it's the opposite, the RecordState is build first then the attributes are set which result in a duplicate update of the state

This produce the exact same error that you can find on this issue: https://github.com/adopted-ember-addons/ember-data-model-fragments/issues/427

My fix is based on the RecordDataDefault, I saw they are using notifyPropertyChange to notify an attribute has change instead of what we are doing which is using notifyStateChange to say the state of the record has changed

VincentMolinie commented 9 months ago

The PR is not ready yet, I'll check why the CI is not passing

VincentMolinie commented 9 months ago

Okey it should be good now

knownasilya commented 9 months ago

Looks like the change is for 4.5+, but you mentioned 4.6, was that a typo?

VincentMolinie commented 9 months ago

Looks like the change is for 4.5+, but you mentioned 4.6, was that a typo?

Yes correct sorry. Because I thought at first it was just 4.6 but you are right it happens also for 4.5

knownasilya commented 9 months ago

Does this solve #427

VincentMolinie commented 9 months ago

Does this solve #427

I don't think so as it's related to Ember 3.28. But I actually had the issue on 3.28 but before ember-data-model-fragments@6.0.5. So this issue might already be fixed anyway

knownasilya commented 9 months ago

Version released