FIX: Don't update `cooked` when a like is received.

This commit is contained in:
Robin Ward 2017-04-07 15:18:23 -04:00
parent 616e1dcd16
commit 28c59d754b
2 changed files with 15 additions and 3 deletions

View File

@ -891,7 +891,11 @@ export default Ember.Controller.extend(SelectedPostsCount, BufferedContent, {
switch (data.type) {
case "acted":
postStream.triggerChangedPost(data.id, data.updated_at).then(() => refresh({ id: data.id, refreshLikes: true }));
postStream.triggerChangedPost(
data.id,
data.updated_at,
{ preserveCooked: true }
).then(() => refresh({ id: data.id, refreshLikes: true }));
break;
case "revised":
case "rebaked": {

View File

@ -544,7 +544,9 @@ export default RestModel.extend({
return Ember.RSVP.Promise.resolve();
},
triggerChangedPost(postId, updatedAt) {
triggerChangedPost(postId, updatedAt, opts) {
opts = opts || {};
const resolved = Ember.RSVP.Promise.resolve();
if (!postId) { return resolved; }
@ -552,7 +554,13 @@ export default RestModel.extend({
if (existing && existing.updated_at !== updatedAt) {
const url = "/posts/" + postId;
const store = this.store;
return ajax(url).then(p => this.storePost(store.createRecord('post', p)));
return ajax(url).then(p => {
if (opts.preserveCooked) {
p.cooked = existing.get('cooked');
}
this.storePost(store.createRecord('post', p));
});
}
return resolved;
},