diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index 534536d7..b70bed05 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -v1.0.0-27-g4d218df-2021-07-07-23-27 +v1.0.0-29-g41ae09d-2021-07-08-20-22 diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index 4ecc0ec5..28264255 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -105,6 +105,14 @@ class CwtchNotifier { } profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.totalMessages++; profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(data["RemotePeer"], DateTime.now()); + + // We only ever see messages from authenticated peers. + // If the contact is marked as offline then override this - can happen when the contact is removed from the front + // end during syncing. + if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.isOnline() == false) { + profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.status = "Authenticated"; + } + break; case "PeerAcknowledgement": // We don't use these anymore, IndexedAcknowledgement is more suited to the UI front end... @@ -118,6 +126,12 @@ class CwtchNotifier { try { var message = Provider.of(key.currentContext!, listen: false); if (message == null) break; + // We only ever see acks from authenticated peers. + // If the contact is marked as offline then override this - can happen when the contact is removed from the front + // end during syncing. + if (profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.isOnline() == false) { + profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.status = "Authenticated"; + } message.ackd = true; } catch (e) { // ignore, we received an ack for a message that hasn't loaded onto the screen yet... @@ -136,7 +150,7 @@ class CwtchNotifier { } else { // from me (already displayed - do not update counter) var idx = data["Signature"]; - var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])!.getMessageKey(idx); + var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["GroupID"])?.getMessageKey(idx); if (key == null) break; try { var message = Provider.of(key.currentContext!, listen: false); @@ -155,7 +169,7 @@ class CwtchNotifier { case "IndexedFailure": EnvironmentConfig.debugLog("IndexedFailure"); var idx = data["Index"]; - var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.getMessageKey(idx); + var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])?.getMessageKey(idx); try { var message = Provider.of(key!.currentContext!, listen: false); message.error = true; @@ -163,6 +177,20 @@ class CwtchNotifier { // ignore, we likely have an old key that has been replaced with an actual signature } break; + case "SendMessageToPeerError": + // from me (already displayed - do not update counter) + EnvironmentConfig.debugLog("SendMessageToPeerError"); + var idx = data["EventID"]; + var key = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(data["RemotePeer"])!.getMessageKey(idx); + if (key == null) break; + try { + var message = Provider.of(key.currentContext!, listen: false); + if (message == null) break; + message.error = true; + } catch (e) { + // ignore, we likely have an old key that has been replaced with an actual signature + } + break; case "SendMessageToGroupError": // from me (already displayed - do not update counter) EnvironmentConfig.debugLog("SendMessageToGroupError"); diff --git a/lib/views/contactsview.dart b/lib/views/contactsview.dart index d52709be..d116977f 100644 --- a/lib/views/contactsview.dart +++ b/lib/views/contactsview.dart @@ -49,7 +49,7 @@ class _ContactsViewState extends State { ), Expanded( child: Text("%1 ยป %2".replaceAll("%1", Provider.of(context).nickname).replaceAll("%2", AppLocalizations.of(context)!.titleManageContacts), - overflow: TextOverflow.ellipsis, style: TextStyle(color: Provider.of(context).current().mainTextColor()))), //todo + overflow: TextOverflow.ellipsis, style: TextStyle(color: Provider.of(context).current().mainTextColor()))), ])), actions: [ IconButton(icon: TorIcon(), onPressed: _pushTorStatus), diff --git a/lib/views/doublecolview.dart b/lib/views/doublecolview.dart index e7d3a260..2275cd74 100644 --- a/lib/views/doublecolview.dart +++ b/lib/views/doublecolview.dart @@ -33,7 +33,7 @@ class _DoubleColumnViewState extends State { : //dev MultiProvider(providers: [ ChangeNotifierProvider.value(value: Provider.of(context)), - ChangeNotifierProvider.value(value: Provider.of(context).contactList.getContact(flwtch.selectedConversation!)!), + ChangeNotifierProvider.value(value: flwtch.selectedConversation != null ? Provider.of(context).contactList.getContact(flwtch.selectedConversation!)! : ContactInfoState("","")), ], child: Container(child: MessageView())), ), ], diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index d295e379..7472f93e 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -47,6 +47,12 @@ class _MessageViewState extends State { @override Widget build(BuildContext context) { + + // After leaving a conversation the selected conversation is set to null... + if (Provider.of(context).profileOnion == "") { + return Card(child: Center(child: Text(AppLocalizations.of(context)!.addContactFirst))); + } + var appState = Provider.of(context); return WillPopScope( onWillPop: _onWillPop, @@ -65,7 +71,8 @@ class _MessageViewState extends State { SizedBox( width: 10, ), - Text(Provider.of(context).nickname) + Expanded( + child:Text(Provider.of(context).nickname, overflow: TextOverflow.ellipsis,)) ]), actions: [ //IconButton(icon: Icon(Icons.chat), onPressed: _pushContactSettings),