mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
One to one migration refactor
This commit is contained in:
parent
24a020b99f
commit
962e648bb8
@ -51,6 +51,8 @@ class ExpirationSettingsViewModel(
|
|||||||
showExpirationTypeSelector = recipient?.isContactRecipient == true && recipient.isLocalNumber == false
|
showExpirationTypeSelector = recipient?.isContactRecipient == true && recipient.isLocalNumber == false
|
||||||
if (recipient?.isLocalNumber == true || recipient?.isClosedGroupRecipient == true) {
|
if (recipient?.isLocalNumber == true || recipient?.isClosedGroupRecipient == true) {
|
||||||
_selectedExpirationType.value = ExpirationType.DELETE_AFTER_SEND
|
_selectedExpirationType.value = ExpirationType.DELETE_AFTER_SEND
|
||||||
|
} else {
|
||||||
|
_selectedExpirationType.value = expirationConfig?.expirationType
|
||||||
}
|
}
|
||||||
_selectedExpirationTimer.value = when(expirationConfig?.expirationType) {
|
_selectedExpirationTimer.value = when(expirationConfig?.expirationType) {
|
||||||
ExpirationType.DELETE_AFTER_SEND -> afterSendOptions.find { it.value.toIntOrNull() == expirationConfig?.durationSeconds }
|
ExpirationType.DELETE_AFTER_SEND -> afterSendOptions.find { it.value.toIntOrNull() == expirationConfig?.durationSeconds }
|
||||||
|
@ -967,7 +967,9 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
|||||||
threadDb.readerFor(threadDb.conversationList).use { reader ->
|
threadDb.readerFor(threadDb.conversationList).use { reader ->
|
||||||
while (reader.next != null) {
|
while (reader.next != null) {
|
||||||
val thread = reader.current
|
val thread = reader.current
|
||||||
if (thread.recipient.isClosedGroupRecipient || thread.recipient.isContactRecipient) {
|
if (thread.threadId == threadId &&
|
||||||
|
(thread.recipient.isClosedGroupRecipient || thread.recipient.isContactRecipient)
|
||||||
|
) {
|
||||||
return ExpirationConfiguration(
|
return ExpirationConfiguration(
|
||||||
thread.threadId,
|
thread.threadId,
|
||||||
thread.expiresIn.toInt(),
|
thread.expiresIn.toInt(),
|
||||||
|
@ -159,11 +159,14 @@ public class ThreadDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getUpdateOneToOneConversationExpiryTypeCommand() {
|
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 + "%'" +
|
"WHERE " + ADDRESS + " NOT LIKE '" + CLOSED_GROUP_PREFIX + "%'" +
|
||||||
"AND " + ADDRESS + " NOT LIKE '" + OPEN_GROUP_PREFIX + "%'" +
|
"AND " + ADDRESS + " NOT LIKE '" + OPEN_GROUP_PREFIX + "%'" +
|
||||||
"AND " + ADDRESS + " NOT LIKE '" + OPEN_GROUP_INBOX_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) {
|
public ThreadDatabase(Context context, SQLCipherOpenHelper databaseHelper) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user