Skip to content

Commit

Permalink
↑ Updates: DashboardItemsViewModelSlice implementation to use site model
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeshRPai committed Feb 5, 2024
1 parent 7635a43 commit b66b9f0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class MySiteViewModel @Inject constructor(
selectedSiteRepository.getSelectedSite()?.let {
if (shouldShowDashboard(it)) {
dashboardCardsViewModelSlice.onRefresh(it)
dashboardItemsViewModelSlice.onRefresh()
dashboardItemsViewModelSlice.onRefresh(it)
} else {
accountDataViewModelSlice.onRefresh()
}
Expand All @@ -276,7 +276,7 @@ class MySiteViewModel @Inject constructor(
// dashboardCardPlansUtils.onResume(uiModel.value as? SiteSelected)
selectedSiteRepository.getSelectedSite()?.let {
dashboardCardsViewModelSlice.onResume(it)
dashboardItemsViewModelSlice.onResume()
dashboardItemsViewModelSlice.onResume(it)
siteInfoHeaderCardViewModelSlice.onResume()
}?: run {
accountDataViewModelSlice.onResume()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DashboardItemsViewModelSlice @Inject constructor(
siteItems: List<MySiteCardAndItem>?,
sotw2023NudgeCard: MySiteCardAndItem.Card.WpSotw2023NudgeCardModel?
): List<MySiteCardAndItem> {
val dasbhboardSiteItems = mutableListOf<MySiteCardAndItem>().apply {
val dasbhboardSiteItems = mutableListOf<MySiteCardAndItem>().apply {
sotw2023NudgeCard?.let { add(it) }
siteItems?.let { addAll(siteItems) }
jetpackSwitchMenu?.let { add(jetpackSwitchMenu) }
Expand All @@ -83,18 +83,14 @@ class DashboardItemsViewModelSlice @Inject constructor(
return dasbhboardSiteItems
}

fun onResume() {
selectedSiteRepository.getSelectedSite()?.let { site ->
if(shouldShowSiteItems(site)) buildCards(site)
else uiModel.postValue(emptyList())
}
fun onResume(site: SiteModel) {
if (shouldShowSiteItems(site)) buildCards(site)
else uiModel.postValue(emptyList())
}

fun onRefresh() {
selectedSiteRepository.getSelectedSite()?.let { site ->
if(shouldShowSiteItems(site)) buildCards(site)
else uiModel.postValue(emptyList())
}
fun onRefresh(site: SiteModel) {
if (shouldShowSiteItems(site)) buildCards(site)
else uiModel.postValue(emptyList())
}

private fun buildCards(site: SiteModel) {
Expand Down

0 comments on commit b66b9f0

Please sign in to comment.