Add viewer count and list to 'All Signal Connections'.

This commit is contained in:
Alex Hart
2022-10-07 09:40:10 -03:00
committed by Greyson Parrelli
parent c239ba1e35
commit 842626e96c
20 changed files with 408 additions and 27 deletions

View File

@@ -3112,6 +3112,44 @@ open class RecipientDatabase(context: Context, databaseHelper: SignalDatabase) :
return readableDatabase.query(TABLE_NAME, SEARCH_PROJECTION, selection, args, null, null, orderBy)
}
fun querySignalContactLetterHeaders(inputQuery: String, includeSelf: Boolean): Map<RecipientId, String> {
val searchSelection = ContactSearchSelection.Builder()
.withRegistered(true)
.withGroups(false)
.excludeId(if (includeSelf) null else Recipient.self().id)
.withSearchQuery(inputQuery)
.build()
return readableDatabase.query(
"""
SELECT
_id,
UPPER(SUBSTR($SORT_NAME, 0, 2)) AS letter_header
FROM (
SELECT ${SEARCH_PROJECTION.joinToString(", ")}
FROM recipient
WHERE ${searchSelection.where}
ORDER BY $SORT_NAME, $SYSTEM_JOINED_NAME, $SEARCH_PROFILE_NAME, $PHONE
)
GROUP BY letter_header
""".trimIndent(),
searchSelection.args
).use { cursor ->
if (cursor.count == 0) {
emptyMap()
} else {
val resultsMap = mutableMapOf<RecipientId, String>()
while (cursor.moveToNext()) {
cursor.requireString("letter_header")?.let {
resultsMap[RecipientId.from(cursor.requireLong(ID))] = it
}
}
resultsMap
}
}
}
fun getNonSignalContacts(): Cursor? {
val searchSelection = ContactSearchSelection.Builder().withNonRegistered(true)
.withGroups(false)