diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt index 1ab53ec9..e8c737ad 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/FlwtchWorker.kt @@ -133,10 +133,10 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : notificationManager.notify(dlID, newNotification); } } catch (e: Exception) { - Log.i("FlwtchWorker->FileDownloadProgressUpdate", e.toString() + " :: " + e.getStackTrace()); + Log.d("FlwtchWorker->FileDownloadProgressUpdate", e.toString() + " :: " + e.getStackTrace()); } } else if (evt.EventType == "FileDownloaded") { - Log.i("FlwtchWorker", "file downloaded!"); + Log.d("FlwtchWorker", "file downloaded!"); val data = JSONObject(evt.Data); val tempFile = data.getString("TempFile"); val fileKey = data.getString("FileKey"); @@ -147,7 +147,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : val targetUri = Uri.parse(filePath); val os = this.applicationContext.getContentResolver().openOutputStream(targetUri); val bytesWritten = Files.copy(sourcePath, os); - Log.i("FlwtchWorker", "copied " + bytesWritten.toString() + " bytes"); + Log.d("FlwtchWorker", "copied " + bytesWritten.toString() + " bytes"); if (bytesWritten != 0L) { os?.flush(); os?.close(); @@ -184,7 +184,7 @@ class FlwtchWorker(context: Context, parameters: WorkerParameters) : val profile = (a.get("ProfileOnion") as? String) ?: "" val conversation = a.getInt("conversation").toLong() val indexI = a.getInt("index").toLong() - Log.i("FlwtchWorker", "Cwtch GetMessage " + profile + " " + conversation.toString() + " " + indexI.toString()) + Log.d("FlwtchWorker", "Cwtch GetMessage " + profile + " " + conversation.toString() + " " + indexI.toString()) return Result.success(Data.Builder().putString("result", Cwtch.getMessage(profile, conversation, indexI)).build()) } "GetMessageByID" -> { diff --git a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt index dec5f220..20940c89 100644 --- a/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt +++ b/android/app/src/main/kotlin/im/cwtch/flwtch/MainActivity.kt @@ -30,7 +30,6 @@ import android.os.Build import android.os.Environment import android.database.Cursor import android.provider.MediaStore -import cwtch.Cwtch class MainActivity: FlutterActivity() { override fun provideSplashScreen(): SplashScreen? = SplashView() @@ -148,11 +147,6 @@ class MainActivity: FlutterActivity() { // that we can divert this method call to ReconnectCwtchForeground instead if so. val works = WorkManager.getInstance(this).getWorkInfosByTag(WORKER_TAG).get() for (workInfo in works) { - Log.i("handleCwtch:WorkManager", "$workInfo") - if (!workInfo.tags.contains(uniqueTag)) { - Log.i("handleCwtch:WorkManager", "canceling ${workInfo.id} bc tags don't include $uniqueTag") - WorkManager.getInstance(this).cancelWorkById(workInfo.id) - } WorkManager.getInstance(this).cancelWorkById(workInfo.id) } WorkManager.getInstance(this).pruneWork() diff --git a/lib/cwtch/cwtchNotifier.dart b/lib/cwtch/cwtchNotifier.dart index aeae4aa2..d3c01c55 100644 --- a/lib/cwtch/cwtchNotifier.dart +++ b/lib/cwtch/cwtchNotifier.dart @@ -166,7 +166,7 @@ class CwtchNotifier { var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.getContact(conversation); // We return -1 for protocol message acks if there is no message if (messageID == -1) break; - var key = contact!.getMessageKeyOrFail(conversation, messageID, contact.lastMessageTime); + var key = contact!.getMessageKeyOrFail(conversation, messageID); if (key == null) break; try { var message = Provider.of(key.currentContext!, listen: false); @@ -217,7 +217,8 @@ class CwtchNotifier { notificationManager.notify("New Message From Group!"); } } else { - // This is not dealt with by IndexedAcknowledgment + // This is dealt with by IndexedAcknowledgment + EnvironmentConfig.debugLog("new message from group from yourself - this should not happen"); } break; case "SendMessageToPeerError": @@ -226,7 +227,7 @@ class CwtchNotifier { case "IndexedFailure": var contact = profileCN.getProfile(data["ProfileOnion"])?.contactList.findContact(data["RemotePeer"]); var idx = int.parse(data["Index"]); - var key = contact?.getMessageKeyOrFail(contact.identifier, idx, contact.lastMessageTime); + var key = contact?.getMessageKeyOrFail(contact.identifier, idx); if (key != null) { var message = Provider.of(key.currentContext!, listen: false); message.error = true; @@ -301,7 +302,6 @@ class CwtchNotifier { break; case "ServerStateChange": // Update the Server Cache - //EnvironmentConfig.debugLog("server state changes $data"); profileCN.getProfile(data["ProfileOnion"])?.updateServerStatusCache(data["GroupServer"], data["ConnectionState"]); profileCN.getProfile(data["ProfileOnion"])?.contactList.contacts.forEach((contact) { if (contact.isGroup == true && contact.server == data["GroupServer"]) { diff --git a/lib/model.dart b/lib/model.dart index 7633688a..87ac2f36 100644 --- a/lib/model.dart +++ b/lib/model.dart @@ -667,9 +667,8 @@ class ContactInfoState extends ChangeNotifier { } } - GlobalKey getMessageKey(int conversation, int message, DateTime lastread) { - String index = "c: " + conversation.toString() + " m:" + message.toString(); //+ " lr:" +lastMessageTime.toIso8601String(); - //EnvironmentConfig.debugLog("looked up key $index"); + GlobalKey getMessageKey(int conversation, int message) { + String index = "c: " + conversation.toString() + " m:" + message.toString(); if (keys[index] == null) { keys[index] = GlobalKey(); } @@ -677,8 +676,8 @@ class ContactInfoState extends ChangeNotifier { return ret; } - GlobalKey? getMessageKeyOrFail(int conversation, int message, DateTime lastread) { - String index = "c: " + conversation.toString() + " m:" + message.toString(); // + " lr:" +lastMessageTime.toIso8601String(); + GlobalKey? getMessageKeyOrFail(int conversation, int message) { + String index = "c: " + conversation.toString() + " m:" + message.toString(); if (keys[index] == null) { return null; diff --git a/lib/widgets/messagelist.dart b/lib/widgets/messagelist.dart index e090e3ac..365a75fc 100644 --- a/lib/widgets/messagelist.dart +++ b/lib/widgets/messagelist.dart @@ -84,7 +84,7 @@ class _MessageListState extends State { builder: (context, snapshot) { if (snapshot.hasData) { var message = snapshot.data as Message; - var key = Provider.of(outerContext, listen: false).getMessageKey(contactHandle, message.getMetadata().messageID, DateTime.now()); + var key = Provider.of(outerContext, listen: false).getMessageKey(contactHandle, message.getMetadata().messageID); return message.getWidget(context, key); } else { return MessageLoadingBubble();