From b62b0272b7b6e22880d0af81d2628db1ecdde0fb Mon Sep 17 00:00:00 2001 From: AmandaRiu Date: Wed, 22 Jan 2020 13:44:03 -0700 Subject: [PATCH] Only include the `search` query param if it's being used For some reason this can cause empty results to be returned when the value of this param is missing (empty). --- .../fluxc/network/rest/wpcom/wc/order/OrderRestClient.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/order/OrderRestClient.kt b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/order/OrderRestClient.kt index 7bc8fabc41..7f4a910a2e 100644 --- a/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/order/OrderRestClient.kt +++ b/plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/order/OrderRestClient.kt @@ -126,12 +126,14 @@ class OrderRestClient( val url = WOOCOMMERCE.orders.pathV3 val responseType = object : TypeToken>() {}.type val networkPageSize = listDescriptor.config.networkPageSize - val params = mapOf( + val params = mutableMapOf( "per_page" to networkPageSize.toString(), "offset" to offset.toString(), "status" to statusFilter, - "_fields" to "id,date_created_gmt,date_modified_gmt", - "search" to listDescriptor.searchQuery.orEmpty()) + "_fields" to "id,date_created_gmt,date_modified_gmt") + listDescriptor.searchQuery.takeUnless { it.isNullOrEmpty() }?.let { + params.put("search", it) + } val request = JetpackTunnelGsonRequest.buildGetRequest(url, listDescriptor.site.siteId, params, responseType, { response: List? -> val orderSummaries = response?.map {