Skip to content

Commit

Permalink
Hide reader announcement card on Discover when empty state is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
RenanLukas committed May 22, 2024
1 parent 7587b30 commit 6f3a6bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ class ReaderDiscoverViewModel @Inject constructor(
// since new users have the dailyprompt tag followed by default, we need to ignore them when
// checking if the user has any tags followed, so we show the onboarding state (ShowNoFollowedTags)
if (userTags.filterNot { it.tagSlug == BLOGGING_PROMPT_TAG }.isEmpty()) {
parentViewModel.onFeedEmptyStateLoaded()
_uiState.value = DiscoverUiState.EmptyUiState.ShowNoFollowedTagsUiState {
parentViewModel.onShowReaderInterests()
}
} else {
if (posts != null && posts.cards.isNotEmpty()) {
parentViewModel.onFeedContentLoaded()
_uiState.value = DiscoverUiState.ContentUiState(
convertCardsToUiStates(posts),
reloadProgressVisibility = false,
Expand All @@ -169,6 +171,7 @@ class ReaderDiscoverViewModel @Inject constructor(
swipeToRefreshTriggered = false
}
} else {
parentViewModel.onFeedEmptyStateLoaded()
_uiState.value = DiscoverUiState.EmptyUiState.ShowNoPostsUiState {
_navigationEvents.value = Event(ShowReaderSubs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ class ReaderViewModel @Inject constructor(
}
}

fun onFeedEmptyStateLoaded() {
hideAnnouncementCard()
}

fun onFeedContentLoaded() {
updateAnnouncementCard()
}

private fun hideAnnouncementCard() {
_announcementCardState.value = _announcementCardState.value?.copy(
shouldShow = false,
)
}

private fun showJetpackPoweredBottomSheet() {
// _showJetpackPoweredBottomSheet.value = Event(true)
}
Expand Down

0 comments on commit 6f3a6bb

Please sign in to comment.