From 0d41203580ec93c0548d97986f8fec34ccc6bbf8 Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 25 Apr 2024 17:40:57 +0300 Subject: [PATCH 1/4] Fixes: NullPointerException in BlazeViewModel --- .../ui/blaze/blazeoverlay/BlazeViewModel.kt | 21 +++++++++++++------ .../BlazePromoteParentActivity.kt | 5 +++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazeoverlay/BlazeViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazeoverlay/BlazeViewModel.kt index 826cd921feae..6189bf25283d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazeoverlay/BlazeViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazeoverlay/BlazeViewModel.kt @@ -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 @@ -32,6 +32,8 @@ class BlazeViewModel @Inject constructor( private val _promoteUiState = MutableLiveData() val promoteUiState: LiveData = _promoteUiState + private val _onSelectedSiteMissing = MutableLiveData() + val onSelectedSiteMissing = _onSelectedSiteMissing as LiveData private val featuredImageTracker = PostListFeaturedImageTracker(dispatcher = dispatcher, mediaStore = mediaStore) @@ -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) { @@ -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 @@ -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) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt index 1a3f3279a7ec..08e54c370eda 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt @@ -1,6 +1,7 @@ package org.wordpress.android.ui.blaze.blazepromote import android.os.Bundle +import android.util.Log import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import dagger.hilt.android.AndroidEntryPoint @@ -47,6 +48,10 @@ class BlazePromoteParentActivity : AppCompatActivity() { else -> {} } } + + viewModel.onSelectedSiteMissing.observe(this) { + finish() + } } private fun getSource(): BlazeFlowSource { From dbffad1b425b179ebbe719787ea22a141f9f149a Mon Sep 17 00:00:00 2001 From: Pantelis Stampoulis Date: Thu, 25 Apr 2024 19:47:28 +0300 Subject: [PATCH 2/4] Fixes: detekt issue --- .../android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt index 08e54c370eda..799a9b2eded2 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/blaze/blazepromote/BlazePromoteParentActivity.kt @@ -1,7 +1,6 @@ package org.wordpress.android.ui.blaze.blazepromote import android.os.Bundle -import android.util.Log import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import dagger.hilt.android.AndroidEntryPoint From 8d4aa1f612011b7bba885f3ca4922dc41d8401e8 Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 25 Apr 2024 12:52:24 -0400 Subject: [PATCH 3/4] Release script: Update build.gradle gutenbergMobileVersion to ref --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ecaf7da776ba..7b54a647beec 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ ext { automatticAboutVersion = '1.4.0' automatticRestVersion = '1.0.8' automatticTracksVersion = '4.0.2' - gutenbergMobileVersion = 'v1.117.0' + gutenbergMobileVersion = '6832-b5afe640373f481d9224ff5df4fdd77a0c81bf59' wordPressAztecVersion = 'v2.1.2' wordPressFluxCVersion = 'trunk-e6bb1ab9b9b73ee49ca380e8e3b665358922e01e' wordPressLoginVersion = '1.15.0' From 56f288e81d7e0af12a28b71d8acbeb3df44940af Mon Sep 17 00:00:00 2001 From: "Tanner W. Stokes" Date: Thu, 25 Apr 2024 15:08:52 -0400 Subject: [PATCH 4/4] Release script: Update build.gradle gutenbergMobileVersion to ref --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7b54a647beec..e3dc3fdb2e13 100644 --- a/build.gradle +++ b/build.gradle @@ -23,7 +23,7 @@ ext { automatticAboutVersion = '1.4.0' automatticRestVersion = '1.0.8' automatticTracksVersion = '4.0.2' - gutenbergMobileVersion = '6832-b5afe640373f481d9224ff5df4fdd77a0c81bf59' + gutenbergMobileVersion = 'v1.118.0' wordPressAztecVersion = 'v2.1.2' wordPressFluxCVersion = 'trunk-e6bb1ab9b9b73ee49ca380e8e3b665358922e01e' wordPressLoginVersion = '1.15.0'