Merge pull request #3587 from tgxworld/emoji_not_shown_in_notifications

FIX: Emoji not shown in notifications.
This commit is contained in:
Sam 2015-07-09 11:45:13 +10:00
commit a0740e8976
5 changed files with 16 additions and 13 deletions

View File

@ -53,7 +53,7 @@ export default Ember.Component.extend({
const notification = this.get('notification');
const description = this.get('description');
const username = notification.get('data.display_username');
const text = I18n.t(this.get('scope'), {description, username});
const text = Discourse.Emoji.unescape(I18n.t(this.get('scope'), {description, username}));
const url = this.get('url');
if (url) {

View File

@ -29,6 +29,18 @@ for (var name in aliases) {
});
}
Discourse.Emoji.unescape = function(string) {
if (Discourse.SiteSettings.enable_emoji && string.indexOf(":") >= 0) {
string = string.replace(/:[^\s:]+:?/g, function(m) {
const emoji = Discourse.Emoji.translations[m] ? Discourse.Emoji.translations[m] : m.slice(1, m.length - 1),
url = Discourse.Emoji.urlFor(emoji);
return url ? "<img src='" + url + "' title='" + emoji + "' alt='" + emoji + "' class='emoji'>" : m;
});
}
return string;
}
Discourse.Emoji.urlFor = urlFor = function(code) {
var url, set = Discourse.SiteSettings.emoji_set;

View File

@ -6,17 +6,7 @@ const Topic = RestModel.extend({
errorLoading: false,
fancyTitle: function() {
let title = this.get("fancy_title");
if (Discourse.SiteSettings.enable_emoji && title.indexOf(":") >= 0) {
title = title.replace(/:[^\s:]+:?/g, function(m) {
const emoji = Discourse.Emoji.translations[m] ? Discourse.Emoji.translations[m] : m.slice(1, m.length - 1),
url = Discourse.Emoji.urlFor(emoji);
return url ? "<img src='" + url + "' title='" + emoji + "' alt='" + emoji + "' class='emoji'>" : m;
});
}
return title;
return Discourse.Emoji.unescape(this.get('fancy_title'));
}.property("fancy_title"),
// returns createdAt if there's no bumped date

View File

@ -68,6 +68,7 @@ export default RestModel.extend({
if (result && result.user_actions) {
const copy = Em.A();
result.user_actions.forEach(function(action) {
action.title = Discourse.Emoji.unescape(action.title);
copy.pushObject(Discourse.UserAction.create(action));
});

View File

@ -5,7 +5,7 @@
<span class='time'>{{format-date item.created_at}}</span>
{{topic-status topic=item disableActions=true}}
<span class="title">
<a href="{{unbound item.postUrl}}">{{unbound item.title}}</a>
<a href="{{unbound item.postUrl}}">{{{unbound item.title}}}</a>
</span>
<div class="category">{{category-link item.category}}</div>
</div>