From dd27c0c80ed3fb4d66cac2fa45e5c059859a14ab Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Thu, 7 Sep 2017 11:06:04 +0200 Subject: [PATCH] FIX: supports emojis in pinned topic excerpt --- app/assets/javascripts/discourse/models/topic.js.es6 | 4 ++++ .../discourse/templates/list/topic-excerpt.raw.hbs | 2 +- test/javascripts/models/topic-test.js.es6 | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/models/topic.js.es6 b/app/assets/javascripts/discourse/models/topic.js.es6 index f8e75e517f9..c3a8c619954 100644 --- a/app/assets/javascripts/discourse/models/topic.js.es6 +++ b/app/assets/javascripts/discourse/models/topic.js.es6 @@ -407,6 +407,10 @@ const Topic = RestModel.extend({ }); }, + @computed('excerpt') + escapedExcerpt(excerpt) { + return emojiUnescape(excerpt); + }, hasExcerpt: Em.computed.notEmpty('excerpt'), diff --git a/app/assets/javascripts/discourse/templates/list/topic-excerpt.raw.hbs b/app/assets/javascripts/discourse/templates/list/topic-excerpt.raw.hbs index 76be2c412f1..0a42a6a0c56 100644 --- a/app/assets/javascripts/discourse/templates/list/topic-excerpt.raw.hbs +++ b/app/assets/javascripts/discourse/templates/list/topic-excerpt.raw.hbs @@ -1,6 +1,6 @@ {{#if topic.hasExcerpt}}
- {{{topic.excerpt}}} + {{{topic.escapedExcerpt}}} {{#if topic.excerptTruncated}} {{i18n 'read_more'}} {{/if}} diff --git a/test/javascripts/models/topic-test.js.es6 b/test/javascripts/models/topic-test.js.es6 index 8738d2b91b0..fd8c79c7d3f 100644 --- a/test/javascripts/models/topic-test.js.es6 +++ b/test/javascripts/models/topic-test.js.es6 @@ -75,3 +75,11 @@ QUnit.test('fancyTitle', assert => { `smile with all slight_smile the emojis pearpeach`, "supports emojis"); }); + +QUnit.test('excerpt', assert => { + var topic = Topic.create({ excerpt: "This is a test topic :smile:", pinned: true }); + + assert.equal(topic.get('escapedExcerpt'), + `This is a test topic smile`, + "supports emojis"); +});