mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe.git
synced 2024-11-13 03:54:48 +00:00
initial implementation for desktop notifications
This commit is contained in:
parent
5813541006
commit
3dc375f442
1 changed files with 12 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue