mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 17:29:32 +01:00
Fix chat folder to not show mute option if there isn't any chat.
This commit is contained in:
committed by
Cody Henthorne
parent
cf0dfdceb1
commit
a66031cfce
@@ -236,12 +236,13 @@ class ChatFolderTables(context: Context?, databaseHelper: SignalDatabase?) : Dat
|
||||
/**
|
||||
* Given a list of folders, maps a folder id to the folder's unread count and whether all the chats in the folder are muted
|
||||
*/
|
||||
fun getUnreadCountAndMutedStatusForFolders(folders: List<ChatFolderRecord>): HashMap<Long, Pair<Int, Boolean>> {
|
||||
val map: HashMap<Long, Pair<Int, Boolean>> = hashMapOf()
|
||||
fun getUnreadCountAndEmptyAndMutedStatusForFolders(folders: List<ChatFolderRecord>): HashMap<Long, Triple<Int, Boolean, Boolean>> {
|
||||
val map: HashMap<Long, Triple<Int, Boolean, Boolean>> = hashMapOf()
|
||||
folders.map { folder ->
|
||||
val unreadCount = SignalDatabase.threads.getUnreadCountByChatFolder(folder)
|
||||
val isEmpty = !SignalDatabase.threads.hasChatInFolder(folder)
|
||||
val isMuted = !SignalDatabase.threads.hasUnmutedChatsInFolder(folder)
|
||||
map[folder.id] = Pair(unreadCount, isMuted)
|
||||
map[folder.id] = Triple(unreadCount, isEmpty, isMuted)
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
@@ -650,6 +650,28 @@ class ThreadTable(context: Context, databaseHelper: SignalDatabase) : DatabaseTa
|
||||
return allCount + forcedUnreadCount
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not there are chats in a chat folder
|
||||
*/
|
||||
fun hasChatInFolder(folder: ChatFolderRecord): Boolean {
|
||||
val chatFolderQuery = folder.toQuery()
|
||||
|
||||
val hasChats =
|
||||
"""
|
||||
SELECT EXISTS(
|
||||
SELECT 1
|
||||
FROM $TABLE_NAME
|
||||
LEFT OUTER JOIN ${RecipientTable.TABLE_NAME} ON $TABLE_NAME.$RECIPIENT_ID = ${RecipientTable.TABLE_NAME}.${RecipientTable.ID}
|
||||
WHERE
|
||||
$ARCHIVED = 0
|
||||
$chatFolderQuery
|
||||
LIMIT 1
|
||||
)
|
||||
"""
|
||||
|
||||
return readableDatabase.rawQuery(hasChats, null).readToSingleBoolean()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not there are any unmuted chats in a chat folder
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user