From cde6962b8e6778f4ca0df0411650379af43baaf1 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 16 Dec 2021 13:36:14 -0500 Subject: [PATCH 1/4] group functionality fixes from storage engine; tor status include percent; crate group enhancement --- lib/cwtch/cwtchNotifier.dart | 19 ++++++++++--------- lib/torstatus.dart | 3 +++ lib/views/addcontactview.dart | 8 ++++++-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index 29ec9ce4..f3eaeb07 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -92,8 +92,8 @@ class CwtchNotifier { if (serverInfoState != null) { status = serverInfoState.status; } - if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) == null) { - profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], data["ConversationID"], data["GroupID"], + if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(int.parse(data["ConversationID"])) == null) { + profileCN.getProfile(data["ProfileOnion"])?.contactList.add(ContactInfoState(data["ProfileOnion"], int.parse(data["ConversationID"]), data["GroupID"], authorization: ContactAuthorization.approved, imagePath: data["PicturePath"], nickname: data["GroupName"], @@ -101,7 +101,7 @@ class CwtchNotifier { server: data["GroupServer"], isGroup: true, lastMessageTime: DateTime.now())); - profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.now()); + profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(int.parse(data["ConversationID"]), DateTime.now()); } break; case "PeerDeleted": @@ -303,8 +303,8 @@ class CwtchNotifier { case "AcceptGroupInvite": EnvironmentConfig.debugLog("accept group invite"); - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.authorization = ContactAuthorization.approved; - profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["GroupID"], DateTime.fromMillisecondsSinceEpoch(0)); + profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(int.parse(data["ConversationID"]))!.authorization = ContactAuthorization.approved; + profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(int.parse(data["ConversationID"]), DateTime.fromMillisecondsSinceEpoch(0)); break; case "ServerStateChange": // Update the Server Cache @@ -317,13 +317,14 @@ class CwtchNotifier { profileCN.getProfile(data["ProfileOnion"])?.contactList.resort(); break; case "SetGroupAttribute": + int identifier = int.parse(data["ConversationID"]); if (data["Key"] == "local.name") { - if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) != null) { - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.nickname = data["Data"]; + if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier) != null) { + profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.nickname = data["Data"]; } } else if (data["Key"] == "local.archived") { - if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"]) != null) { - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.isArchived = data["Data"] == "true"; + if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier) != null) { + profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.isArchived = data["Data"] == "true"; } } else { EnvironmentConfig.debugLog("unhandled set group attribute event: ${data['Key']}"); diff --git a/lib/torstatus.dart b/lib/torstatus.dart index a6910b58..af94b78d 100644 --- a/lib/torstatus.dart +++ b/lib/torstatus.dart @@ -18,6 +18,9 @@ class TorStatus extends ChangeNotifier { progress = new_progress; status = new_status; + if (new_progress != 100) { + status = "$new_progress% - $new_status"; + } notifyListeners(); } diff --git a/lib/views/addcontactview.dart b/lib/views/addcontactview.dart index c073f0f5..4e984595 100644 --- a/lib/views/addcontactview.dart +++ b/lib/views/addcontactview.dart @@ -197,11 +197,15 @@ class _AddContactViewState extends State { }, isExpanded: true, // magic property value: server, - items: Provider.of(context).serverList.servers.map>((RemoteServerInfoState serverInfo) { + items: Provider.of(context) + .serverList + .servers + .where((serverInfo) => serverInfo.status == "Synced") + .map>((RemoteServerInfoState serverInfo) { return DropdownMenuItem( value: serverInfo.onion, child: Text( - serverInfo.onion, + serverInfo.description, overflow: TextOverflow.ellipsis, ), ); From aff7a5f4b210d7026c07ee2c0c587a830c7e44d2 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Thu, 16 Dec 2021 19:50:43 -0500 Subject: [PATCH 2/4] deleting removed event event handlers --- lib/cwtch/cwtchNotifier.dart | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index f3eaeb07..b7adfb19 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -300,12 +300,6 @@ class CwtchNotifier { } } break; - case "AcceptGroupInvite": - EnvironmentConfig.debugLog("accept group invite"); - - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(int.parse(data["ConversationID"]))!.authorization = ContactAuthorization.approved; - profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(int.parse(data["ConversationID"]), DateTime.fromMillisecondsSinceEpoch(0)); - break; case "ServerStateChange": // Update the Server Cache profileCN.getProfile(data["ProfileOnion"])?.updateServerStatusCache(data["GroupServer"], data["ConnectionState"]); @@ -316,20 +310,6 @@ class CwtchNotifier { }); profileCN.getProfile(data["ProfileOnion"])?.contactList.resort(); break; - case "SetGroupAttribute": - int identifier = int.parse(data["ConversationID"]); - if (data["Key"] == "local.name") { - if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier) != null) { - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.nickname = data["Data"]; - } - } else if (data["Key"] == "local.archived") { - if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier) != null) { - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.isArchived = data["Data"] == "true"; - } - } else { - EnvironmentConfig.debugLog("unhandled set group attribute event: ${data['Key']}"); - } - break; case "SetPeerAttribute": if (data["Key"] == "local.name") { if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"]) != null) { From 75acfe8dd092b15332996d45d4f300fe924c9c0a Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Fri, 17 Dec 2021 17:34:56 -0500 Subject: [PATCH 3/4] contact list sort more often and float unauthed contacts to top --- lib/model.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/model.dart b/lib/model.dart index 2106895b..083b63e4 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -149,6 +149,7 @@ class ContactListState extends ChangeNotifier { servers?.addGroup(contact); } }); + resort(); notifyListeners(); } @@ -157,6 +158,7 @@ class ContactListState extends ChangeNotifier { if (newContact.isGroup) { servers?.addGroup(newContact); } + resort(); notifyListeners(); } @@ -164,12 +166,18 @@ class ContactListState extends ChangeNotifier { _contacts.sort((ContactInfoState a, ContactInfoState b) { // return -1 = a first in list // return 1 = b first in list + // blocked contacts last if (a.isBlocked == true && b.isBlocked != true) return 1; if (a.isBlocked != true && b.isBlocked == true) return -1; // archive is next... if (!a.isArchived && b.isArchived) return -1; if (a.isArchived && !b.isArchived) return 1; + + // unapproved top + if (a.isInvitation && !b.isInvitation) return -1; + if (!a.isInvitation && b.isInvitation) return 1; + // special sorting for contacts with no messages in either history if (a.lastMessageTime.millisecondsSinceEpoch == 0 && b.lastMessageTime.millisecondsSinceEpoch == 0) { // online contacts first From 8e489131fa1dd39ff853c840a992eb52933ab9a4 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sat, 18 Dec 2021 13:51:52 -0500 Subject: [PATCH 4/4] fix bg color of servers pane --- lib/views/serversview.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/views/serversview.dart b/lib/views/serversview.dart index 5e943b43..d413f2b2 100644 --- a/lib/views/serversview.dart +++ b/lib/views/serversview.dart @@ -30,6 +30,7 @@ class _ServersView extends State { @override Widget build(BuildContext context) { return Scaffold( + backgroundColor: Provider.of(context, listen: false).theme.backgroundMainColor, appBar: AppBar( title: Text(MediaQuery.of(context).size.width > 600 ? AppLocalizations.of(context)!.serversManagerTitleLong : AppLocalizations.of(context)!.serversManagerTitleShort), actions: getActions(),