diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index 185ed735..d24aa00b 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -145,7 +145,6 @@ class CwtchNotifier { } profileCN.getProfile(data["ProfileOnion"])?.contactList.updateLastMessageTime(identifier, DateTime.now()); profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.updateMessageCache(identifier, messageID, timestamp, senderHandle, senderImage, data["Data"]); - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.totalMessages++; // 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 @@ -195,7 +194,6 @@ class CwtchNotifier { // Only bother to do anything if we know about the group and the provided index is greater than our current total... if (currentTotal != null && idx >= currentTotal) { profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.updateMessageCache(identifier, idx, timestampSent, senderHandle, senderImage, data["Data"]); - profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier)!.totalMessages++; //if not currently open if (appState.selectedProfile != data["ProfileOnion"] || appState.selectedConversation != identifier) { @@ -221,14 +219,6 @@ class CwtchNotifier { // This is not dealt with by IndexedAcknowledgment } break; - case "MessageCounterResync": - var contactHandle = data["RemotePeer"]; - if (contactHandle == null || contactHandle == "") contactHandle = data["GroupID"]; - var total = int.parse(data["Data"]); - if (total != profileCN.getProfile(data["Identity"])?.contactList.findContact(contactHandle)!.totalMessages) { - profileCN.getProfile(data["Identity"])?.contactList.findContact(contactHandle)!.totalMessages = total; - } - break; case "SendMessageToPeerError": // Ignore break; diff --git a/lib/model.dart b/lib/model.dart index 4c94fb8e..eb5da8c9 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -689,10 +689,12 @@ class ContactInfoState extends ChangeNotifier { void updateMessageCache(int conversation, int messageID, DateTime timestamp, String senderHandle, String senderImage, String data) { this.messageCache.insert(0, MessageCache(MessageMetadata(profileOnion, conversation, messageID, timestamp, senderHandle, senderImage, "", {}, false, false), data)); + this.totalMessages += 1; } void bumpMessageCache() { this.messageCache.insert(0, null); + this.totalMessages += 1; } void ackCache(int messageID) { diff --git a/lib/views/messageview.dart b/lib/views/messageview.dart index 7cfd0501..539bebfb 100644 --- a/lib/views/messageview.dart +++ b/lib/views/messageview.dart @@ -215,7 +215,6 @@ class _MessageViewState extends State { focusNode.requestFocus(); Future.delayed(const Duration(milliseconds: 80), () { Provider.of(context, listen: false).contactList.getContact(Provider.of(context, listen: false).identifier)?.bumpMessageCache(); - Provider.of(context, listen: false).totalMessages++; Provider.of(context, listen: false).newMarker++; // Resort the contact list... Provider.of(context, listen: false).contactList.updateLastMessageTime(Provider.of(context, listen: false).identifier, DateTime.now()); diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index 81fb4533..e090e3ac 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -79,9 +79,7 @@ class _MessageListState extends State { var contactHandle = Provider.of(outerContext, listen: false).identifier; var messageIndex = index; - // var key = Provider.of(outerContext, listen: false).getMessageKey(contactHandle, Provider.of(outerContext).totalMessages - index, DateTime.now()); return FutureBuilder( - //key: Provider.of(outerContext, listen: false).getMessageKey(contactHandle, Provider.of(outerContext).totalMessages - index, DateTime.now()), future: messageHandler(outerContext, profileOnion, contactHandle, messageIndex), builder: (context, snapshot) { if (snapshot.hasData) { @@ -99,23 +97,3 @@ class _MessageListState extends State { ]))); } } - -class CachedMessage extends Message { - @override - MessageMetadata getMetadata() { - // TODO: implement getMetadata - throw UnimplementedError(); - } - - @override - Widget getPreviewWidget(BuildContext context) { - // TODO: implement getPreviewWidget - throw UnimplementedError(); - } - - @override - Widget getWidget(BuildContext context, Key key) { - // TODO: implement getWidget - throw UnimplementedError(); - } -}