mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-01 06:03:18 +01:00
Hide empty text until after we've tried to load stories.
This commit is contained in:
@@ -77,7 +77,7 @@ class StoriesLandingFragment :
|
|||||||
|
|
||||||
viewModel.state.observe(viewLifecycleOwner) {
|
viewModel.state.observe(viewLifecycleOwner) {
|
||||||
adapter.submitList(getConfiguration(it).toMappingModelList())
|
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(
|
data class StoriesLandingState(
|
||||||
val storiesLandingItems: List<StoriesLandingItemData> = emptyList(),
|
val storiesLandingItems: List<StoriesLandingItemData> = emptyList(),
|
||||||
val displayMyStoryItem: Boolean = false,
|
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 ->
|
disposables += storiesLandingRepository.getStories().subscribe { stories ->
|
||||||
store.update { state ->
|
store.update { state ->
|
||||||
state.copy(
|
state.copy(
|
||||||
|
loadingState = StoriesLandingState.LoadingState.LOADED,
|
||||||
storiesLandingItems = stories.sorted(),
|
storiesLandingItems = stories.sorted(),
|
||||||
displayMyStoryItem = stories.isEmpty() || stories.none { it.storyRecipient.isMyStory }
|
displayMyStoryItem = stories.isEmpty() || stories.none { it.storyRecipient.isMyStory }
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user