Skip to content

Commit de8a4c1

Browse files
committed
Use dev version of plugin so we can test it
1 parent 06180d2 commit de8a4c1

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/payments/receipt/PaymentReceiptHelper.kt

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.woocommerce.android.ui.payments.receipt
22

33
import com.woocommerce.android.AppPrefsWrapper
4+
import com.woocommerce.android.BuildConfig
45
import com.woocommerce.android.extensions.semverCompareTo
56
import com.woocommerce.android.tools.SelectedSite
67
import com.woocommerce.android.ui.payments.cardreader.onboarding.PluginType
7-
import kotlinx.coroutines.Dispatchers
8-
import kotlinx.coroutines.withContext
98
import org.wordpress.android.fluxc.model.SiteModel
109
import org.wordpress.android.fluxc.store.WCOrderStore
1110
import org.wordpress.android.fluxc.store.WooCommerceStore
@@ -72,16 +71,29 @@ class PaymentReceiptHelper @Inject constructor(
7271
}
7372
}
7473

75-
private suspend fun isWCCanGenerateReceipts() =
76-
withContext(Dispatchers.IO) {
77-
val currentWooCoreVersion =
78-
wooCommerceStore.getSitePlugin(
79-
selectedSite.get(),
80-
WooCommerceStore.WooPlugin.WOO_CORE
81-
)?.version ?: return@withContext false
74+
private suspend fun isWCCanGenerateReceipts(): Boolean {
75+
val currentWooCoreVersion = getWoocommerceCorePluginVersion()
8276

83-
currentWooCoreVersion.semverCompareTo(WC_CAN_GENERATE_RECEIPTS_VERSION) >= 0
84-
}
77+
return currentWooCoreVersion.semverCompareTo(WC_CAN_GENERATE_RECEIPTS_VERSION) >= 0
78+
}
79+
80+
private suspend fun getWoocommerceCorePluginVersion(): String {
81+
val sitePlugin = wooCommerceStore.getSitePlugin(
82+
selectedSite.get(),
83+
WooCommerceStore.WooPlugin.WOO_CORE
84+
)
85+
return if (sitePlugin == null) {
86+
if (BuildConfig.DEBUG) {
87+
wooCommerceStore.getSitePlugins(selectedSite.get())
88+
.firstOrNull { it.name == "woocommerce-dev/woocommerce" }
89+
?.let { it.version }
90+
} else {
91+
""
92+
}
93+
} else {
94+
sitePlugin.version
95+
} ?: ""
96+
}
8597

8698
private companion object {
8799
const val WCPAY_RECEIPTS_SENDING_SUPPORT_VERSION = "4.0.0"

0 commit comments

Comments
 (0)