diff --git a/LIBCWTCH-GO.version b/LIBCWTCH-GO.version index a7cd31a..115c0b6 100644 --- a/LIBCWTCH-GO.version +++ b/LIBCWTCH-GO.version @@ -1 +1 @@ -v0.0.2-20-g7ad9c25-2021-05-07-23-49 \ No newline at end of file +v0.0.2-24-ga1095b7-2021-05-11-00-13 \ No newline at end of file diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index e77cedd..b87c243 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -100,6 +100,20 @@ class CwtchNotifier { } } break; + case "SendMessageToGroupError": + // from me (already displayed - do not update counter) + print("SendMessageToGroupError: $data"); + var idx = data["Signature"]; + 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); + 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 "AppError": print("New App Error: $data"); error.handleUpdate(data["Data"]); @@ -148,11 +162,11 @@ class CwtchNotifier { print("server state change: $data"); profileCN.getProfile(data["ProfileOnion"]).contactList.contacts.forEach((contact) { if (contact.isGroup == true && contact.server == data["GroupServer"]) { - print("server state change: $data " + contact.server); contact.status = data["ConnectionState"]; } }); break; + default: print("unhandled event: $type"); } diff --git a/lib/model.dart b/lib/model.dart index 365d6b5..f70a5dd 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -358,6 +358,7 @@ class MessageState extends ChangeNotifier { String _senderImage; String _signature = ""; bool _ackd = false; + bool _error = false; bool _loaded = false; MessageState({ @@ -372,6 +373,7 @@ class MessageState extends ChangeNotifier { get message => this._message; get timestamp => this._timestamp; get ackd => this._ackd; + get error => this._error; get senderOnion => this._senderOnion; get senderImage => this._senderImage; get loaded => this._loaded; @@ -382,6 +384,11 @@ class MessageState extends ChangeNotifier { notifyListeners(); } + set error(bool newVal) { + this._error = newVal; + notifyListeners(); + } + void tryLoad(BuildContext context) { Provider.of(context, listen: false).cwtch.GetMessage(profileOnion, contactHandle, messageIndex).then((jsonMessage) { dynamic messageWrapper = jsonDecode(jsonMessage); @@ -406,8 +413,12 @@ class MessageState extends ChangeNotifier { } this._loaded = true; - //update ackd last as it's changenotified - this._ackd = messageWrapper['Acknowledged']; + + //update ackd and error last as they are changenotified + this.ackd = messageWrapper['Acknowledged']; + if (messageWrapper['Error'] != null) { + this.error = true; + } }); } } diff --git a/lib/widgets/messagebubble.dart b/lib/widgets/messagebubble.dart index 14e115b..a69b70c 100644 --- a/lib/widgets/messagebubble.dart +++ b/lib/widgets/messagebubble.dart @@ -61,9 +61,11 @@ class MessageBubbleState extends State { textAlign: fromMe ? TextAlign.right : TextAlign.left), !fromMe ? SizedBox(width: 1, height: 1) - : Provider.of(context).ackd + : Provider.of(context).ackd == true ? Icon(Icons.check_circle_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) - : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) + : (Provider.of(context).error == true + ? Icon(Icons.error_outline, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12) + : Icon(Icons.hourglass_bottom_outlined, color: Provider.of(context).theme.messageFromMeTextColor(), size: 12)) ], ));