fix(frontend): обновлен notification-manager для работы с новой архитектурой

- Изменен WebSocket URL: /ws/notifications/ -> /ws/
- Обновлен обработчик типа 'notification' (вместо 'new_notification')
- Добавлена обратная совместимость для старых типов сообщений
- Теперь уведомления приходят через универсальный UserConsumer
This commit is contained in:
admin i 2025-12-03 12:54:05 +03:00
parent 825dd5f9e2
commit 7346f2977a
4 changed files with 9 additions and 11 deletions

View File

@ -1,3 +0,0 @@
from django.db import models
# Create your models here.

View File

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View File

@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View File

@ -95,7 +95,8 @@ class NotificationManager {
connectWebSocket() {
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = `${protocol}//${window.location.host}/ws/notifications/`;
// Используем универсальный WebSocket endpoint (realtime architecture)
const wsUrl = `${protocol}//${window.location.host}/ws/`;
console.log('[Notifications] Connecting to:', wsUrl);
@ -145,7 +146,13 @@ class NotificationManager {
this.updateBadge(data.count);
break;
case 'new_notification':
case 'notification': // UserConsumer использует "notification"
this.showNewNotification(data.notification);
// Инвалидируем кеш при получении нового уведомления
invalidateNotifications();
break;
case 'new_notification': // Backwards compatibility
this.showNewNotification(data.notification);
this.updateBadge(data.notification.unread_count);
// Инвалидируем кеш при получении нового уведомления