diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt index 7f18d172e4..da09683b63 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewModel.kt @@ -113,7 +113,15 @@ class ThreadListViewModel @AssistedInject constructor(@Assisted val initialState private fun fetchThreadList() { viewModelScope.launch { + isLoading(true) room?.fetchThreadSummaries() + isLoading(false) + } + } + + private fun isLoading(show: Boolean) { + setState { + copy(isLoading = show) } } diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewState.kt index e08f70030b..2328da0b8a 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/viewmodel/ThreadListViewState.kt @@ -27,6 +27,7 @@ data class ThreadListViewState( val threadSummaryList: Async> = Uninitialized, val rootThreadEventList: Async> = Uninitialized, val shouldFilterThreads: Boolean = false, + val isLoading: Boolean = false, val roomId: String ) : MavericksState { constructor(args: ThreadListArgs) : this(roomId = args.roomId) diff --git a/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt index d5659efa49..ab9ca4d2f2 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/threads/list/views/ThreadListFragment.kt @@ -104,6 +104,11 @@ class ThreadListFragment @Inject constructor( override fun invalidate() = withState(threadListViewModel) { state -> renderEmptyStateIfNeeded(state) threadListController.update(state) + renderLoaderIfNeeded(state) + } + + private fun renderLoaderIfNeeded(state: ThreadListViewState) { + views.threadListProgressBar.isVisible = state.isLoading } private fun renderToolbar() { diff --git a/vector/src/main/res/layout/fragment_thread_list.xml b/vector/src/main/res/layout/fragment_thread_list.xml index 7e7c79f8c3..f0f7dff611 100644 --- a/vector/src/main/res/layout/fragment_thread_list.xml +++ b/vector/src/main/res/layout/fragment_thread_list.xml @@ -37,6 +37,21 @@ tools:listitem="@layout/item_thread" tools:visibility="gone" /> + + + + app:layout_constraintTop_toBottomOf="@id/threadListEmptyImageView" /> + app:layout_constraintTop_toBottomOf="@id/threadListEmptyTitleTextView" />