FIX: Emoji not shown in notifications.
Fixes: https://meta.discourse.org/t/topic-title-emoji-not-supported-in-notifications/30670/2.
This commit is contained in:
parent
0c403272e2
commit
210f1ab424
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
});
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue