| File was renamed from assets/js/Notifications.js |
| | |
| | | this.isLoading = true; |
| | | |
| | | const params = new URLSearchParams({ |
| | | user: jvbSettings.currentUser, |
| | | user: window.auth.getUser(), |
| | | status: 'unread', |
| | | limit: 5, |
| | | }); |
| | |
| | | { |
| | | method: 'GET', |
| | | headers: { |
| | | 'X-WP-Nonce': jvbSettings.nonce, |
| | | 'action_nonce': jvbSettings.notifications |
| | | 'X-WP-Nonce': window.auth.getNonce(), |
| | | 'action_nonce': window.auth.getNonce('notifications') |
| | | } |
| | | }, { |
| | | context: 'notifications', |
| | |
| | | } |
| | | ); |
| | | |
| | | console.log(data); |
| | | |
| | | this.renderPreviewNotifications(data.notifications); |
| | | this.updateUnreadCount(data.total); |
| | | this.notificationsLoaded = true; |
| | |
| | | `${jvbSettings.api}notifications`, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'X-WP-Nonce': jvbSettings.nonce, |
| | | 'action_nonce': jvbSettings.dash, |
| | | 'X-WP-Nonce': window.auth.getNonce(), |
| | | 'action_nonce': window.auth.getNonce('dash'), |
| | | }, |
| | | body: { |
| | | notification: notificationId, |
| | | user: jvbSettings.currentUser, |
| | | user: window.auth.getUser(), |
| | | } |
| | | } |
| | | ); |
| | |
| | | async checkNotifications() { |
| | | try { |
| | | const params = new URLSearchParams({ |
| | | user: jvbSettings.currentUser, |
| | | user: window.auth.getUser(), |
| | | status: 'unread', |
| | | }); |
| | | const response = await fetch(`${jvbSettings.api}notifications?${params.toString()}`, { |
| | | headers: { |
| | | 'X-WP-Nonce': jvbSettings.nonce, |
| | | 'action_nonce': jvbSettings.dash, |
| | | 'X-WP-Nonce': window.auth.getNonce(), |
| | | 'action_nonce': window.auth.getNonce('dash'), |
| | | 'If-Modified-Since': this.lastCheck, |
| | | } |
| | | }); |
| | |
| | | } |
| | | |
| | | // Initialize when DOM is ready |
| | | document.addEventListener('DOMContentLoaded', () => { |
| | | window.jvbNotifications = new NotificationManager({ |
| | | position: 'bottom-right', |
| | | maxVisibleNotifications: 5, |
| | | displayDuration: 5000 |
| | | }); |
| | | document.addEventListener('DOMContentLoaded', async function(){ |
| | | window.auth.subscribe((event) => { |
| | | if (event === 'auth-loaded') { |
| | | window.jvbNotifications = new NotificationManager({ |
| | | position: 'bottom-right', |
| | | maxVisibleNotifications: 5, |
| | | displayDuration: 5000 |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | function handleNotificationAction(button) { |