From 28c59d754b00efa2b26521faac6af38989d7eb77 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 7 Apr 2017 15:18:23 -0400 Subject: [PATCH] FIX: Don't update `cooked` when a like is received. --- .../javascripts/discourse/controllers/topic.js.es6 | 6 +++++- .../javascripts/discourse/models/post-stream.js.es6 | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index d5b6852685b..6fe51c4936e 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -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": { diff --git a/app/assets/javascripts/discourse/models/post-stream.js.es6 b/app/assets/javascripts/discourse/models/post-stream.js.es6 index 0e9a5863038..419baf7ccb1 100644 --- a/app/assets/javascripts/discourse/models/post-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/post-stream.js.es6 @@ -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; },