mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 21:15:48 +00:00
Ensure default chat folder exists.
This commit is contained in:
@@ -129,6 +129,7 @@ import org.thoughtcrime.securesms.database.helpers.migration.V271_AddNotificatio
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V272_UpdateUnreadCountIndices
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V273_FixUnreadOriginalMessages
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V274_BackupMediaSnapshotLastSeenOnRemote
|
||||
import org.thoughtcrime.securesms.database.helpers.migration.V275_EnsureDefaultAllChatsFolder
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase as SignalSqliteDatabase
|
||||
|
||||
/**
|
||||
@@ -263,10 +264,11 @@ object SignalDatabaseMigrations {
|
||||
271 to V271_AddNotificationProfileIdColumn,
|
||||
272 to V272_UpdateUnreadCountIndices,
|
||||
273 to V273_FixUnreadOriginalMessages,
|
||||
274 to V274_BackupMediaSnapshotLastSeenOnRemote
|
||||
274 to V274_BackupMediaSnapshotLastSeenOnRemote,
|
||||
275 to V275_EnsureDefaultAllChatsFolder
|
||||
)
|
||||
|
||||
const val DATABASE_VERSION = 274
|
||||
const val DATABASE_VERSION = 275
|
||||
|
||||
@JvmStatic
|
||||
fun migrate(context: Application, db: SignalSqliteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.thoughtcrime.securesms.database.helpers.migration
|
||||
|
||||
import android.app.Application
|
||||
import org.thoughtcrime.securesms.database.ChatFolderTables
|
||||
import androidx.core.content.contentValuesOf
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase
|
||||
|
||||
/**
|
||||
@@ -42,6 +42,16 @@ object V253_CreateChatFolderTables : SignalDatabaseMigration {
|
||||
db.execSQL("CREATE INDEX chat_folder_membership_thread_id_index ON chat_folder_membership (thread_id)")
|
||||
db.execSQL("CREATE INDEX chat_folder_membership_membership_type_index ON chat_folder_membership (membership_type)")
|
||||
|
||||
ChatFolderTables.insertInitialChatFoldersAtCreationTime(db)
|
||||
db.insert(
|
||||
"chat_folder",
|
||||
null,
|
||||
contentValuesOf(
|
||||
"position" to 0,
|
||||
"folder_type" to 0,
|
||||
"show_individual" to 1,
|
||||
"show_groups" to 1,
|
||||
"show_muted" to 1
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2025 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.database.helpers.migration
|
||||
|
||||
import android.app.Application
|
||||
import org.signal.core.util.Base64
|
||||
import org.thoughtcrime.securesms.database.SQLiteDatabase
|
||||
import org.thoughtcrime.securesms.storage.StorageSyncHelper
|
||||
import java.util.UUID
|
||||
|
||||
/**
|
||||
* Ensures that there is a default 'All chat' within chat folders.
|
||||
*/
|
||||
object V275_EnsureDefaultAllChatsFolder : SignalDatabaseMigration {
|
||||
override fun migrate(context: Application, db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
|
||||
db.execSQL(
|
||||
"""
|
||||
INSERT INTO chat_folder(position, folder_type, show_individual, show_groups, show_muted, chat_folder_id, storage_service_id)
|
||||
SELECT '0', '0', '1', '1', '1', '${UUID.randomUUID()}', '${Base64.encodeWithPadding(StorageSyncHelper.generateKey())}'
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM chat_folder
|
||||
WHERE folder_type = 0
|
||||
LIMIT 1
|
||||
);
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.thoughtcrime.securesms.logsubmit
|
||||
|
||||
import android.content.Context
|
||||
import org.thoughtcrime.securesms.components.settings.app.chats.folders.ChatFolderRecord
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
/**
|
||||
* Prints out chat folders settings
|
||||
*/
|
||||
class LogSectionChatFolders : LogSection {
|
||||
override fun getTitle(): String = "CHAT FOLDERS"
|
||||
|
||||
override fun getContent(context: Context): CharSequence {
|
||||
val output = StringBuilder()
|
||||
|
||||
if (Recipient.isSelfSet) {
|
||||
val count = SignalDatabase.chatFolders.getFolderCount()
|
||||
val hasDefault = SignalDatabase.chatFolders.getCurrentChatFolders().any { folder -> folder.folderType == ChatFolderRecord.FolderType.ALL }
|
||||
output.append("Has default all chats : ${hasDefault}\n")
|
||||
output.append("Number of folders (undeleted) : ${count}\n")
|
||||
} else {
|
||||
output.append("< Self is not set yet >\n")
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,7 @@ public class SubmitDebugLogRepository {
|
||||
add(new LogSectionKeyPreferences());
|
||||
add(new LogSectionStories());
|
||||
add(new LogSectionBadges());
|
||||
add(new LogSectionChatFolders());
|
||||
add(new LogSectionRemoteBackups());
|
||||
add(new LogSectionPermissions());
|
||||
add(new LogSectionTrace());
|
||||
|
||||
Reference in New Issue
Block a user