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

Store push / findRecord causes model to reload previously destroyed record #4786

Closed
locks opened this issue Feb 1, 2017 · 4 comments
Closed

Comments

@locks
Copy link
Contributor

locks commented Feb 1, 2017

Original: emberjs/ember.js#14895

This is a bit complex to describe with out showing, but I do believe it is a bug.

I have a model, feed, which hasMany feedTracks.

When a user takes a certain action, the top object in the feedTracks array is removed. But then, when I go to insert a new object into that array, the old object that was just removed, reappears.

    skipFeedTrack(feedTrack) {
      feedTrack.skip().then((response) => {
        feedTrack.destroyRecord().then(() => {
          this.modelFor('master.feed').get('feedTracks').removeObject(feedTrack);
        });
        if (response != null) {
          this.store.pushPayload({feedTrack: response});
        }
      }.bind(this));
    }

The feedTrack is successfully removed from the feedTracks array (which is a hasMany relationship to the feed). But then, when this.store.pushPayload({feedTrack: response}); or any variation of that (i.e. findRecord, or push) is called, the feedTrack that was just removed reappears on the template at the top.

I believe this is a bug as, when you call destroy() on a record, it should effectively remove it from the cache.

Ultimately at the end of the day, all I want to do is remove one record/object from the hasMany association and insert another which is given from the server response to the call to skip().

— @gregattra

@runspired
Copy link
Contributor

Fixed by #4791 and #4792 with a failing test committed by #4790

@bmac
Copy link
Member

bmac commented Feb 3, 2017

This is fixed by #4791 and the fix was published in the Ember Data 2.11.1 release. I'm going to close this issue now but please let me know if you are still experiencing a problem.

@bmac bmac closed this as completed Feb 3, 2017
@gbattra
Copy link

gbattra commented Feb 4, 2017

Fix resolved this issue for me. Thank you for getting this out quickly.

@joshsmith
Copy link

🙌

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

No branches or pull requests

5 participants