Skip to content

Commit

Permalink
→ Moves: refresh logic to child VM Slices
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeshRPai committed Feb 7, 2024
1 parent 40fc54f commit a433574
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ class CardViewModelSlice @Inject constructor(
val refresh =
merge(
_refresh,
pagesCardViewModelSlice.refresh,
todaysStatsViewModelSlice.refresh,
postsCardViewModelSlice.refresh,
activityLogCardViewModelSlice.refresh,
dynamicCardsViewModelSlice.refresh,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class ActivityLogCardViewModelSlice @Inject constructor(
private val _onNavigation = MutableLiveData<Event<SiteNavigationAction>>()
val onNavigation = _onNavigation

private val _refresh = MutableLiveData<Event<Boolean>>()
val refresh = _refresh

fun buildCard(activityCardModel: CardModel.ActivityCardModel?) {
_uiModel.postValue(activityCardBuilder.build(getActivityLogCardBuilderParams(activityCardModel)))
}
Expand Down Expand Up @@ -68,7 +65,7 @@ class ActivityLogCardViewModelSlice @Inject constructor(
appPrefsWrapper.setShouldHideActivityDashboardCard(
requireNotNull(selectedSiteRepository.getSelectedSite()).siteId, true
)
_refresh.postValue(Event(true))
_uiModel.value = null
}

private fun onActivityCardAllActivityItemClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class PagesCardViewModelSlice @Inject constructor(
private val _onNavigation = MutableLiveData<Event<SiteNavigationAction>>()
val onNavigation = _onNavigation

private val _refresh = MutableLiveData<Event<Boolean>>()
val refresh = _refresh

fun buildCard(pagesCardModel: PagesCardModel?) {
_uiModel.postValue(
pagesCardBuilder.build(getPagesCardBuilderParams(pagesCardModel))
Expand Down Expand Up @@ -61,7 +58,7 @@ class PagesCardViewModelSlice @Inject constructor(
private fun onPagesCardHideThisCardClick() {
cardsTracker.trackCardMoreMenuItemClicked(CardsTracker.Type.PAGES.label, PagesMenuItemType.HIDE_THIS.label)
appPrefsWrapper.setShouldHidePagesDashboardCard(selectedSiteRepository.getSelectedSite()!!.siteId, true)
_refresh.postValue(Event(true))
_uiModel.value = null
}

private fun onPagesItemClick(params: PagesCardBuilderParams.PagesItemClickParams) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ class PostsCardViewModelSlice @Inject constructor(
private val _onNavigation = MutableLiveData<Event<SiteNavigationAction>>()
val onNavigation = _onNavigation

private val _refresh = MutableLiveData<Event<Boolean>>()
val refresh = _refresh

fun buildPostCard(postsCardModel: PostsCardModel?) {
_uiModel.postValue(postCardBuilder.build(getPostsCardBuilderParams(postsCardModel)))
}
Expand Down Expand Up @@ -58,7 +55,7 @@ class PostsCardViewModelSlice @Inject constructor(
postCardType.name,
true
)
refresh.postValue(Event(true))
_uiModel.postValue(null)
}

private fun onViewPostsMenuItemClick(postCardType: PostCardType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ class TodaysStatsViewModelSlice @Inject constructor(
private val _onNavigation = MutableLiveData<Event<SiteNavigationAction>>()
val onNavigation = _onNavigation

private val _refresh = MutableLiveData<Event<Boolean>>()
val refresh = _refresh


fun buildTodaysStatsCard(todaysStatsCardModel: TodaysStatsCardModel?) {
_uiModel.postValue(todaysStatsCardBuilder.build(getTodaysStatsBuilderParams(todaysStatsCardModel)))
}
Expand Down Expand Up @@ -78,7 +74,7 @@ class TodaysStatsViewModelSlice @Inject constructor(
TodaysStatsMenuItemType.HIDE_THIS.label
)
appPrefsWrapper.setShouldHideTodaysStatsDashboardCard(selectedSiteRepository.getSelectedSite()!!.siteId, true)
_refresh.postValue(Event(true))
_uiModel.value = null
}

private fun onViewStatsMenuItemClick() {
Expand Down

0 comments on commit a433574

Please sign in to comment.