diff --git a/lib/src/visual/views/chats/chat_messages_components/in_chat_group_overview.dart b/lib/src/visual/views/chats/chat_messages_components/in_chat_group_overview.dart index ebc2f3df..1749f47c 100644 --- a/lib/src/visual/views/chats/chat_messages_components/in_chat_group_overview.dart +++ b/lib/src/visual/views/chats/chat_messages_components/in_chat_group_overview.dart @@ -5,7 +5,6 @@ import 'package:go_router/go_router.dart'; import 'package:twonly/locator.dart'; import 'package:twonly/src/constants/routes.keys.dart'; import 'package:twonly/src/database/daos/key_verification.dao.dart'; -import 'package:twonly/src/database/tables/contacts.table.dart'; import 'package:twonly/src/database/twonly.db.dart'; import 'package:twonly/src/utils/misc.dart'; import 'package:twonly/src/visual/components/avatar_icon.comp.dart'; @@ -27,9 +26,12 @@ class InChatGroupOverview extends StatefulWidget { class _InChatGroupOverviewState extends State { Contact? _directContact; StreamSubscription? _verificationSub; + StreamSubscription>? _transferredTrustSub; StreamSubscription? _unverifiedCountSub; bool _isVerified = true; int _unverifiedCount = 0; + List<(KeyVerification, Contact?)> _verifications = []; + List<(Contact, DateTime)> _transferredTrust = []; @override void initState() { @@ -37,6 +39,17 @@ class _InChatGroupOverviewState extends State { _initVerificationCheck(); } + void _updateVerificationState() { + if (mounted) { + setState(() { + _isVerified = + _directContact?.verified == true || + _verifications.isNotEmpty || + _transferredTrust.isNotEmpty; + }); + } + } + Future _initVerificationCheck() async { if (widget.group.isDirectChat) { final contacts = await twonlyDB.groupsDao.getGroupContact( @@ -47,14 +60,14 @@ class _InChatGroupOverviewState extends State { _verificationSub = twonlyDB.keyVerificationDao .watchContactVerification(_directContact!.userId) .listen((verifications) { - if (mounted) { - setState(() { - _isVerified = verifications.any( - (v) => - v.$1.type != VerificationType.contactSharedByVerified, - ); - }); - } + _verifications = verifications; + _updateVerificationState(); + }); + _transferredTrustSub = twonlyDB.keyVerificationDao + .watchTransferredTrustVerifications(_directContact!.userId) + .listen((transferredTrust) { + _transferredTrust = transferredTrust; + _updateVerificationState(); }); } } else { @@ -82,6 +95,7 @@ class _InChatGroupOverviewState extends State { @override void dispose() { _verificationSub?.cancel(); + _transferredTrustSub?.cancel(); _unverifiedCountSub?.cancel(); super.dispose(); } diff --git a/pubspec.yaml b/pubspec.yaml index 359fad98..478ea0ed 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: "twonly, a privacy-friendly way to connect with friends through sec publish_to: 'none' -version: 0.3.5+151 +version: 0.3.6+152 environment: sdk: ^3.11.0