New Cwtch Library Integration #258

Merged
sarah merged 14 commits from cwtch-lib-integration into trunk 2021-12-10 21:02:02 +00:00
4 changed files with 2 additions and 33 deletions
Showing only changes of commit 30fa788b84 - Show all commits

View File

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

View File

@ -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;
}
sarah marked this conversation as resolved
Review

ideally internal. the public setter for totalMessages can call, and updateMessageCaches should internally inc totalMessages

ideally internal. the public setter for totalMessages can call, and updateMessageCaches should internally inc totalMessages
void bumpMessageCache() {
this.messageCache.insert(0, null);
this.totalMessages += 1;
}
void ackCache(int messageID) {

View File

@ -215,7 +215,6 @@ class _MessageViewState extends State<MessageView> {
focusNode.requestFocus();
Future.delayed(const Duration(milliseconds: 80), () {
Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(Provider.of<ContactInfoState>(context, listen: false).identifier)?.bumpMessageCache();
Provider.of<ContactInfoState>(context, listen: false).totalMessages++;
Provider.of<ContactInfoState>(context, listen: false).newMarker++;
// Resort the contact list...
Provider.of<ProfileInfoState>(context, listen: false).contactList.updateLastMessageTime(Provider.of<ContactInfoState>(context, listen: false).identifier, DateTime.now());

View File

@ -79,9 +79,7 @@ class _MessageListState extends State<MessageList> {
var contactHandle = Provider.of<ContactInfoState>(outerContext, listen: false).identifier;
var messageIndex = index;
// var key = Provider.of<ContactInfoState>(outerContext, listen: false).getMessageKey(contactHandle, Provider.of<ContactInfoState>(outerContext).totalMessages - index, DateTime.now());
return FutureBuilder(
//key: Provider.of<ContactInfoState>(outerContext, listen: false).getMessageKey(contactHandle, Provider.of<ContactInfoState>(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<MessageList> {
])));
}
}
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();
}
}