diff --git a/changelog.d/5562.bugfix b/changelog.d/5562.bugfix new file mode 100644 index 0000000000..02148e58fa --- /dev/null +++ b/changelog.d/5562.bugfix @@ -0,0 +1 @@ +Add loader in thread list \ No newline at end of file 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..8840131f38 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 { + setLoading(true) room?.fetchThreadSummaries() + setLoading(false) + } + } + + private fun setLoading(isLoading: Boolean) { + setState { + copy(isLoading = isLoading) } } 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..7918aaf178 100644 --- a/vector/src/main/res/layout/fragment_thread_list.xml +++ b/vector/src/main/res/layout/fragment_thread_list.xml @@ -37,6 +37,22 @@ tools:listitem="@layout/item_thread" tools:visibility="gone" /> + + + + app:layout_constraintTop_toBottomOf="@id/threadListEmptyImageView" /> + app:layout_constraintTop_toBottomOf="@id/threadListEmptyTitleTextView" />