From 2dd306b277271f5c1718f0f51fcff32b1004cd48 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Fri, 29 Jan 2021 13:17:23 -0500 Subject: [PATCH 1/4] Enable dot Blog domains for all URL searches --- .../android/ui/sitecreation/SiteCreationActivity.kt | 2 +- .../android/ui/sitecreation/SiteCreationMainVM.kt | 4 ++-- .../domains/SiteCreationDomainsViewModel.kt | 13 ++++++++++++- .../sitecreation/theme/HomePagePickerViewModel.kt | 8 ++++---- .../ui/sitecreation/usecases/FetchDomainsUseCase.kt | 2 ++ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt index c3ebed8ea5de..df4caf90709e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationActivity.kt @@ -111,7 +111,7 @@ class SiteCreationActivity : LocaleAwareActivity(), mainViewModel.onBackPressed() }) hppViewModel.onDesignActionPressed.observe(this, Observer { design -> - mainViewModel.onSiteDesignSelected(design.template, design.segmentId) + mainViewModel.onSiteDesignSelected(design.template) }) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt index b348aaac813b..494a0fec7615 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt @@ -100,8 +100,8 @@ class SiteCreationMainVM @Inject constructor( wizardManager.showNextStep() } - fun onSiteDesignSelected(siteDesign: String, segmentId: Long?) { - siteCreationState = siteCreationState.copy(siteDesign = siteDesign, segmentId = segmentId) + fun onSiteDesignSelected(siteDesign: String) { + siteCreationState = siteCreationState.copy(siteDesign = siteDesign) wizardManager.showNextStep() } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt index dc30661e277c..acebf04c185f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModel.kt @@ -36,6 +36,7 @@ import org.wordpress.android.ui.sitecreation.usecases.FetchDomainsUseCase import org.wordpress.android.ui.utils.UiString import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.NetworkUtilsWrapper +import org.wordpress.android.util.config.HomePagePickerFeatureConfig import org.wordpress.android.viewmodel.SingleLiveEvent import javax.inject.Inject import javax.inject.Named @@ -51,6 +52,7 @@ class SiteCreationDomainsViewModel @Inject constructor( private val domainSanitizer: SiteCreationDomainSanitizer, private val fetchDomainsUseCase: FetchDomainsUseCase, private val tracker: SiteCreationTracker, + private val homePagePickerFeatureConfig: HomePagePickerFeatureConfig, @Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher, @Named(UI_THREAD) private val mainDispatcher: CoroutineDispatcher ) : ViewModel(), CoroutineScope { @@ -140,7 +142,16 @@ class SiteCreationDomainsViewModel @Inject constructor( updateUiStateToContent(query, Loading(Ready(emptyList()), false)) fetchDomainsJob = launch { delay(THROTTLE_DELAY) - val onSuggestedDomains = fetchDomainsUseCase.fetchDomains(query.value, segmentId) + val onSuggestedDomains: OnSuggestedDomains + if (homePagePickerFeatureConfig.isEnabled()) { + onSuggestedDomains = fetchDomainsUseCase.fetchDomains(query.value, + null, + includeVendorDot = true, + includeDotBlog = true) + } else { + onSuggestedDomains = fetchDomainsUseCase.fetchDomains(query.value, segmentId) + } + withContext(mainDispatcher) { onDomainsFetched(query, onSuggestedDomains) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModel.kt index 23e618bd4ca6..68085b6e2897 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModel.kt @@ -73,9 +73,9 @@ class HomePagePickerViewModel @Inject constructor( private val _onPreviewModeButtonPressed = SingleLiveEvent() val onPreviewModeButtonPressed: LiveData = _onPreviewModeButtonPressed - sealed class DesignSelectionAction(val template: String, val segmentId: Long?) { - object Skip : DesignSelectionAction(defaultTemplateSlug, null) - class Choose(template: String, segmentId: Long?) : DesignSelectionAction(template, segmentId) + sealed class DesignSelectionAction(val template: String) { + object Skip : DesignSelectionAction(defaultTemplateSlug) + class Choose(template: String) : DesignSelectionAction(template) } sealed class DesignPreviewAction { @@ -205,7 +205,7 @@ class HomePagePickerViewModel @Inject constructor( layouts.firstOrNull { it.slug != null && it.slug == state.selectedLayoutSlug }?.let { layout -> val template = layout.slug!! analyticsTracker.trackSiteDesignSelected(template) - _onDesignActionPressed.value = DesignSelectionAction.Choose(template, layout.segmentId) + _onDesignActionPressed.value = DesignSelectionAction.Choose(template) return } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/usecases/FetchDomainsUseCase.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/usecases/FetchDomainsUseCase.kt index 0973d333ea93..2a81309fcc8d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/usecases/FetchDomainsUseCase.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/usecases/FetchDomainsUseCase.kt @@ -35,6 +35,7 @@ class FetchDomainsUseCase @Inject constructor( query: String, segmentId: Long?, includeVendorDot: Boolean = FETCH_DOMAINS_SHOULD_INCLUDE_DOT_BLOG_VENDOR, + includeDotBlog: Boolean = false, size: Int = FETCH_DOMAINS_SIZE ): OnSuggestedDomains { val payload = SuggestDomainsPayload( @@ -50,6 +51,7 @@ class FetchDomainsUseCase @Inject constructor( */ payload.includeWordpressCom = true payload.onlyWordpressCom = true + payload.includeDotBlogSubdomain = includeDotBlog return suspendCancellableCoroutine { cont -> pair = Pair(payload.query, cont) From 78c5fac434730856142a2a35dc58546cf62a8f43 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Fri, 29 Jan 2021 13:33:31 -0500 Subject: [PATCH 2/4] Update release notes --- RELEASE-NOTES.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 62a1a145d271..a6f010408db6 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -2,7 +2,8 @@ 16.7 ----- - +* [**] Site Creation: Enables dot blog subdomains for each site design. [https://github.com/wordpress-mobile/WordPress-Android/pull/13917] + 16.6 ----- * [**] Reader: adds site filter capability to Followed P2s tab page. Now the sites listed in the filters are only those relevant to the page (Following/Followed P2s) [https://github.com/wordpress-mobile/WordPress-Android/pull/13766] From 480859dc815218e148b7c7479c9ecda55fc4a898 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Fri, 29 Jan 2021 13:42:17 -0500 Subject: [PATCH 3/4] Revert gutenberg change --- libs/gutenberg-mobile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gutenberg-mobile b/libs/gutenberg-mobile index 2bcc59a816ae..ac2f99c7766b 160000 --- a/libs/gutenberg-mobile +++ b/libs/gutenberg-mobile @@ -1 +1 @@ -Subproject commit 2bcc59a816ae970a87cafe5d996ebceea282c6c6 +Subproject commit ac2f99c7766bf9d6d51fe3ca04cbe25421e10246 From f05e7fe5bef2021a7cc9ba7e3f4f72147436a6c3 Mon Sep 17 00:00:00 2001 From: Chip Snyder Date: Fri, 29 Jan 2021 15:16:38 -0500 Subject: [PATCH 4/4] Update tests --- .../sitecreation/domains/SiteCreationDomainsViewModelTest.kt | 3 +++ .../ui/sitecreation/theme/HomePagePickerViewModelTest.kt | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt index 7c102c5ac3f7..339b64019f0d 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/domains/SiteCreationDomainsViewModelTest.kt @@ -35,6 +35,7 @@ import org.wordpress.android.ui.sitecreation.domains.SiteCreationDomainsViewMode import org.wordpress.android.ui.sitecreation.misc.SiteCreationTracker import org.wordpress.android.ui.sitecreation.usecases.FetchDomainsUseCase import org.wordpress.android.util.NetworkUtilsWrapper +import org.wordpress.android.util.config.HomePagePickerFeatureConfig import org.hamcrest.CoreMatchers.`is` as Is private const val MULTI_RESULT_DOMAIN_FETCH_RESULT_SIZE = 20 @@ -61,6 +62,7 @@ class SiteCreationDomainsViewModelTest { @Mock private lateinit var onHelpClickedObserver: Observer @Mock private lateinit var networkUtils: NetworkUtilsWrapper @Mock private lateinit var mSiteCreationDomainSanitizer: SiteCreationDomainSanitizer + @Mock private lateinit var homePagePickerFeatureConfig: HomePagePickerFeatureConfig private lateinit var viewModel: SiteCreationDomainsViewModel @@ -72,6 +74,7 @@ class SiteCreationDomainsViewModelTest { dispatcher = dispatcher, fetchDomainsUseCase = fetchDomainsUseCase, tracker = tracker, + homePagePickerFeatureConfig = homePagePickerFeatureConfig, bgDispatcher = TEST_DISPATCHER, mainDispatcher = TEST_DISPATCHER ) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModelTest.kt index 25faa70a73f8..d2b31ea79dcf 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/theme/HomePagePickerViewModelTest.kt @@ -171,7 +171,6 @@ class HomePagePickerViewModelTest { val captor = ArgumentCaptor.forClass(DesignSelectionAction::class.java) verify(onDesignActionObserver).onChanged(captor.capture()) assertThat(captor.value.template).isEqualTo(defaultTemplateSlug) - assertThat(captor.value.segmentId).isNull() } @Test @@ -183,7 +182,6 @@ class HomePagePickerViewModelTest { val captor = ArgumentCaptor.forClass(DesignSelectionAction::class.java) verify(onDesignActionObserver).onChanged(captor.capture()) assertThat(captor.value.template).isEqualTo(mockedDesignSlug) - assertThat(captor.value.segmentId).isEqualTo(mockedDesignSegmentId) } @Test