Skip to content

Commit

Permalink
Merge pull request #10688 from woocommerce/fix-jetpack-cp-login
Browse files Browse the repository at this point in the history
Fix Jetpack CP login
  • Loading branch information
JorgeMucientes authored Feb 6, 2024
2 parents 37c6ea8 + 2c6baa5 commit ffd7c59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
17.2
-----
- [**] [Available for users with WooCommerce version of 8.7+, which is not released yet] Every order have a receipt now. The receipts can be shared via many apps installed on the phone [https://github.com/woocommerce/woocommerce-android/pull/10650]
- [*] Fix login for sites with Jetpack Connection Package [https://github.com/woocommerce/woocommerce-android/pull/10688]

17.1
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ class SitePickerViewModel @Inject constructor(
}

private fun onSitesLoaded(sites: List<SiteModel>) {
val filteredSites = sites.filter { !it.isJetpackCPConnected }

if (filteredSites.isEmpty()) {
if (sites.isEmpty()) {
when {
loginSiteAddress != null -> showAccountMismatchScreen(loginSiteAddress!!)
navArgs.openedFromLogin -> onEmptyStoresList()
Expand All @@ -198,8 +196,8 @@ class SitePickerViewModel @Inject constructor(
return
}

val wooSites = filteredSites.filter { it.hasWooCommerce }
val nonWooSites = filteredSites.filter { !it.hasWooCommerce }
val wooSites = sites.filter { it.hasWooCommerce }
val nonWooSites = sites.filter { !it.hasWooCommerce }

if (_sites.value == null) {
// Track events only on the first call
Expand Down Expand Up @@ -231,7 +229,7 @@ class SitePickerViewModel @Inject constructor(
}
}
sitePickerViewState = sitePickerViewState.copy(
hasConnectedStores = filteredSites.isNotEmpty(),
hasConnectedStores = sites.isNotEmpty(),
isPrimaryBtnVisible = wooSites.isNotEmpty(),
isNoStoresViewVisible = false,
currentSitePickerState = SitePickerState.StoreListState
Expand Down Expand Up @@ -263,7 +261,7 @@ class SitePickerViewModel @Inject constructor(
* - Has WooCommerce installed
*/
private fun processLoginSiteAddress(url: String) {
val site = repository.getSiteBySiteUrl(url)?.takeIf { !it.isJetpackCPConnected }
val site = repository.getSiteBySiteUrl(url)
when {
site == null -> {
// The url doesn't match any sites for this account.
Expand Down

0 comments on commit ffd7c59

Please sign in to comment.