diff options
| author | Henry Jameson <me@hjkos.com> | 2017-08-30 00:25:27 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2017-11-12 23:34:08 +0300 |
| commit | 3dc375f442cf81d4eae872515188d72bb744350b (patch) | |
| tree | 1556981dc05afe5ee30a32cfa6a5d24e3b9ed5b4 /src | |
| parent | 58135410063477e708e0dca090a67fe6a3e6b4c4 (diff) | |
initial implementation for desktop notifications
Diffstat (limited to 'src')
| -rw-r--r-- | src/modules/statuses.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/modules/statuses.js b/src/modules/statuses.js index 5f2f8152..0f45ba1b 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -239,6 +239,18 @@ 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') { + let title = action.user.name + let icon = action.user.profile_image_url + let body = action.text + + let notification = new window.Notification(title, {body, icon}) + + // Chrome is known for not closing notifications automatically + // according to MDN, anyway. + setTimeout(notification.close.bind(notification), 5000) + } } } |
