Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable dot Blog domains for all URL searches #13917

Merged
merged 5 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()) {
Copy link
Contributor Author

@chipsnyder chipsnyder Jan 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this check just to support the segments if we decide to A/B test it still

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