mardi 31 janvier 2017

Pushing object to store causes model to reload with previously removed objects

I have a feed object that hasMany feed tracks. The template loops through those feed tracks and displays their associated track.


  


When a user decides to like a track, that feed track is removed from the array and another is added from the server response:

shareFeedTrack(feedTrack) {
  this.modelFor('master.feed').get('feedTracks').removeObject(feedTrack);
  feedTrack.share().then((response) => {
    if (response != null) {
      var normalizedResponse = this.store.normalize('feed-track', response);
      this.store.push(normalizedResponse);
    }
  }.bind(this));
}

But when the push occurs, the template displays the previously removed track at the top again, as if the model reloaded and didn't register that the top item had been removed.

I've tried to delete the record and save, but again, after pushing the new object, the feed still shows an empty template for the record that had been removed, as if the object still existed in the relations array.




Aucun commentaire:

Enregistrer un commentaire