Remove empty recycle bin menu item if there are no recycle bin conversations

This commit is contained in:
Ensar Sarajčić 2023-07-20 14:18:24 +02:00
parent 372dbaeaa4
commit 31be5d3d95
2 changed files with 8 additions and 1 deletions

View File

@ -58,6 +58,12 @@ class RecycleBinConversationsActivity : SimpleActivity() {
}
}
private fun updateOptionsMenu(conversations: ArrayList<Conversation>) {
recycle_bin_toolbar.menu.apply {
findItem(R.id.empty_recycle_bin).isVisible = conversations.isNotEmpty()
}
}
private fun updateMenuColors() {
updateStatusbarColor(getProperBackgroundColor())
}
@ -117,6 +123,7 @@ class RecycleBinConversationsActivity : SimpleActivity() {
).toMutableList() as ArrayList<Conversation>
showOrHidePlaceholder(conversations.isEmpty())
updateOptionsMenu(conversations)
try {
getOrCreateConversationsAdapter().apply {

View File

@ -118,7 +118,7 @@ abstract class MessagesDatabase : RoomDatabase() {
override fun migrate(database: SupportSQLiteDatabase) {
database.apply {
execSQL("ALTER TABLE conversations ADD COLUMN archived INTEGER NOT NULL DEFAULT 0")
execSQL("CREATE TABLE IF NOT EXISTS `recycle_bin_messages` (`id` INTEGER PRIMARY KEY, `deleted_ts` INTEGER NOT NULL)")
execSQL("CREATE TABLE IF NOT EXISTS `recycle_bin_messages` (`id` INTEGER NOT NULL PRIMARY KEY, `deleted_ts` INTEGER NOT NULL)")
execSQL("CREATE UNIQUE INDEX IF NOT EXISTS `index_recycle_bin_messages_id` ON `recycle_bin_messages` (`id`)")
}
}