Skip to content

Commit

Permalink
Enable dot Blog domains for all URL searches (#13917)
Browse files Browse the repository at this point in the history
* Enable dot Blog domains for all URL searches

* Update release notes

* Revert gutenberg change

* Update tests
  • Loading branch information
Chip authored Feb 1, 2021
1 parent fb45861 commit 92fc430
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
3 changes: 2 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class HomePagePickerViewModel @Inject constructor(
private val _onPreviewModeButtonPressed = SingleLiveEvent<Unit>()
val onPreviewModeButtonPressed: LiveData<Unit> = _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 {
Expand Down Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -61,6 +62,7 @@ class SiteCreationDomainsViewModelTest {
@Mock private lateinit var onHelpClickedObserver: Observer<Unit>
@Mock private lateinit var networkUtils: NetworkUtilsWrapper
@Mock private lateinit var mSiteCreationDomainSanitizer: SiteCreationDomainSanitizer
@Mock private lateinit var homePagePickerFeatureConfig: HomePagePickerFeatureConfig

private lateinit var viewModel: SiteCreationDomainsViewModel

Expand All @@ -72,6 +74,7 @@ class SiteCreationDomainsViewModelTest {
dispatcher = dispatcher,
fetchDomainsUseCase = fetchDomainsUseCase,
tracker = tracker,
homePagePickerFeatureConfig = homePagePickerFeatureConfig,
bgDispatcher = TEST_DISPATCHER,
mainDispatcher = TEST_DISPATCHER
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 92fc430

Please sign in to comment.