diff --git a/lib/screens/chat.dart b/lib/screens/chat.dart index bc52052..32d4910 100644 --- a/lib/screens/chat.dart +++ b/lib/screens/chat.dart @@ -258,7 +258,8 @@ class _ChatScreenState extends State { channel.name), ), const Gap(8), - if (_unreadCounts?[channel.id] != null) + if (_unreadCounts?[channel.id] != null && + _unreadCounts![channel.id]! > 0) Badge( label: Text('${_unreadCounts![channel.id]}'), ), @@ -294,7 +295,11 @@ class _ChatScreenState extends State { 'alias': channel.alias, }, ).then((value) { - if (mounted) _refreshChannels(noRemote: true); + if (mounted) { + _unreadCounts?[channel.id] = 0; + setState(() => _unreadCounts?[channel.id] = 0); + _refreshChannels(noRemote: true); + } }); }, ); @@ -305,7 +310,8 @@ class _ChatScreenState extends State { children: [ Expanded(child: Text(channel.name)), const Gap(8), - if (_unreadCounts?[channel.id] != null) + if (_unreadCounts?[channel.id] != null && + _unreadCounts![channel.id]! > 0) Badge( label: Text('${_unreadCounts![channel.id]}'), ), @@ -330,6 +336,7 @@ class _ChatScreenState extends State { ), onTap: () { if (doExpand) { + _unreadCounts?[channel.id] = 0; setState(() => _focusChannel = channel); return; } @@ -340,7 +347,10 @@ class _ChatScreenState extends State { 'alias': channel.alias, }, ).then((value) { - if (value == true) _refreshChannels(noRemote: true); + if (mounted) { + setState(() => _unreadCounts?[channel.id] = 0); + _refreshChannels(noRemote: true); + } }); }, );