diff options
| author | Fuwn <[email protected]> | 2025-02-14 01:57:30 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-02-14 01:57:30 -0800 |
| commit | cbd31e2734352f73c2d57abf9b631ffbc4053c40 (patch) | |
| tree | ef5c2105d2685ee7eab4f8b0c91f139a03c876ed /src/lib/Utility | |
| parent | feat(Tools): Use generic birthdays tool template, adds NIJISANJI birthdays tool (diff) | |
| download | due.moe-cbd31e2734352f73c2d57abf9b631ffbc4053c40.tar.xz due.moe-cbd31e2734352f73c2d57abf9b631ffbc4053c40.zip | |
style: Run formatter
Diffstat (limited to 'src/lib/Utility')
| -rw-r--r-- | src/lib/Utility/notifications.ts | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/lib/Utility/notifications.ts b/src/lib/Utility/notifications.ts index cba430e9..596eec2a 100644 --- a/src/lib/Utility/notifications.ts +++ b/src/lib/Utility/notifications.ts @@ -1,5 +1,9 @@ import { env } from '$env/dynamic/public'; -import { isNotificationQueued, notifications, updateLastNotificationID } from '$lib/Data/AniList/notifications'; +import { + isNotificationQueued, + notifications, + updateLastNotificationID +} from '$lib/Data/AniList/notifications'; import { database } from '$lib/Database/IDB/user'; import { getFingerprint } from './fingerprint'; import root from './root'; @@ -26,7 +30,7 @@ export const requestNotifications = async () => { await fetch(`/api/notifications/unsubscribe?p=${getFingerprint()}`, { method: 'POST' }); - await updateLocalNotifications() + await updateLocalNotifications(); setInterval(async () => await updateLocalNotifications(), 1000 * 60); } } @@ -40,17 +44,14 @@ const updateLocalNotifications = async () => { const recentNotifications = await notifications(user.user.accessToken); - if (await window.Notification.requestPermission() == "granted") - if ( - recentNotifications && - isNotificationQueued(recentNotifications, user.lastNotificationID) - ) { - await updateLastNotificationID(user.id, recentNotifications) + if ((await window.Notification.requestPermission()) == 'granted') + if (recentNotifications && isNotificationQueued(recentNotifications, user.lastNotificationID)) { + await updateLastNotificationID(user.id, recentNotifications); new Notification('due.moe', { body: `${recentNotifications[0].user.name}${recentNotifications[0].context}`, icon: recentNotifications[0].user.avatar.large || '/favicon-196x196.png', tag: 'notification-1' - }) + }); } -} +}; |