Sort "new group story" entries by recency.

This commit is contained in:
Alex Hart
2022-08-16 16:59:37 -03:00
committed by Cody Henthorne
parent 28310a88f5
commit e517232172
5 changed files with 116 additions and 6 deletions

View File

@@ -63,6 +63,7 @@ class ContactSearchConfiguration private constructor(
val includeV1: Boolean = false,
val includeInactive: Boolean = false,
val returnAsGroupStories: Boolean = false,
val sortOrder: ContactSearchSortOrder = ContactSearchSortOrder.NATURAL,
override val includeHeader: Boolean,
override val expandConfig: ExpandConfig? = null
) : Section(SectionKey.GROUPS)

View File

@@ -41,8 +41,19 @@ open class ContactSearchPagedDataSourceRepository(
return contactRepository.queryNonGroupContacts(query ?: "", includeSelf)
}
open fun getGroupContacts(section: ContactSearchConfiguration.Section.Groups, query: String?): Cursor? {
return SignalDatabase.groups.queryGroupsByTitle(query ?: "", section.includeInactive, !section.includeV1, !section.includeMms).cursor
open fun getGroupContacts(
section: ContactSearchConfiguration.Section.Groups,
query: String?
): Cursor? {
return SignalDatabase.groups.queryGroups(
GroupDatabase.GroupQuery.Builder()
.withSearchQuery(query)
.withInactiveGroups(section.includeInactive)
.withMmsGroups(section.includeMms)
.withV1Groups(section.includeV1)
.withSortOrder(section.sortOrder)
.build()
).cursor
}
open fun getRecents(section: ContactSearchConfiguration.Section.Recents): Cursor? {

View File

@@ -0,0 +1,19 @@
package org.thoughtcrime.securesms.contacts.paged
/**
* Different options for sort order of contact search items.
*/
enum class ContactSearchSortOrder {
/**
* The "natural" expected order. This is considered the default ordering.
* For example, Groups would normally be ordered by title from A-Z.
*/
NATURAL,
/**
* The requested ordering is by recency. This can mean different things for
* different contact types. For example, for Groups, this entry means that
* the results are ordered by latest message date in descending order.
*/
RECENCY
}