Skip to content

Commit f95953e

Browse files
committed
Remove the redundant isLocalCatalogSupported dependency
1 parent f0726ab commit f95953e

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/woopos/localcatalog/WooPosLocalCatalogSyncWorker.kt

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.woocommerce.android.ui.woopos.tab.WooPosTabShouldBeVisible
1010
import com.woocommerce.android.ui.woopos.util.datastore.WooPosPreferencesRepository
1111
import dagger.assisted.Assisted
1212
import dagger.assisted.AssistedInject
13-
import org.wordpress.android.fluxc.model.SiteModel
1413
import kotlin.time.Duration.Companion.milliseconds
1514

1615
@HiltWorker
@@ -26,7 +25,6 @@ constructor(
2625
private val logger: WooPosLogWrapper,
2726
private val timeProvider: DateTimeProvider,
2827
private val wooPosTabShouldBeVisible: WooPosTabShouldBeVisible,
29-
private val isLocalCatalogSupported: WooPosIsLocalCatalogSupported,
3028
private val syncStatusChecker: WooPosFullSyncStatusChecker,
3129
) : CoroutineWorker(appContext, workerParams) {
3230

@@ -48,9 +46,13 @@ constructor(
4846
return Result.success()
4947
}
5048

51-
checkSyncRequirement()?.let { return it }
49+
validateSyncStatus()?.let { return it }
5250

53-
val site = isCatalogSyncSupported() ?: return Result.failure()
51+
// Site and catalog support already validated by validateSyncStatus()
52+
val site = selectedSite.getOrNull() ?: run {
53+
logger.e("Unexpected: Site is null after validation")
54+
return Result.failure()
55+
}
5456

5557
logger.d("Starting FULL local catalog sync")
5658

@@ -88,7 +90,7 @@ constructor(
8890
}
8991

9092
@Suppress("ReturnCount")
91-
private suspend fun checkSyncRequirement(): Result? {
93+
private suspend fun validateSyncStatus(): Result? {
9294
val syncRequirement = syncStatusChecker.checkSyncRequirement()
9395
return when (syncRequirement) {
9496
is WooPosFullSyncRequirement.NotRequired -> {
@@ -127,20 +129,4 @@ constructor(
127129
false
128130
}
129131
}
130-
131-
@Suppress("ReturnCount")
132-
private suspend fun isCatalogSyncSupported(): SiteModel? {
133-
val site = selectedSite.getOrNull()
134-
if (site == null) {
135-
logger.w("No selected WooCommerce site found, skipping local catalog sync")
136-
return null
137-
}
138-
139-
if (!isLocalCatalogSupported(site.localId())) {
140-
logger.d("Local catalog not supported for site")
141-
return null
142-
}
143-
144-
return site
145-
}
146132
}

0 commit comments

Comments
 (0)