Add default chat folders in backups.

This commit is contained in:
Michelle Tang 2024-10-23 11:41:01 -07:00 committed by Greyson Parrelli
parent 1ff6169795
commit 9a0ebb5028
2 changed files with 12 additions and 0 deletions

View file

@ -487,6 +487,9 @@ object BackupRepository {
SignalDatabase.recipients.setProfileKey(selfId, selfData.profileKey)
SignalDatabase.recipients.setProfileSharing(selfId, true)
// Add back default All Chats chat folder after clearing data
SignalDatabase.chatFolders.insertAllChatFolder()
val importState = ImportState(backupKey)
val chatItemInserter: ChatItemArchiveImporter = ChatItemArchiveProcessor.beginImport(importState)

View file

@ -395,6 +395,15 @@ class ChatFolderTables(context: Context?, databaseHelper: SignalDatabase?) : Dat
}
}
/**
* Inserts the default 'All chats' folder in cases where it could get deleted (eg backups)
*/
fun insertAllChatFolder() {
writableDatabase.withinTransaction { db ->
db.insert(ChatFolderTable.TABLE_NAME, null, getAllChatsFolderContentValues())
}
}
private fun Collection<Long>.toContentValues(chatFolderId: Long, membershipType: MembershipType): List<ContentValues> {
return map {
contentValuesOf(