mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-21 09:20:19 +01:00
Add "You can pull to filter" tip.
This commit is contained in:
committed by
Greyson Parrelli
parent
43fe789807
commit
296a113c65
@@ -80,10 +80,10 @@ public class SearchRepository {
|
||||
this.serialExecutor = new SerialExecutor(SignalExecutors.BOUNDED);
|
||||
}
|
||||
|
||||
public void queryThreads(@NonNull String query, @NonNull Consumer<ThreadSearchResult> callback) {
|
||||
public void queryThreads(@NonNull String query, boolean unreadOnly, @NonNull Consumer<ThreadSearchResult> callback) {
|
||||
searchExecutor.execute(2, () -> {
|
||||
long start = System.currentTimeMillis();
|
||||
List<ThreadRecord> result = queryConversations(query);
|
||||
List<ThreadRecord> result = queryConversations(query, unreadOnly);
|
||||
|
||||
Log.d(TAG, "[threads] Search took " + (System.currentTimeMillis() - start) + " ms");
|
||||
|
||||
@@ -155,7 +155,7 @@ public class SearchRepository {
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull List<ThreadRecord> queryConversations(@NonNull String query) {
|
||||
private @NonNull List<ThreadRecord> queryConversations(@NonNull String query, boolean unreadOnly) {
|
||||
if (Util.isEmpty(query)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -192,15 +192,15 @@ public class SearchRepository {
|
||||
|
||||
List<ThreadRecord> output = new ArrayList<>(contactIds.size() + groupsByTitleIds.size() + groupsByMemberIds.size());
|
||||
|
||||
output.addAll(getMatchingThreads(contactIds));
|
||||
output.addAll(getMatchingThreads(groupsByTitleIds));
|
||||
output.addAll(getMatchingThreads(groupsByMemberIds));
|
||||
output.addAll(getMatchingThreads(contactIds, unreadOnly));
|
||||
output.addAll(getMatchingThreads(groupsByTitleIds, unreadOnly));
|
||||
output.addAll(getMatchingThreads(groupsByMemberIds, unreadOnly));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private List<ThreadRecord> getMatchingThreads(@NonNull Collection<RecipientId> recipientIds) {
|
||||
try (Cursor cursor = threadTable.getFilteredConversationList(new ArrayList<>(recipientIds))) {
|
||||
private List<ThreadRecord> getMatchingThreads(@NonNull Collection<RecipientId> recipientIds, boolean unreadOnly) {
|
||||
try (Cursor cursor = threadTable.getFilteredConversationList(new ArrayList<>(recipientIds), unreadOnly)) {
|
||||
return readToList(cursor, new ThreadModelBuilder(threadTable));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.thoughtcrime.securesms.search
|
||||
|
||||
import org.thoughtcrime.securesms.conversationlist.model.ConversationFilter
|
||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
|
||||
@@ -11,7 +12,8 @@ data class SearchResult(
|
||||
val query: String,
|
||||
val contacts: List<Recipient>,
|
||||
val conversations: List<ThreadRecord>,
|
||||
val messages: List<MessageResult>
|
||||
val messages: List<MessageResult>,
|
||||
val conversationFilter: ConversationFilter
|
||||
) {
|
||||
fun size(): Int {
|
||||
return contacts.size + conversations.size + messages.size
|
||||
@@ -32,8 +34,12 @@ data class SearchResult(
|
||||
return this.copy(messages = result.results, query = result.query)
|
||||
}
|
||||
|
||||
fun merge(conversationFilter: ConversationFilter): SearchResult {
|
||||
return this.copy(conversationFilter = conversationFilter)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val EMPTY = SearchResult("", emptyList(), emptyList(), emptyList())
|
||||
val EMPTY = SearchResult("", emptyList(), emptyList(), emptyList(), ConversationFilter.OFF)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user