add notifyListen to newMessage in contact; format
continuous-integration/drone/pr Build is pending
Details
continuous-integration/drone/pr Build is pending
Details
This commit is contained in:
parent
589bc4c36c
commit
889d398343
|
@ -146,7 +146,17 @@ class CwtchNotifier {
|
|||
String? contenthash = data['ContentHash'];
|
||||
var selectedConversation = appState.selectedProfile == data["ProfileOnion"] && appState.selectedConversation == identifier;
|
||||
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.newMessage(identifier, messageID, timestamp, senderHandle, senderImage, isAuto, data["Data"], contenthash, selectedConversation, );
|
||||
profileCN.getProfile(data["ProfileOnion"])?.contactList.newMessage(
|
||||
identifier,
|
||||
messageID,
|
||||
timestamp,
|
||||
senderHandle,
|
||||
senderImage,
|
||||
isAuto,
|
||||
data["Data"],
|
||||
contenthash,
|
||||
selectedConversation,
|
||||
);
|
||||
|
||||
break;
|
||||
case "PeerAcknowledgement":
|
||||
|
@ -188,7 +198,6 @@ class CwtchNotifier {
|
|||
String? contenthash = data['ContentHash'];
|
||||
var selectedConversation = appState.selectedProfile == data["ProfileOnion"] && appState.selectedConversation == identifier;
|
||||
|
||||
|
||||
// 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) {
|
||||
// TODO: There are 2 timestamps associated with a new group message - time sent and time received.
|
||||
|
|
|
@ -68,4 +68,4 @@ class AppState extends ChangeNotifier {
|
|||
}
|
||||
|
||||
bool isLandscape(BuildContext c) => MediaQuery.of(c).size.width > MediaQuery.of(c).size.height;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,6 +220,7 @@ class ContactInfoState extends ChangeNotifier {
|
|||
if (isOnline() == false) {
|
||||
status = "Authenticated";
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void ackCache(int messageID) {
|
||||
|
|
|
@ -127,4 +127,4 @@ class ContactListState extends ChangeNotifier {
|
|||
getContact(identifier)?.newMessage(identifier, messageID, timestamp, senderHandle, senderImage, isAuto, data, contenthash, selectedConversation);
|
||||
updateLastMessageTime(identifier, DateTime.now());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,14 +74,14 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, int co
|
|||
}
|
||||
|
||||
// Hit cache
|
||||
MessageInfo? messageInfo = getMessageInfoFromCache(context, profileOnion, conversationIdentifier, byIndex: byIndex, index: index, byID: byID, id: id, byHash: byHash, hash: hash);
|
||||
MessageInfo? messageInfo = getMessageInfoFromCache(context, profileOnion, conversationIdentifier, byIndex: byIndex, index: index, byID: byID, id: id, byHash: byHash, hash: hash);
|
||||
if (messageInfo != null) {
|
||||
return Future.value(compileOverlay(messageInfo.metadata, messageInfo.wrapper));
|
||||
}
|
||||
|
||||
// Fetch and Cache
|
||||
var messageInfoFuture = fetchAndCacheMessageInfo(context, profileOnion, conversationIdentifier, byIndex: byIndex, index: index, byID: byID, id: id, byHash: byHash, hash: hash);
|
||||
return messageInfoFuture.then( (MessageInfo? messageInfo) {
|
||||
var messageInfoFuture = fetchAndCacheMessageInfo(context, profileOnion, conversationIdentifier, byIndex: byIndex, index: index, byID: byID, id: id, byHash: byHash, hash: hash);
|
||||
return messageInfoFuture.then((MessageInfo? messageInfo) {
|
||||
if (messageInfo != null) {
|
||||
return compileOverlay(messageInfo.metadata, messageInfo.wrapper);
|
||||
} else {
|
||||
|
@ -91,7 +91,7 @@ Future<Message> messageHandler(BuildContext context, String profileOnion, int co
|
|||
}
|
||||
|
||||
MessageInfo? getMessageInfoFromCache(BuildContext context, String profileOnion, int conversationIdentifier,
|
||||
{bool byIndex = false, int? index, bool byID = false, int? id, bool byHash = false, String? hash}) {
|
||||
{bool byIndex = false, int? index, bool byID = false, int? id, bool byHash = false, String? hash}) {
|
||||
// Hit cache
|
||||
try {
|
||||
var cache = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(conversationIdentifier)?.messageCache;
|
||||
|
@ -116,26 +116,17 @@ MessageInfo? getMessageInfoFromCache(BuildContext context, String profileOnion,
|
|||
}
|
||||
|
||||
Future<MessageInfo?> fetchAndCacheMessageInfo(BuildContext context, String profileOnion, int conversationIdentifier,
|
||||
{bool byIndex = false, int? index, bool byID = false, int? id, bool byHash = false, String? hash}) {
|
||||
{bool byIndex = false, int? index, bool byID = false, int? id, bool byHash = false, String? hash}) {
|
||||
// Load and cache
|
||||
try {
|
||||
Future<dynamic> rawMessageEnvelopeFuture;
|
||||
|
||||
if (byID) {
|
||||
rawMessageEnvelopeFuture = Provider
|
||||
.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.GetMessageByID(profileOnion, conversationIdentifier, id!);
|
||||
rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessageByID(profileOnion, conversationIdentifier, id!);
|
||||
} else if (byHash) {
|
||||
rawMessageEnvelopeFuture = Provider
|
||||
.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.GetMessageByContentHash(profileOnion, conversationIdentifier, hash!);
|
||||
rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessageByContentHash(profileOnion, conversationIdentifier, hash!);
|
||||
} else {
|
||||
rawMessageEnvelopeFuture = Provider
|
||||
.of<FlwtchState>(context, listen: false)
|
||||
.cwtch
|
||||
.GetMessage(profileOnion, conversationIdentifier, index!);
|
||||
rawMessageEnvelopeFuture = Provider.of<FlwtchState>(context, listen: false).cwtch.GetMessage(profileOnion, conversationIdentifier, index!);
|
||||
}
|
||||
|
||||
return rawMessageEnvelopeFuture.then((dynamic rawMessageEnvelope) {
|
||||
|
@ -153,12 +144,7 @@ Future<MessageInfo?> fetchAndCacheMessageInfo(BuildContext context, String profi
|
|||
if (messageWrapper['Message'] == null || messageWrapper['Message'] == '' || messageWrapper['Message'] == '{}') {
|
||||
return Future.delayed(Duration(seconds: 2), () {
|
||||
print("Tail recursive call to messageHandler called. This should be a rare event. If you see multiples of this log over a short period of time please log it as a bug.");
|
||||
return fetchAndCacheMessageInfo(context, profileOnion, conversationIdentifier, byIndex: byIndex,
|
||||
index: index,
|
||||
byID: byID,
|
||||
id: id,
|
||||
byHash: byHash,
|
||||
hash: hash).then((value) => value);
|
||||
return fetchAndCacheMessageInfo(context, profileOnion, conversationIdentifier, byIndex: byIndex, index: index, byID: byID, id: id, byHash: byHash, hash: hash).then((value) => value);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -173,25 +159,10 @@ Future<MessageInfo?> fetchAndCacheMessageInfo(BuildContext context, String profi
|
|||
var signature = messageWrapper['Signature'];
|
||||
var contenthash = messageWrapper['ContentHash'];
|
||||
var localIndex = messageWrapper['LocalIndex'];
|
||||
var metadata = MessageMetadata(
|
||||
profileOnion,
|
||||
conversationIdentifier,
|
||||
messageID,
|
||||
timestamp,
|
||||
senderHandle,
|
||||
senderImage,
|
||||
signature,
|
||||
attributes,
|
||||
ackd,
|
||||
error,
|
||||
false);
|
||||
var metadata = MessageMetadata(profileOnion, conversationIdentifier, messageID, timestamp, senderHandle, senderImage, signature, attributes, ackd, error, false);
|
||||
var messageInfo = new MessageInfo(metadata, messageWrapper['Message']);
|
||||
|
||||
var cache = Provider
|
||||
.of<ProfileInfoState>(context, listen: false)
|
||||
.contactList
|
||||
.getContact(conversationIdentifier)
|
||||
?.messageCache;
|
||||
var cache = Provider.of<ProfileInfoState>(context, listen: false).contactList.getContact(conversationIdentifier)?.messageCache;
|
||||
|
||||
if (cache != null) {
|
||||
if (byID) {
|
||||
|
|
|
@ -26,6 +26,7 @@ class MessageCache {
|
|||
}
|
||||
return cache[cacheByIndex[index]];
|
||||
}
|
||||
|
||||
MessageInfo? getByContentHash(String contenthash) => cache[cacheByHash[contenthash]];
|
||||
|
||||
void addNew(String profileOnion, int conversation, int messageID, DateTime timestamp, String senderHandle, String senderImage, bool isAuto, String data, String? contenthash) {
|
||||
|
@ -54,4 +55,4 @@ class MessageCache {
|
|||
void ackCache(int messageID) {
|
||||
cache[messageID]?.metadata.ackd = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,8 +59,7 @@ class QuotedMessage extends Message {
|
|||
return ChangeNotifierProvider.value(
|
||||
value: this.metadata,
|
||||
builder: (bcontext, child) {
|
||||
return MessageRow(
|
||||
QuotedMessageBubble(message["body"], messageHandler(bcontext, metadata.profileOnion, metadata.conversationIdentifier, byHash: true, hash: message["quotedHash"])),
|
||||
return MessageRow(QuotedMessageBubble(message["body"], messageHandler(bcontext, metadata.profileOnion, metadata.conversationIdentifier, byHash: true, hash: message["quotedHash"])),
|
||||
key: key);
|
||||
});
|
||||
} catch (e) {
|
||||
|
|
|
@ -284,8 +284,8 @@ class _MessageViewState extends State<MessageView> {
|
|||
var children;
|
||||
if (Provider.of<AppState>(context).selectedConversation != null && Provider.of<AppState>(context).selectedIndex != null) {
|
||||
var quoted = FutureBuilder(
|
||||
future:
|
||||
messageHandler(context, Provider.of<AppState>(context).selectedProfile!, Provider.of<AppState>(context).selectedConversation!, id: Provider.of<AppState>(context).selectedIndex!, byID: true),
|
||||
future: messageHandler(context, Provider.of<AppState>(context).selectedProfile!, Provider.of<AppState>(context).selectedConversation!,
|
||||
id: Provider.of<AppState>(context).selectedIndex!, byID: true),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
var message = snapshot.data! as Message;
|
||||
|
|
Loading…
Reference in New Issue