mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
tweak: update notification format
This commit is contained in:
parent
ef8f4de962
commit
20542b0565
@ -24,7 +24,13 @@ class NotificationService extends BaseService {
|
|||||||
svc_script.register('test-notification', async ({ log }, [username, summary]) => {
|
svc_script.register('test-notification', async ({ log }, [username, summary]) => {
|
||||||
log('creating notification: ' + 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');
|
const svc_event = this.services.get('event');
|
||||||
|
@ -111,9 +111,22 @@ async function UIDesktop(options){
|
|||||||
$(`.window[data-path="${html_encode(window.trash_path)}" i]`).find('.item-container').empty();
|
$(`.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({
|
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 ) {
|
for ( const notif_info of unreads ) {
|
||||||
const notification = notif_info.notification;
|
const notification = notif_info.notification;
|
||||||
const icon = (sys => {
|
const icon = window.icons[notification.icon];
|
||||||
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);
|
|
||||||
|
|
||||||
UINotification({
|
UINotification({
|
||||||
// icon: window.icons['shared.svg'],
|
|
||||||
icon,
|
icon,
|
||||||
title: notification.summary,
|
title: notification.title,
|
||||||
text: notification.text ?? notification.summary,
|
text: notification.text ?? notification.title,
|
||||||
click: async () => {
|
click: async () => {
|
||||||
await fetch(`${window.api_origin}/notif/mark-read`, {
|
await fetch(`${window.api_origin}/notif/mark-awk`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${puter.authToken}`,
|
Authorization: `Bearer ${puter.authToken}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user