Skip to content

Commit

Permalink
Merge branch 'feature/notifications_refresh_p2' into task/noteblock-t…
Browse files Browse the repository at this point in the history
…o-kotlin-2
  • Loading branch information
Antonis Lilis committed Apr 26, 2024
2 parents d6fa715 + 19ea81b commit 71c80da
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BlazeViewModel @Inject constructor(
private val blazeFeatureUtils: BlazeFeatureUtils,
dispatcher: Dispatcher,
mediaStore: MediaStore,
private val siteSelectedSiteRepository: SelectedSiteRepository
private val selectedSiteRepository: SelectedSiteRepository
) : ViewModel() {
private lateinit var blazeFlowSource: BlazeFlowSource

Expand All @@ -32,6 +32,8 @@ class BlazeViewModel @Inject constructor(
private val _promoteUiState = MutableLiveData<BlazeUiState.PromoteScreen>()
val promoteUiState: LiveData<BlazeUiState.PromoteScreen> = _promoteUiState

private val _onSelectedSiteMissing = MutableLiveData<Unit>()
val onSelectedSiteMissing = _onSelectedSiteMissing as LiveData<Unit>
private val featuredImageTracker =
PostListFeaturedImageTracker(dispatcher = dispatcher, mediaStore = mediaStore)

Expand All @@ -40,6 +42,11 @@ class BlazeViewModel @Inject constructor(
blazeUIModel?.let { initializePromoteContentUIState(it) } ?: run {
initializePromoteSiteUIState(shouldShowOverlay)
}
val site = selectedSiteRepository.getSelectedSite()
if (site == null) {
_onSelectedSiteMissing.value = Unit
return
}
}

private fun initializePromoteContentUIState(blazeUIModel: BlazeUIModel) {
Expand All @@ -52,7 +59,7 @@ class BlazeViewModel @Inject constructor(
private fun initializePromotePostUIState(postModel: PostUIModel) {
val updatedPostModel = postModel.copy(
url = UrlUtils.removeScheme(postModel.url),
featuredImageUrl = siteSelectedSiteRepository.getSelectedSite()?.let {
featuredImageUrl = selectedSiteRepository.getSelectedSite()?.let {
featuredImageTracker.getFeaturedImageUrl(
it,
postModel.featuredImageId
Expand All @@ -71,10 +78,12 @@ class BlazeViewModel @Inject constructor(
private fun initializePromotePageUIState(pageModel: PageUIModel) {
val updatedPageModel = pageModel.copy(
url = UrlUtils.removeScheme(pageModel.url),
featuredImageUrl = featuredImageTracker.getFeaturedImageUrl(
siteSelectedSiteRepository.getSelectedSite()!!,
pageModel.featuredImageId
)
featuredImageUrl = selectedSiteRepository.getSelectedSite()?.let {
featuredImageTracker.getFeaturedImageUrl(
it,
pageModel.featuredImageId
)
}
)

_promoteUiState.value = BlazeUiState.PromoteScreen.PromotePage(updatedPageModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class BlazePromoteParentActivity : AppCompatActivity() {
else -> {}
}
}

viewModel.onSelectedSiteMissing.observe(this) {
finish()
}
}

private fun getSource(): BlazeFlowSource {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ext {
automatticAboutVersion = '1.4.0'
automatticRestVersion = '1.0.8'
automatticTracksVersion = '4.0.2'
gutenbergMobileVersion = 'v1.117.0'
gutenbergMobileVersion = 'v1.118.0'
wordPressAztecVersion = 'v2.1.2'
wordPressFluxCVersion = 'trunk-e6bb1ab9b9b73ee49ca380e8e3b665358922e01e'
wordPressLoginVersion = '1.15.0'
Expand Down

0 comments on commit 71c80da

Please sign in to comment.