fix(frontend): обновлен notification-manager для работы с новой архитектурой
- Изменен WebSocket URL: /ws/notifications/ -> /ws/ - Обновлен обработчик типа 'notification' (вместо 'new_notification') - Добавлена обратная совместимость для старых типов сообщений - Теперь уведомления приходят через универсальный UserConsumer
This commit is contained in:
parent
825dd5f9e2
commit
7346f2977a
@ -1,3 +0,0 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@ -1,3 +0,0 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
@ -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);
|
||||
// Инвалидируем кеш при получении нового уведомления
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user