diff --git a/lib/frontend/screens/chats/chat_screen.dart b/lib/frontend/screens/chats/chat_screen.dart index 2fcb198..69ef379 100644 --- a/lib/frontend/screens/chats/chat_screen.dart +++ b/lib/frontend/screens/chats/chat_screen.dart @@ -679,11 +679,24 @@ class _ChatScreenState extends State case Opcode.notifMsgDelayed: final p = packet.payload; if (p is Map && p['chatId'] == widget.chatId) { - _refreshScheduledCount(); + // lastDelayedUpdateTime — авторитетный признак от сервера: + // 0 — отложенных в чате не осталось, иначе они есть. Реагируем + // мгновенно по пушу, не дожидаясь повторного запроса. + final t = p['lastDelayedUpdateTime']; + if (t is int && t == 0) { + _scheduledCount.value = 0; + } else { + if (_scheduledCount.value == 0) _scheduledCount.value = 1; + _refreshScheduledCount(); + } } } } + void _markHasScheduled() { + if (_scheduledCount.value == 0) _scheduledCount.value = 1; + } + Future _refreshScheduledCount() async { if (_myId == 0) return; try { @@ -1356,6 +1369,7 @@ class _ChatScreenState extends State _hasText.value = false; _messageController.clear(); Haptics.send(); + _markHasScheduled(); showCustomNotification( context, 'Запланировано на ${formatDateTimeWords(when)}', @@ -2668,6 +2682,7 @@ class _ChatScreenState extends State if (scheduled) { Haptics.send(); + _markHasScheduled(); showCustomNotification( context, 'Запланировано на ' @@ -2752,6 +2767,7 @@ class _ChatScreenState extends State if (!mounted) return; if (result != null) { Haptics.send(); + _markHasScheduled(); showCustomNotification( context, 'Запланировано на '