From 5e56e7cf829464d429ed06cc2ffe8013bfe10ef8 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Thu, 24 Sep 2020 10:21:26 +0300 Subject: [PATCH] Implement search state, action and view events. --- .../app/features/home/room/detail/search/SearchAction.kt | 6 +++++- .../features/home/room/detail/search/SearchViewEvents.kt | 5 ++++- .../features/home/room/detail/search/SearchViewState.kt | 9 ++++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchAction.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchAction.kt index 2774ef4d8e..d295784a8c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchAction.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchAction.kt @@ -18,4 +18,8 @@ package im.vector.app.features.home.room.detail.search import im.vector.app.core.platform.VectorViewModelAction -sealed class SearchAction : VectorViewModelAction +sealed class SearchAction : VectorViewModelAction { + data class SearchWith(val roomId: String, val searchTerm: String) : SearchAction() + object ScrolledToTop : SearchAction() + object Retry : SearchAction() +} diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewEvents.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewEvents.kt index a5489e9240..41dabd8686 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewEvents.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewEvents.kt @@ -18,4 +18,7 @@ package im.vector.app.features.home.room.detail.search import im.vector.app.core.platform.VectorViewEvents -sealed class SearchViewEvents : VectorViewEvents +sealed class SearchViewEvents : VectorViewEvents { + data class Failure(val throwable: Throwable) : SearchViewEvents() + data class Loading(val message: CharSequence? = null) : SearchViewEvents() +} diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewState.kt index 785d61dc00..02db098e68 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/search/SearchViewState.kt @@ -17,7 +17,14 @@ package im.vector.app.features.home.room.detail.search import com.airbnb.mvrx.MvRxState +import org.matrix.android.sdk.api.session.search.SearchResult data class SearchViewState( - val searchTerm: String = "" + // Accumulated search result + val searchResult: SearchResult? = null, + // Last batch result will help RecyclerView to position itself + val lastBatch: SearchResult? = null, + val searchTerm: String? = null, + val roomId: String? = null, + val isNextBatch: Boolean = false ) : MvRxState