diff --git a/packages/backend/src/services/NotificationService.js b/packages/backend/src/services/NotificationService.js index f98786c2..556d3f0c 100644 --- a/packages/backend/src/services/NotificationService.js +++ b/packages/backend/src/services/NotificationService.js @@ -24,7 +24,13 @@ class NotificationService extends BaseService { svc_script.register('test-notification', async ({ log }, [username, summary]) => { log('creating notification: ' + summary); - this.notify(UsernameNotifSelector(username), { summary }); + this.notify(UsernameNotifSelector(username), { + source: 'notification-testing', + icon_source: 'builtin', + icon: 'logo.svg', + title: summary, + text: summary, + }); }); const svc_event = this.services.get('event'); diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index fa99a468..6a078d14 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -111,9 +111,22 @@ async function UIDesktop(options){ $(`.window[data-path="${html_encode(window.trash_path)}" i]`).find('.item-container').empty(); }) - window.socket.on('notif.message', ({ notification }) => { + window.socket.on('notif.message', ({ uid, notification }) => { + const icon = window.icons[notification.icon]; UINotification({ - content: notification.summary + title: notification.title, + text: notification.text, + icon: icon, + click: async () => { + await fetch(`${window.api_origin}/notif/mark-awk`, { + method: 'POST', + headers: { + Authorization: `Bearer ${puter.authToken}`, + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ uid }), + }); + }, }); }); @@ -124,21 +137,14 @@ async function UIDesktop(options){ for ( const notif_info of unreads ) { const notification = notif_info.notification; - const icon = (sys => { - if ( sys === 'share' ) return window.icons['shared.svg']; - if ( sys === 'puter' ) return window.icons['logo-fill.svg']; - return notification.builtin_icon - ? window.icons[notification.builtin_icon] - : notification.icon || window.icons['bell.svg']; - })(notification.subsystem); + const icon = window.icons[notification.icon]; UINotification({ - // icon: window.icons['shared.svg'], icon, - title: notification.summary, - text: notification.text ?? notification.summary, + title: notification.title, + text: notification.text ?? notification.title, click: async () => { - await fetch(`${window.api_origin}/notif/mark-read`, { + await fetch(`${window.api_origin}/notif/mark-awk`, { method: 'POST', headers: { Authorization: `Bearer ${puter.authToken}`,