💄 Optimized unread indicator

This commit is contained in:
LittleSheep 2025-04-01 22:40:43 +08:00
parent 00863b94e8
commit 919ff5e464

@ -171,7 +171,18 @@ class _ChatScreenState extends State<ChatScreen> {
} }
void _onTapChannel(SnChannel channel) { void _onTapChannel(SnChannel channel) {
setState(() => _unreadCounts?[channel.id] = 0); setState(() {
_unreadCounts?[channel.id] = 0;
if (channel.realmId != null) {
_unreadCountsGrouped?[channel.realmId!] =
(_unreadCountsGrouped?[channel.realmId!] ?? 0) -
(_unreadCounts?[channel.id] ?? 0);
}
if (channel.type == 1) {
_unreadCountsGrouped?[0] =
(_unreadCountsGrouped?[0] ?? 0) - (_unreadCounts?[channel.id] ?? 0);
}
});
if (ResponsiveScaffold.getIsExpand(context)) { if (ResponsiveScaffold.getIsExpand(context)) {
GoRouter.of(context).pushReplacementNamed( GoRouter.of(context).pushReplacementNamed(
'chatRoom', 'chatRoom',
@ -180,9 +191,8 @@ class _ChatScreenState extends State<ChatScreen> {
'alias': channel.alias, 'alias': channel.alias,
}, },
).then((value) { ).then((value) {
if (mounted) { if (mounted && value == true) {
setState(() => _unreadCounts?[channel.id] = 0); _refreshChannels();
_refreshChannels(noRemote: true);
} }
}); });
} else { } else {
@ -193,9 +203,8 @@ class _ChatScreenState extends State<ChatScreen> {
'alias': channel.alias, 'alias': channel.alias,
}, },
).then((value) { ).then((value) {
if (mounted) { if (mounted && value == true) {
setState(() => _unreadCounts?[channel.id] = 0); _refreshChannels();
_refreshChannels(noRemote: true);
} }
}); });
} }