Skip to content

Commit

Permalink
Merge pull request #12640 from woocommerce/issue/12146-enable-for-jet…
Browse files Browse the repository at this point in the history
…pack-plugin

Issue/12146 enable for jetpack plugin
  • Loading branch information
JorgeMucientes authored Sep 20, 2024
2 parents b07aafb + 8267e2b commit 692f475
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
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

0 comments on commit 692f475

Please sign in to comment.