tweak: update notification format

This commit is contained in:
KernelDeimos 2024-06-15 18:53:03 -04:00 committed by Eric Dubé
parent ef8f4de962
commit 20542b0565
2 changed files with 26 additions and 14 deletions

View File

@ -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');

View File

@ -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}`,