Hide empty text until after we've tried to load stories.
This commit is contained in:
parent
8d8a2a8eef
commit
4e851f90df
3 changed files with 12 additions and 3 deletions
|
@ -77,7 +77,7 @@ class StoriesLandingFragment :
|
|||
|
||||
viewModel.state.observe(viewLifecycleOwner) {
|
||||
adapter.submitList(getConfiguration(it).toMappingModelList())
|
||||
emptyNotice.visible = it.storiesLandingItems.isEmpty()
|
||||
emptyNotice.visible = it.hasNoStories
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,5 +3,13 @@ package org.thoughtcrime.securesms.stories.landing
|
|||
data class StoriesLandingState(
|
||||
val storiesLandingItems: List<StoriesLandingItemData> = emptyList(),
|
||||
val displayMyStoryItem: Boolean = false,
|
||||
val isHiddenContentVisible: Boolean = false
|
||||
)
|
||||
val isHiddenContentVisible: Boolean = false,
|
||||
val loadingState: LoadingState = LoadingState.INIT
|
||||
) {
|
||||
enum class LoadingState {
|
||||
INIT,
|
||||
LOADED
|
||||
}
|
||||
|
||||
val hasNoStories: Boolean = loadingState == LoadingState.LOADED && storiesLandingItems.isEmpty()
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ class StoriesLandingViewModel(private val storiesLandingRepository: StoriesLandi
|
|||
disposables += storiesLandingRepository.getStories().subscribe { stories ->
|
||||
store.update { state ->
|
||||
state.copy(
|
||||
loadingState = StoriesLandingState.LoadingState.LOADED,
|
||||
storiesLandingItems = stories.sorted(),
|
||||
displayMyStoryItem = stories.isEmpty() || stories.none { it.storyRecipient.isMyStory }
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue