diff --git a/app/assets/javascripts/discourse/app/models/post.js b/app/assets/javascripts/discourse/app/models/post.js index 69cdd292f9b..d6264dac0ba 100644 --- a/app/assets/javascripts/discourse/app/models/post.js +++ b/app/assets/javascripts/discourse/app/models/post.js @@ -63,7 +63,7 @@ function trackedPostProperty(target, propertyKey, descriptor) { export default class Post extends RestModel { static munge(json) { - json.likeAction = null; + json.likeAction ??= null; if (json.actions_summary) { const lookup = EmberObject.create(); diff --git a/app/assets/javascripts/discourse/tests/unit/models/post-test.js b/app/assets/javascripts/discourse/tests/unit/models/post-test.js index dc30ffca4a8..0a44de6e418 100644 --- a/app/assets/javascripts/discourse/tests/unit/models/post-test.js +++ b/app/assets/javascripts/discourse/tests/unit/models/post-test.js @@ -43,6 +43,12 @@ module("Unit | Model | post", function (hooks) { likeAction: null, // `likeAction` is a tracked property from the model added using `@trackedPostProperty` }); + // asserts that Object.keys(post) does not contain "likeAction" + assert.false( + Object.keys(post).includes("likeAction"), + "Object.keys does not enumerate `likeAction`" + ); + post.updateFromPost( this.store.createRecord("post", { raw: "different raw", @@ -131,6 +137,6 @@ module("Unit | Model | post", function (hooks) { id: 1173, }); - assert.ok(post.likeAction === null, "likeAction was reset to null"); + assert.strictEqual(post.likeAction, null, "likeAction was reset to null"); }); });