this.modelFor('master.feed').get('feedTracks').removeObject(feedTrack);
this.store.findRecord('feed-track', feedTrack.id).then((ft) =>{
ft.deleteRecord();
});
feedTrack.share().then((response) => {
if (response != null) {
var normalizedResponse = this.store.normalize('feed-track', response);
this.store.push(normalizedResponse);
});
The code above works as planned at first. The feedTrack record is removed from the array in the model. And the API returns a new object which is then pushed to the store.
But when the push occurs, the old feedTrack record that I had deleted, gets repopulated back into the association array.
It’s as if the delete()
call never actually did anything and when the model detects a change, it reloads it.
Is this a bug or am I doing something wrong?