From b766f778d8313c3d07ba832007c097bd039cd380 Mon Sep 17 00:00:00 2001 From: klockky Date: Sat, 13 Jun 2026 12:56:04 +0000 Subject: [PATCH] =?UTF-8?q?fix(chat):=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BE=D1=82=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D1=80=D0=B5=D0=B0=D0=B3=D0=B8=D1=80=D1=83=D0=B5=D1=82?= =?UTF-8?q?=20=D0=BD=D0=B0=20lastDelayedUpdateTime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/frontend/screens/chats/chat_screen.dart | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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, 'Запланировано на '