mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-07-18 01:14:07 +00:00
fix in chat overview
Some checks failed
Flutter analyze & test / flutter_analyze_and_test (push) Has been cancelled
Some checks failed
Flutter analyze & test / flutter_analyze_and_test (push) Has been cancelled
This commit is contained in:
parent
21ca0a9c37
commit
93f1031453
2 changed files with 24 additions and 10 deletions
|
|
@ -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<InChatGroupOverview> {
|
||||
Contact? _directContact;
|
||||
StreamSubscription<dynamic>? _verificationSub;
|
||||
StreamSubscription<List<(Contact, DateTime)>>? _transferredTrustSub;
|
||||
StreamSubscription<int>? _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<InChatGroupOverview> {
|
|||
_initVerificationCheck();
|
||||
}
|
||||
|
||||
void _updateVerificationState() {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isVerified =
|
||||
_directContact?.verified == true ||
|
||||
_verifications.isNotEmpty ||
|
||||
_transferredTrust.isNotEmpty;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _initVerificationCheck() async {
|
||||
if (widget.group.isDirectChat) {
|
||||
final contacts = await twonlyDB.groupsDao.getGroupContact(
|
||||
|
|
@ -47,14 +60,14 @@ class _InChatGroupOverviewState extends State<InChatGroupOverview> {
|
|||
_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<InChatGroupOverview> {
|
|||
@override
|
||||
void dispose() {
|
||||
_verificationSub?.cancel();
|
||||
_transferredTrustSub?.cancel();
|
||||
_unverifiedCountSub?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue