File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
libs/fluxc-plugin/src/main/kotlin/org/wordpress/android/fluxc Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,15 @@ object WCRefundSqlUtils {
20
20
fun insertOrUpdate (site : SiteModel , orderId : Long , data : RefundResponse ) =
21
21
insertOrUpdate(site, orderId, listOf (data))
22
22
23
+ fun deleteRefunds (site : SiteModel , orderId : Long ) {
24
+ WellSql .delete(RefundBuilder ::class .java)
25
+ .where()
26
+ .equals(WCRefundsTable .LOCAL_SITE_ID , site.id)
27
+ .equals(WCRefundsTable .ORDER_ID , orderId)
28
+ .endWhere()
29
+ .execute()
30
+ }
31
+
23
32
fun insertOrUpdate (site : SiteModel , orderId : Long , data : List <RefundResponse >) {
24
33
data.forEach { item ->
25
34
val json = gson.toJson(item)
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ class WCRefundStore @Inject constructor(
116
116
return @withDefaultContext when {
117
117
response.isError -> WooResult (response.error)
118
118
response.result != null -> {
119
+ WCRefundSqlUtils .deleteRefunds(site, orderId)
119
120
WCRefundSqlUtils .insertOrUpdate(site, orderId, response.result.toList())
120
121
WooResult (response.result.map { refundsMapper.map(it) })
121
122
}
You can’t perform that action at this time.
0 commit comments