diff options
Diffstat (limited to 'src/modules/statuses.js')
| -rw-r--r-- | src/modules/statuses.js | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 5f2f8152..6d4b4843 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -131,7 +131,7 @@ export const statusType = (status) => { return 'favorite' } - if (status.text.match(/deleted notice {{tag/)) { + if (status.text.match(/deleted notice {{tag/) || status.qvitter_delete_notice) { return 'deletion' } @@ -211,8 +211,10 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us sortTimeline(mentions) } - - addNotification({ type: 'mention', status, action: status }) + // Don't add notification for self-mention + if (status.user.id !== user.id) { + addNotification({ type: 'mention', status, action: status }) + } } } @@ -239,6 +241,25 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us // Only add a new notification if we don't have one for the same action if (!find(state.notifications, (oldNotification) => oldNotification.action.id === action.id)) { state.notifications.push({type, status, action, seen: false}) + + if ('Notification' in window && window.Notification.permission === 'granted') { + const title = action.user.name + const result = {} + result.icon = action.user.profile_image_url + result.body = action.text // there's a problem that it doesn't put a space before links tho + + // Shows first attached non-nsfw image, if any. Should add configuration for this somehow... + if (action.attachments.length > 0 && !action.nsfw && + action.attachments[0].mimetype.startsWith('image/')) { + result.image = action.attachments[0].url + } + + let notification = new window.Notification(title, result) + + // Chrome is known for not closing notifications automatically + // according to MDN, anyway. + setTimeout(notification.close.bind(notification), 5000) + } } } |
