Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit 054015f

Browse files
author
Alejo
committed
conditional delete old data
1 parent da7b075 commit 054015f

File tree

1 file changed

+8
-2
lines changed
  • plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store

1 file changed

+8
-2
lines changed

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store/WCOrderStore.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,10 @@ class WCOrderStore @Inject constructor(
11071107
return deleteOptions
11081108
}
11091109

1110-
suspend fun fetchOrdersListFirstPage(listDescriptor: WCOrderListDescriptor): WooResult<List<OrderEntity>> {
1110+
suspend fun fetchOrdersListFirstPage(
1111+
listDescriptor: WCOrderListDescriptor,
1112+
deleteOldData: Boolean = false
1113+
): WooResult<List<OrderEntity>> {
11111114
val response = wcOrderRestClient.fetchOrdersListFirstPage(listDescriptor)
11121115
return if (response.isError) {
11131116
WooResult(WooError(API_ERROR, SERVER_ERROR, response.error.message))
@@ -1126,7 +1129,10 @@ class WCOrderStore @Inject constructor(
11261129
OrderSqlUtils.insertOrUpdateOrderSummaries(orderSummaries)
11271130
}
11281131

1129-
ordersDaoDecorator.deleteOrdersForSite(listDescriptor.site.localId())
1132+
if (deleteOldData) {
1133+
ordersDaoDecorator.deleteOrdersForSite(listDescriptor.site.localId())
1134+
}
1135+
11301136
@Suppress("SpreadOperator")
11311137
insertOrder(listDescriptor.site.localId(), *result.toTypedArray())
11321138
WooResult(orders)

0 commit comments

Comments
 (0)