Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modern-flies-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'studytimer.io': minor
---

Add logo icon for desktop notifications.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default [
...globals.browser,
NodeJS: true,
NotificationPermission: true,
NotificationOptions: true,
},
},
plugins: { jsdoc, importPlugin },
Expand Down
Binary file added src/assets/images/logo-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions src/services/notification-api.service.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logoIcon from '../assets/images/logo-icon.png';
import { appStore } from '../stores/app.js';
import {
CLIENT_ERROR_MESSAGE,
Expand All @@ -16,16 +17,15 @@ class NotificationApiService {
return;
}

/** @type {NotificationOptions} */
const notificationOptions = { body: message, icon: logoIcon };

if (Notification.permission === NOTIFICATION_PERMISSION.GRANTED) {
new Notification(title, {
body: message,
});
new Notification(title, { ...notificationOptions });
} else {
this.requestNotificationPermission().then(function (permissionGranted) {
if (permissionGranted) {
new Notification(title, {
body: message,
});
new Notification(title, { ...notificationOptions });
}
});
}
Expand Down
Loading