Skip to content
Snippets Groups Projects
Commit 4498c231 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

smartlist: fix username and hash lookup

Change-Id: I03f93ad79adc61065b23f2d41458668a0ba8dfe4
parent 6fca9820
No related branches found
No related tags found
No related merge requests found
......@@ -354,13 +354,6 @@ class ConversationFacade(
}
}
fun getConversationSearchResults(account: Account, query: Observable<String>): Observable<SearchResult> =
query.switchMapSingle { q: String ->
if (q.isEmpty())
Single.just(SearchResult.EMPTY_RESULT)
else getConversationSearchResults(account, q)
}
data class ConversationList(val conversations: List<Conversation> = emptyList(), val searchResult: SearchResult = SearchResult.EMPTY_RESULT, val latestQuery: String = "") {
fun isEmpty(): Boolean = conversations.isEmpty() && searchResult.result.isEmpty()
......@@ -401,7 +394,7 @@ class ConversationFacade(
currentAccount.switchMap { account ->
Observable.combineLatest(
account.getConversationsSubject(),
getConversationSearchResults(account, query),
query.switchMapSingle { getConversationSearchResults(account, it) },
query
) { conversations, searchResults, q -> ConversationList(conversations, searchResults, q) }
}.switchMapSingle { list ->
......@@ -409,8 +402,8 @@ class ConversationFacade(
val lq = list.latestQuery.lowercase()
Maybe.concatEager(list.conversations.map { c -> mContactService.getLoadedConversation(c)
.filter { it.matches(lq) }.map { c }
}).toList().map { newList -> ConversationList(newList, list.searchResult, lq) }
} else Single.just(ConversationList(list.conversations))
}).toList().map { newList -> ConversationList(newList, list.searchResult, list.latestQuery) }
} else Single.just(list)
}
/**
......
......@@ -57,7 +57,7 @@ class SmartListPresenter @Inject constructor(
.subscribe { list ->
val v = this.view ?: return@subscribe
v.setLoading(false)
if (list.conversations.isEmpty()) {
if (list.isEmpty()) {
v.hideList()
v.displayNoConversationMessage()
} else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment