Jake Vanderwerf
2025-12-21 3aada9949d51024a92a8b5c6cb70d12f9c3cac16
assets/js/concise/Notifications.js
File was renamed from assets/js/Notifications.js
@@ -82,7 +82,7 @@
            this.isLoading = true;
            const params = new URLSearchParams({
                user: jvbSettings.currentUser,
                user: window.auth.getUser(),
                status: 'unread',
                limit: 5,
            });
@@ -92,8 +92,8 @@
                {
                    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',
@@ -101,8 +101,6 @@
                }
            );
            console.log(data);
            this.renderPreviewNotifications(data.notifications);
            this.updateUnreadCount(data.total);
            this.notificationsLoaded = true;
@@ -279,12 +277,12 @@
                `${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(),
                    }
                }
            );
@@ -335,13 +333,13 @@
    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,
                }
            });
@@ -366,12 +364,16 @@
}
// 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) {