Browse Source

UI state fixes

Fix #89
Fix #75
quote
Sarah Jamie Lewis 12 months ago
parent
commit
a784ac1937
  1. 2
      LIBCWTCH-GO.version
  2. 32
      lib/cwtch/cwtchNotifier.dart
  3. 2
      lib/views/contactsview.dart
  4. 2
      lib/views/doublecolview.dart
  5. 9
      lib/views/messageview.dart

2
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

32
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<MessageMetadata>(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<MessageMetadata>(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<MessageMetadata>(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<MessageMetadata>(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");

2
lib/views/contactsview.dart

@ -49,7 +49,7 @@ class _ContactsViewState extends State<ContactsView> {
),
Expanded(
child: Text("%1 » %2".replaceAll("%1", Provider.of<ProfileInfoState>(context).nickname).replaceAll("%2", AppLocalizations.of(context)!.titleManageContacts),
overflow: TextOverflow.ellipsis, style: TextStyle(color: Provider.of<Settings>(context).current().mainTextColor()))), //todo
overflow: TextOverflow.ellipsis, style: TextStyle(color: Provider.of<Settings>(context).current().mainTextColor()))),
])),
actions: [
IconButton(icon: TorIcon(), onPressed: _pushTorStatus),

2
lib/views/doublecolview.dart

@ -33,7 +33,7 @@ class _DoubleColumnViewState extends State<DoubleColumnView> {
: //dev
MultiProvider(providers: [
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)),
ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context).contactList.getContact(flwtch.selectedConversation!)!),
ChangeNotifierProvider.value(value: flwtch.selectedConversation != null ? Provider.of<ProfileInfoState>(context).contactList.getContact(flwtch.selectedConversation!)! : ContactInfoState("","")),
], child: Container(child: MessageView())),
),
],

9
lib/views/messageview.dart

@ -47,6 +47,12 @@ class _MessageViewState extends State<MessageView> {
@override
Widget build(BuildContext context) {
// After leaving a conversation the selected conversation is set to null...
if (Provider.of<ContactInfoState>(context).profileOnion == "") {
return Card(child: Center(child: Text(AppLocalizations.of(context)!.addContactFirst)));
}
var appState = Provider.of<AppState>(context);
return WillPopScope(
onWillPop: _onWillPop,
@ -65,7 +71,8 @@ class _MessageViewState extends State<MessageView> {
SizedBox(
width: 10,
),
Text(Provider.of<ContactInfoState>(context).nickname)
Expanded(
child:Text(Provider.of<ContactInfoState>(context).nickname, overflow: TextOverflow.ellipsis,))
]),
actions: [
//IconButton(icon: Icon(Icons.chat), onPressed: _pushContactSettings),

Loading…
Cancel
Save