💄 Hide unread count auto after entering channel

This commit is contained in:
LittleSheep 2025-02-23 21:10:32 +08:00
parent 2c5dd0563a
commit fda09382dd

View File

@ -258,7 +258,8 @@ class _ChatScreenState extends State<ChatScreen> {
channel.name), channel.name),
), ),
const Gap(8), const Gap(8),
if (_unreadCounts?[channel.id] != null) if (_unreadCounts?[channel.id] != null &&
_unreadCounts![channel.id]! > 0)
Badge( Badge(
label: Text('${_unreadCounts![channel.id]}'), label: Text('${_unreadCounts![channel.id]}'),
), ),
@ -294,7 +295,11 @@ class _ChatScreenState extends State<ChatScreen> {
'alias': channel.alias, 'alias': channel.alias,
}, },
).then((value) { ).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<ChatScreen> {
children: [ children: [
Expanded(child: Text(channel.name)), Expanded(child: Text(channel.name)),
const Gap(8), const Gap(8),
if (_unreadCounts?[channel.id] != null) if (_unreadCounts?[channel.id] != null &&
_unreadCounts![channel.id]! > 0)
Badge( Badge(
label: Text('${_unreadCounts![channel.id]}'), label: Text('${_unreadCounts![channel.id]}'),
), ),
@ -330,6 +336,7 @@ class _ChatScreenState extends State<ChatScreen> {
), ),
onTap: () { onTap: () {
if (doExpand) { if (doExpand) {
_unreadCounts?[channel.id] = 0;
setState(() => _focusChannel = channel); setState(() => _focusChannel = channel);
return; return;
} }
@ -340,7 +347,10 @@ class _ChatScreenState extends State<ChatScreen> {
'alias': channel.alias, 'alias': channel.alias,
}, },
).then((value) { ).then((value) {
if (value == true) _refreshChannels(noRemote: true); if (mounted) {
setState(() => _unreadCounts?[channel.id] = 0);
_refreshChannels(noRemote: true);
}
}); });
}, },
); );