@@ -795,19 +795,19 @@ extension OrderDetailsViewModel {
795795 return false
796796 }
797797
798- guard await !isPluginActive( SitePlugin . SupportedPlugin . LegacyWCShip) else {
798+ guard await !isPluginActive( pluginPath : SitePlugin . SupportedPluginPath . LegacyWCShip) else {
799799 return true
800800 }
801801
802- return await isPluginActive ( SitePlugin . SupportedPlugin . WooShipping)
802+ return await isPluginActive ( pluginPath : SitePlugin . SupportedPluginPath . WooShipping)
803803 }
804804
805805 /// Checks if the Woo Shipping extension is active, with the minimum version required for its shipping label flow.
806806 ///
807807 @MainActor
808808 func isWooShippingSupported( ) async -> Bool {
809809 guard featureFlagService. isFeatureFlagEnabled ( . revampedShippingLabelCreation) ,
810- let plugin = await fetchPlugin ( SitePlugin . SupportedPlugin . WooShipping) else {
810+ let plugin = await fetchPluginByPath ( SitePlugin . SupportedPluginPath . WooShipping) else {
811811 return false
812812 }
813813
@@ -884,7 +884,7 @@ extension OrderDetailsViewModel {
884884 ///
885885 private func isPluginActive( _ pluginNames: [ String ] , completion: @escaping ( Bool ) -> ( Void ) ) {
886886 Task { @MainActor in
887- let plugin = await fetchPlugin ( pluginNames)
887+ let plugin = await fetchPluginByNames ( pluginNames)
888888 completion ( plugin? . active == true )
889889 }
890890 }
@@ -893,7 +893,7 @@ extension OrderDetailsViewModel {
893893 /// Additionally it logs to tracks if the plugin store is accessed without it being in sync so we can handle that edge-case if it happens recurrently.
894894 ///
895895 @MainActor
896- private func fetchPlugin ( _ pluginNames: [ String ] ) async -> SystemPlugin ? {
896+ private func fetchPluginByNames ( _ pluginNames: [ String ] ) async -> SystemPlugin ? {
897897 guard arePluginsSynced ( ) else {
898898 DDLogError ( " ⚠️ SystemPlugins accessed without being in sync. " )
899899 ServiceLocator . analytics. track ( event: WooAnalyticsEvent . Orders. pluginsNotSyncedYet ( ) )
@@ -907,6 +907,24 @@ extension OrderDetailsViewModel {
907907 }
908908 }
909909
910+ /// Fetches a plugin from storage, based on the provided plugin path.
911+ /// Additionally it logs to tracks if the plugin store is accessed without it being in sync so we can handle that edge-case if it happens recurrently.
912+ ///
913+ @MainActor
914+ private func fetchPluginByPath( _ path: String ) async -> SystemPlugin ? {
915+ guard arePluginsSynced ( ) else {
916+ DDLogError ( " ⚠️ SystemPlugins accessed without being in sync. " )
917+ ServiceLocator . analytics. track ( event: WooAnalyticsEvent . Orders. pluginsNotSyncedYet ( ) )
918+ return nil
919+ }
920+
921+ return await withCheckedContinuation { continuation in
922+ stores. dispatch ( SystemStatusAction . fetchSystemPluginWithPath ( siteID: order. siteID, pluginPath: path, onCompletion: { plugin in
923+ continuation. resume ( returning: plugin)
924+ } ) )
925+ }
926+ }
927+
910928 /// Function that checks for any existing system plugin in the order's store.
911929 /// If there is none, we assume plugins are not synced because at least the`WooCommerce` plugin should be present.
912930 ///
@@ -944,6 +962,12 @@ private extension OrderDetailsViewModel {
944962 }
945963 }
946964 }
965+
966+ @MainActor
967+ func isPluginActive( pluginPath: String ) async -> Bool {
968+ let plugin = await fetchPluginByPath ( pluginPath)
969+ return plugin? . active == true
970+ }
947971}
948972
949973extension OrderDetailsViewModel {
0 commit comments