Skip to content

Commit

Permalink
* Fixes: the crash by checking if the site is nulll
Browse files Browse the repository at this point in the history
  • Loading branch information
AjeshRPai committed Feb 2, 2024
1 parent 6621e43 commit d1cdbf1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class CampaignListingFragment : Fragment() {
}
}
}
viewModel.onSelectedSiteMissing.observe(viewLifecycleOwner) {
requireActivity().finish()
}
}

private fun getPageSource(): CampaignListingPageSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import org.wordpress.android.Result
import org.wordpress.android.R
import org.wordpress.android.Result
import org.wordpress.android.fluxc.model.SiteModel
import org.wordpress.android.modules.BG_THREAD
import org.wordpress.android.ui.blaze.BlazeFeatureUtils
Expand Down Expand Up @@ -47,12 +47,20 @@ class CampaignListingViewModel @Inject constructor(
private val _snackbar = MutableSharedFlow<String>()
val snackBar = _snackbar.asSharedFlow()

private val _onSelectedSiteMissing = MutableLiveData<Unit>()
val onSelectedSiteMissing = _onSelectedSiteMissing as LiveData<Unit>

private var page = 1
private var limitPerPage: Int = 10
private var isLastPage: Boolean = false

fun start(campaignListingPageSource: CampaignListingPageSource) {
this.site = selectedSiteRepository.getSelectedSite()!!
val site = selectedSiteRepository.getSelectedSite()
if (site == null) {
_onSelectedSiteMissing.value = Unit
return
}
this.site = site
blazeFeatureUtils.trackCampaignListingPageShown(campaignListingPageSource)
loadCampaigns()
}
Expand Down

0 comments on commit d1cdbf1

Please sign in to comment.