diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsViewState.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsViewState.kt index eca32e2481..fa985c5c76 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsViewState.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/RoomPollsViewState.kt @@ -30,4 +30,7 @@ data class RoomPollsViewState( ) : MavericksState { constructor(roomProfileArgs: RoomProfileArgs) : this(roomId = roomProfileArgs.roomId) + + fun hasNoPolls() = polls.isEmpty() + fun hasNoPollsAndCanLoadMore() = !isSyncing && hasNoPolls() && canLoadMore } diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/RoomPollsListFragment.kt b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/RoomPollsListFragment.kt index 327b1d713a..5920eb046e 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/RoomPollsListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/polls/list/ui/RoomPollsListFragment.kt @@ -119,11 +119,10 @@ abstract class RoomPollsListFragment : canLoadMore = viewState.canLoadMore, nbLoadedDays = viewState.nbLoadedDays, ) - views.roomPollsEmptyTitle.isVisible = viewState.polls.isEmpty() && !viewState.isSyncing - views.roomPollsLoadMoreWhenEmpty.isVisible = viewState.polls.isEmpty() && viewState.canLoadMore && !viewState.isSyncing - views.roomPollsLoadMoreWhenEmptyProgress.isVisible = viewState.polls.isEmpty() && viewState.canLoadMore && - viewState.isLoadingMore && !viewState.isSyncing - views.roomPollsLoadMoreWhenEmptyProgress.isEnabled = !viewState.isLoadingMore + views.roomPollsEmptyTitle.isVisible = !viewState.isSyncing && viewState.hasNoPolls() + views.roomPollsLoadMoreWhenEmpty.isVisible = viewState.hasNoPollsAndCanLoadMore() + views.roomPollsLoadMoreWhenEmpty.isEnabled = !viewState.isLoadingMore + views.roomPollsLoadMoreWhenEmptyProgress.isVisible = viewState.hasNoPollsAndCanLoadMore() && viewState.isLoadingMore } override fun onPollClicked(pollId: String) {