1
0
Эх сурвалжийг харах

tweak: update notification format

KernelDeimos 11 сар өмнө
parent
commit
20542b0565

+ 7 - 1
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');

+ 19 - 13
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}`,