Compare commits

...

1 Commits
trunk ... quote

Author SHA1 Message Date
Sarah Jamie Lewis a784ac1937 UI state fixes
Fix #89
Fix #75
2021-07-08 13:29:42 -07:00
5 changed files with 41 additions and 6 deletions

View File

@ -1 +1 @@
v1.0.0-27-g4d218df-2021-07-07-23-27
v1.0.0-29-g41ae09d-2021-07-08-20-22

View File

@ -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");

View File

@ -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),

View File

@ -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())),
),
],

View File

@ -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),