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

Issue/12146 enable Blaze for Blaze for WooCoomerce plugin #12640

Merged
merged 8 commits into from
Sep 20, 2024
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-----
- [*] Fixes a bug that prevented users to rename the Product Variation Attributes to because of case insensitive checks [https://github.com/woocommerce/woocommerce-android/pull/12608]
- [*] Users can directly pick product images when creating Blaze ads [https://github.com/woocommerce/woocommerce-android/pull/12610]
- [*] Enables Blaze feature for sites with Blaze for WooCommerce plugin installed and active [https://github.com/woocommerce/woocommerce-android/pull/12640]
- [*] Fix for ConcurrentModificationException while removing notification [https://github.com/woocommerce/woocommerce-android/pull/12646]

20.4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
package com.woocommerce.android.ui.blaze

import com.woocommerce.android.tools.SelectedSite
import com.woocommerce.android.tools.SiteConnectionType
import com.woocommerce.android.tools.SiteConnectionType.Jetpack
import com.woocommerce.android.util.IsRemoteFeatureFlagEnabled
import com.woocommerce.android.util.RemoteFeatureFlag.WOO_BLAZE
import javax.inject.Inject

class IsBlazeEnabled @Inject constructor(
private val selectedSite: SelectedSite,
private val isRemoteFeatureFlagEnabled: IsRemoteFeatureFlagEnabled,
private val isRemoteFeatureFlagEnabled: IsRemoteFeatureFlagEnabled
) {
companion object {
private const val BLAZE_FOR_WOOCOMMERCE_PLUGIN_SLUG = "blaze-ads"
}

suspend operator fun invoke(): Boolean = selectedSite.getIfExists()?.isAdmin ?: false &&
selectedSite.connectionType == SiteConnectionType.Jetpack &&
hasAValidJetpackConnectionForBlaze() &&
selectedSite.getIfExists()?.canBlaze ?: false &&
isRemoteFeatureFlagEnabled(WOO_BLAZE)

/**
* In order for Blaze to work, the site requires the Jetpack Sync module to be enabled. This means not all
* Jetpack connection will work. For now, Blaze will only be enabled for sites with Jetpack plugin installed and
* active, or for sites with Blaze for WooCommerce plugin installed and connected.
*/
private fun hasAValidJetpackConnectionForBlaze() =
selectedSite.connectionType == Jetpack || isBlazeForWooCommercePluginActive()

private fun isBlazeForWooCommercePluginActive(): Boolean =
selectedSite.get().activeJetpackConnectionPlugins?.contains(BLAZE_FOR_WOOCOMMERCE_PLUGIN_SLUG) == true
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ tasks.register("installGitHooks", Copy) {
}

ext {
fluxCVersion = '2.96.0'
fluxCVersion = 'trunk-b96c0d2e70b1a2975ef8dce322f37a9ee4a60891'
glideVersion = '4.16.0'
coilVersion = '2.1.0'
constraintLayoutVersion = '1.2.0'
Expand Down
Loading