DS.Store won't push data into an already existing model


#1

I’ll try to be as concise and as clear as possible. Pardon me in advance for my english :). In my application, I have model. This model is never saved, because the backend doesn’t need it. This model is used for the front-end only, and at one point I receive information from another client doing datachannel (nothing to do with the backend, more like a websocket). But when I try to update the model with the new data received, there are no changes occurring for the model.

This is the function updating the model: onMessageUpdateReceive: function(messageId, uid, content) { var parsedContent = JSON.parse(content.replace(this.get(‘PREFIX_UPDATE’), ‘’)); parsedContent.id = uid; this.get(‘store’).push(this.get(‘store’).normalize(‘attendee’, parsedContent)); },

Digging into the code of Ember and using the debugger, I found out that the problem comes from _changedKeys method in internal-model.js. Specifically, the problem comes from this condition:

    // A value in _attributes means the user has a local change to
    // this attributes. We never override this value when merging
    // updates from the backend so we should not sent a change
    // notification if the server value differs from the original.
    if (this._attributes[key] !== undefined) {
      continue;
    }

So what I understand is that the store doesn’t take care of my updates because it thinks that the model is in a dirty state (i.e. there are local changes not yet saved on the server). But this is actually not a dirty state in my case since I’m not going to save it anyway. So I want the store.push() method to take into account my updates. I thought about doing a fake save function in the model adapter that just do nothing but return a promise with success. But I don’t find it elegant. How would you guys do that ?

Thank you

Clément