From f91fc2503ba3accf77a5f8937ba7a20b1d396672 Mon Sep 17 00:00:00 2001 From: 0x330a <92654767+0x330a@users.noreply.github.com> Date: Tue, 23 May 2023 14:56:37 +1000 Subject: [PATCH] fix: nts threads --- .../conversation/v2/ConversationActivityV2.kt | 4 ---- .../org/thoughtcrime/securesms/database/Storage.kt | 14 +++++++++++++- .../securesms/database/ThreadDatabase.java | 1 + gradle.properties | 2 +- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 49a1a033fa..fe5d41af11 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -248,10 +248,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe // assume created thread if (recipient.isContactRecipient && !recipient.isLocalNumber) { storage.setRecipientApproved(recipient, true) // assume approved when we CREATE the thread, not send first message - } else if (recipient.isLocalNumber) { - // this gets around the filtering of unapproved / unsent threads - // since the sql query would have to take into account whether address == local user address - threadDb.setHasSent(threadId, true) } } } ?: finish() diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt index 7d3b0a672a..0f944ede72 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -5,6 +5,7 @@ import android.net.Uri import network.loki.messenger.libsession_util.ConfigBase import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_HIDDEN import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_PINNED +import network.loki.messenger.libsession_util.ConfigBase.Companion.PRIORITY_VISIBLE import network.loki.messenger.libsession_util.Contacts import network.loki.messenger.libsession_util.ConversationVolatileConfig import network.loki.messenger.libsession_util.UserGroupsConfig @@ -95,7 +96,18 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co ThreadDatabase.ConversationThreadUpdateListener { override fun threadCreated(address: Address, threadId: Long) { - if (!getRecipientApproved(address)) return // don't store unapproved / message requests + val localUserAddress = getUserPublicKey() ?: return + if (!getRecipientApproved(address) && localUserAddress != address.serialize()) return // don't store unapproved / message requests + + if (localUserAddress == address.serialize()) { + val userConfig = configFactory.user ?: return + if (userConfig.getNtsPriority() == PRIORITY_HIDDEN) { + // if it's hidden set it visible, otherwise it's pinned so don't change + userConfig.setNtsPriority(PRIORITY_VISIBLE) + DatabaseComponent.get(context).threadDatabase().setHasSent(threadId, true) + } + return + } val volatile = configFactory.convoVolatile ?: return if (address.isGroup) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java index b8f90bd14d..68b496fb5e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java @@ -728,6 +728,7 @@ public class ThreadDatabase extends Database { new String[] {String.valueOf(threadId)}); notifyConversationListeners(threadId); + notifyConversationListListeners(); } public boolean update(long threadId, boolean unarchive, boolean shouldDeleteOnEmpty) { diff --git a/gradle.properties b/gradle.properties index 928c64b38b..2f7c70b81f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ android.useAndroidX=true android.enableJetifier=true -org.gradle.jvmargs=-Xmx8g +org.gradle.jvmargs=-Xmx4g gradlePluginVersion=7.3.1 googleServicesVersion=4.3.12