Skip to content

Commit

Permalink
add unescape function without jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
ykzts committed Apr 29, 2017
1 parent 7d6d918 commit a373e0f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/assets/javascripts/components/actions/notifications.jsx
Expand Up @@ -25,6 +25,12 @@ const fetchRelatedRelationships = (dispatch, notifications) => {
}
};

const unescapeHTML = (html) => {
const wrapper = document.createElement('p');
wrapper.innerHTML = html;
return wrapper.textContent;
}

export function updateNotifications(notification, intlMessages, intlLocale) {
return (dispatch, getState) => {
const showAlert = getState().getIn(['settings', 'notifications', 'alerts', notification.type], true);
Expand All @@ -43,7 +49,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) {
// Desktop notifications
if (typeof window.Notification !== 'undefined' && showAlert) {
const title = new IntlMessageFormat(intlMessages[`notification.${notification.type}`], intlLocale).format({ name: notification.account.display_name.length > 0 ? notification.account.display_name : notification.account.username });
const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : $('<p>').html(notification.status ? notification.status.content : '').text();
const body = (notification.status && notification.status.spoiler_text.length > 0) ? notification.status.spoiler_text : notification.status ? unescapeHTML(notification.status.content) : '';

new Notification(title, { body, icon: notification.account.avatar, tag: notification.id });
}
Expand Down

0 comments on commit a373e0f

Please sign in to comment.