Skip to content

Commit

Permalink
Checks if Blaze for WooCommerce plugin is installed and active
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeMucientes committed Sep 18, 2024
1 parent 584137b commit 807844b
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.woocommerce.android.ui.blaze

import com.woocommerce.android.tools.SelectedSite
import com.woocommerce.android.tools.SiteConnectionType.Jetpack
import com.woocommerce.android.tools.SiteConnectionType.JetpackConnectionPackage
import com.woocommerce.android.util.IsRemoteFeatureFlagEnabled
import com.woocommerce.android.util.RemoteFeatureFlag.WOO_BLAZE
import javax.inject.Inject
Expand All @@ -23,12 +22,11 @@ class IsBlazeEnabled @Inject constructor(
/**
* 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 (Jetpack CP with sync module)
* active, or for sites with Blaze for WooCommerce plugin installed and connected.
*/
private fun hasAValidJetpackConnectionForBlaze() =
selectedSite.connectionType == Jetpack ||
(selectedSite.connectionType == JetpackConnectionPackage && isBlazeForWooCommercePluginInstalled())
selectedSite.connectionType == Jetpack || isBlazeForWooCommercePluginActive()

private fun isBlazeForWooCommercePluginInstalled(): Boolean =
selectedSite.get().activeJetpackConnectionPlugins.any { it.toString() == BLAZE_FOR_WOOCOMMERCE_PLUGIN_SLUG }
private fun isBlazeForWooCommercePluginActive(): Boolean =
selectedSite.get().activeJetpackConnectionPlugins?.contains(BLAZE_FOR_WOOCOMMERCE_PLUGIN_SLUG) == true
}

0 comments on commit 807844b

Please sign in to comment.