|
|
|
@ -58,7 +58,14 @@ class CwtchNotifier {
|
|
|
|
|
// EnvironmentConfig.debugLog("NewEvent $type $data");
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "CwtchStarted":
|
|
|
|
|
flwtchState.cwtch.LoadProfiles(DefaultPassword);
|
|
|
|
|
if (data["Reload"] == "true" && profileCN.num > 0 ) {
|
|
|
|
|
// don't reload...
|
|
|
|
|
// unless we have loaded no profiles...then there isnt a risk and this
|
|
|
|
|
// might be a first time (e.g. new apk, existing service)
|
|
|
|
|
} else {
|
|
|
|
|
EnvironmentConfig.debugLog("Reloading....${data}");
|
|
|
|
|
flwtchState.cwtch.LoadProfiles(DefaultPassword);
|
|
|
|
|
}
|
|
|
|
|
appState.SetCwtchInit();
|
|
|
|
|
break;
|
|
|
|
|
case "CwtchStartError":
|
|
|
|
@ -188,21 +195,9 @@ class CwtchNotifier {
|
|
|
|
|
var senderImage = data['picture'];
|
|
|
|
|
var isAuto = data['Auto'] == "true";
|
|
|
|
|
String contenthash = data['ContentHash'];
|
|
|
|
|
|
|
|
|
|
var selectedProfile = appState.selectedProfile == data["ProfileOnion"];
|
|
|
|
|
var selectedConversation = selectedProfile && appState.selectedConversation == identifier;
|
|
|
|
|
var notification = data["notification"];
|
|
|
|
|
|
|
|
|
|
if (selectedConversation && seenMessageCallback != null) {
|
|
|
|
|
seenMessageCallback!(data["ProfileOnion"]!, identifier, DateTime.now().toUtc());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (notification == "SimpleEvent") {
|
|
|
|
|
notificationManager.notify(notificationSimple ?? "New Message", "", 0);
|
|
|
|
|
} else if (notification == "ContactInfo") {
|
|
|
|
|
var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier);
|
|
|
|
|
notificationManager.notify((notificationConversationInfo ?? "New Message from %1").replaceFirst("%1", (contact?.nickname ?? senderHandle.toString())), data["ProfileOnion"], identifier);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
profileCN.getProfile(data["ProfileOnion"])?.newMessage(
|
|
|
|
|
identifier,
|
|
|
|
|
messageID,
|
|
|
|
@ -215,6 +210,19 @@ class CwtchNotifier {
|
|
|
|
|
selectedProfile,
|
|
|
|
|
selectedConversation,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Now perform the notification logic...
|
|
|
|
|
var notification = data["notification"];
|
|
|
|
|
if (selectedConversation && seenMessageCallback != null) {
|
|
|
|
|
seenMessageCallback!(data["ProfileOnion"]!, identifier, DateTime.now().toUtc());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (notification == "SimpleEvent") {
|
|
|
|
|
notificationManager.notify(notificationSimple ?? "New Message", "", 0);
|
|
|
|
|
} else if (notification == "ContactInfo") {
|
|
|
|
|
var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(identifier);
|
|
|
|
|
notificationManager.notify((notificationConversationInfo ?? "New Message from %1").replaceFirst("%1", (contact?.nickname ?? senderHandle.toString())), data["ProfileOnion"], identifier);
|
|
|
|
|
}
|
|
|
|
|
appState.notifyProfileUnread();
|
|
|
|
|
break;
|
|
|
|
|
case "PeerAcknowledgement":
|
|
|
|
|