diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt index 9f14c3b6a8..7071c84e0e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/expiration/ExpirationSettingsViewModel.kt @@ -51,6 +51,8 @@ class ExpirationSettingsViewModel( showExpirationTypeSelector = recipient?.isContactRecipient == true && recipient.isLocalNumber == false if (recipient?.isLocalNumber == true || recipient?.isClosedGroupRecipient == true) { _selectedExpirationType.value = ExpirationType.DELETE_AFTER_SEND + } else { + _selectedExpirationType.value = expirationConfig?.expirationType } _selectedExpirationTimer.value = when(expirationConfig?.expirationType) { ExpirationType.DELETE_AFTER_SEND -> afterSendOptions.find { it.value.toIntOrNull() == expirationConfig?.durationSeconds } 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 bf28d663b1..61e2268fd0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/database/Storage.kt @@ -967,7 +967,9 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context, threadDb.readerFor(threadDb.conversationList).use { reader -> while (reader.next != null) { val thread = reader.current - if (thread.recipient.isClosedGroupRecipient || thread.recipient.isContactRecipient) { + if (thread.threadId == threadId && + (thread.recipient.isClosedGroupRecipient || thread.recipient.isContactRecipient) + ) { return ExpirationConfiguration( thread.threadId, thread.expiresIn.toInt(), 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 dfc8e4059e..a6b89f3e82 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java +++ b/app/src/main/java/org/thoughtcrime/securesms/database/ThreadDatabase.java @@ -159,11 +159,14 @@ public class ThreadDatabase extends Database { } public static String getUpdateOneToOneConversationExpiryTypeCommand() { - return "UPDATE " + TABLE_NAME + " SET " + EXPIRY_TYPE + " = 2 " + + return "UPDATE " + TABLE_NAME + " SET " + EXPIRY_TYPE + " = 2, " + + EXPIRES_IN + " = (SELECT " + RecipientDatabase.EXPIRE_MESSAGES + " FROM " + RecipientDatabase.TABLE_NAME + + " WHERE " + TABLE_NAME + "." + ADDRESS + " = " + RecipientDatabase.TABLE_NAME + "." + RecipientDatabase.ADDRESS + " AND " + RecipientDatabase.EXPIRE_MESSAGES + " > 0 )" + "WHERE " + ADDRESS + " NOT LIKE '" + CLOSED_GROUP_PREFIX + "%'" + "AND " + ADDRESS + " NOT LIKE '" + OPEN_GROUP_PREFIX + "%'" + "AND " + ADDRESS + " NOT LIKE '" + OPEN_GROUP_INBOX_PREFIX + "%'" + - "AND " + EXPIRES_IN + " > 0"; + "AND EXISTS (SELECT " + RecipientDatabase.EXPIRE_MESSAGES + " FROM " + RecipientDatabase.TABLE_NAME + + " WHERE " + TABLE_NAME + "." + ADDRESS + " = " + RecipientDatabase.TABLE_NAME + "." + RecipientDatabase.ADDRESS + " AND " + RecipientDatabase.EXPIRE_MESSAGES + " > 0 )"; } public ThreadDatabase(Context context, SQLCipherOpenHelper databaseHelper) {