mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 04:58:45 +00:00
Fix unreads for new unread count scheme.
This commit is contained in:
@@ -127,6 +127,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V269_BackupMediaSna
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V270_FixChatFolderColumnsForStorageSync
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V271_AddNotificationProfileIdColumn
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V272_UpdateUnreadCountIndices
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V273_FixUnreadOriginalMessages
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase as SignalSqliteDatabase
|
||||
|
||||
/**
|
||||
@@ -259,10 +260,11 @@ object SignalDatabaseMigrations {
|
||||
269 to V269_BackupMediaSnapshotChanges,
|
||||
270 to V270_FixChatFolderColumnsForStorageSync,
|
||||
271 to V271_AddNotificationProfileIdColumn,
|
||||
272 to V272_UpdateUnreadCountIndices
|
||||
272 to V272_UpdateUnreadCountIndices,
|
||||
273 to V273_FixUnreadOriginalMessages
|
||||
)
|
||||
|
||||
const val DATABASE_VERSION = 272
|
||||
const val DATABASE_VERSION = 273
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SignalSqliteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.database.helpers.migration
|
||||
|
||||
import android.app.Application
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase
|
||||
|
||||
/**
|
||||
* Updates read status for unread original messages to work with new unread count scheme.
|
||||
*/
|
||||
@Suppress("ClassName")
|
||||
object V273_FixUnreadOriginalMessages : SignalDatabaseMigration {
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
db.execSQL(
|
||||
"""
|
||||
UPDATE message
|
||||
SET read = 1
|
||||
WHERE original_message_id IS NULL AND read = 0 AND _id IN (
|
||||
SELECT DISTINCT original_message_id
|
||||
FROM message INDEXED BY message_original_message_id_index
|
||||
WHERE read = 1 AND original_message_id NOT NULL
|
||||
)"""
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user