ember-data-change-tracker icon indicating copy to clipboard operation
ember-data-change-tracker copied to clipboard

fix: fallback to localState when canonicalState is not present

Open eyupatis opened this issue 2 years ago • 2 comments

We were using Ember 3.15 in one of our projects and ember-data-change-tracker was working perfectly. When we upgraded our application to Ember 3.28(LTS) version, the addon stopped tracking the changes on belongsTo relationships.

At first, I was guessing the problem could be related to the addon's Ember version. When I upgraded the addon's Ember version to 3.28, it didn't solve the problem.

Then I dig deeper and saw that it was happening because of not having canonicalState attribute on belongsTo relationships. Instead, we have localState and remoteState attributes.

In order to make the fix backward compatible, I kept canonicalState as the first option and if we don't have it, we fall back to localState.

Here are the debugger outputs to explain the situation even better:

Screen Shot 2022-07-30 at 22 32 26 Screen Shot 2022-07-30 at 22 33 04

With this PR, we are making this addon compatible with Ember 3.28 and probably newer versions of Ember.

@danielspaniel Let me know if you see any problems with the PR. I would be happy to address the problems and help further.

eyupatis avatar Jul 30 '22 19:07 eyupatis

Interesting @eyupatis, I have switched to the clojure ecosystem a few years ago, so I have not been involved with ember + change tracker anymore. If I merge this I then have to make new version, etc. Let me ponder

danielspaniel avatar Jul 31 '22 13:07 danielspaniel

I had to do this change too, but as @runspired advised on discord, it seems like using remoteState is the 'right' move. see: https://discord.com/channels/480462759797063690/490216705122107427/970796099432480869 Capture d’écran 2022-10-04 à 10 02 43

sly7-7 avatar Oct 04 '22 08:10 sly7-7