Skip to content

Commit 3be0abb

Browse files
authored
Merge pull request #14761 from woocommerce/woomob-1513-order-list-filtering-by-custom-from-the-order-details-doesnt
[WOOMOB-1513] Fix customer name display when filtering orders from order details
2 parents d2f63c9 + 6989282 commit 3be0abb

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [Internal][Wear] Remove unused dependencies and optimize dependency scopes [https://github.com/woocommerce/woocommerce-android/pull/14710]
77
- [Internal] Remove unused dependencies and optimize dependency scopes [https://github.com/woocommerce/woocommerce-android/pull/14710]
88
- [*] Fix a rare crash in order refund flow [https://github.com/woocommerce/woocommerce-android/pull/14742]
9+
- [*] Fix customer name display when filtering orders from order details [https://github.com/woocommerce/woocommerce-android/pull/14761]
910

1011
23.4
1112
-----

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/filters/data/OrderFiltersRepository.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import kotlinx.coroutines.CoroutineScope
99
import kotlinx.coroutines.flow.distinctUntilChanged
1010
import kotlinx.coroutines.flow.launchIn
1111
import kotlinx.coroutines.flow.onEach
12+
import kotlinx.coroutines.launch
13+
import org.wordpress.android.fluxc.store.WCCustomerStore
1214
import javax.inject.Inject
1315
import javax.inject.Singleton
1416

1517
@Singleton
1618
class OrderFiltersRepository @Inject constructor(
1719
private val appSharedPrefs: AppPrefsWrapper,
20+
private val customerStore: WCCustomerStore,
1821
private val selectedSite: SelectedSite,
1922
@AppCoroutineScope private val appCoroutineScope: CoroutineScope
2023
) {
@@ -56,6 +59,14 @@ class OrderFiltersRepository @Inject constructor(
5659
}
5760
}
5861

62+
fun loadCustomerInfoIfNeeded(customerId: Long) {
63+
appCoroutineScope.launch {
64+
if (customerStore.getCustomerByRemoteId(selectedSite.get(), customerId) == null) {
65+
customerStore.fetchSingleCustomer(selectedSite.get(), customerId)
66+
}
67+
}
68+
}
69+
5970
fun getCurrentFilterSelection(filterCategory: OrderListFilterCategory): List<String> {
6071
val preferenceFilters = selectedSite.getIfExists()?.let { site ->
6172
appSharedPrefs.getOrderFilters(site.id, filterCategory.name)

WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/list/OrderListFragment.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import com.woocommerce.android.ui.orders.OrdersCommunicationViewModel
6666
import com.woocommerce.android.ui.orders.creation.CodeScannerStatus
6767
import com.woocommerce.android.ui.orders.creation.GoogleBarcodeFormatMapper.BarcodeFormat
6868
import com.woocommerce.android.ui.orders.creation.OrderCreateEditViewModel
69+
import com.woocommerce.android.ui.orders.creation.customerlist.CustomerListRepository
6970
import com.woocommerce.android.ui.orders.details.OrderStatusSelectorDialog
7071
import com.woocommerce.android.ui.orders.filters.data.OrderFiltersRepository
7172
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory
@@ -117,6 +118,9 @@ class OrderListFragment :
117118
@Inject
118119
internal lateinit var orderFiltersRepository: OrderFiltersRepository
119120

121+
@Inject
122+
internal lateinit var customerListRepository: CustomerListRepository
123+
120124
private var tracker: SelectionTracker<Long>? = null
121125
private var actionMode: ActionMode? = null
122126
private val selectionPredicate = MutableMultipleSelectionPredicate<Long>(
@@ -930,6 +934,7 @@ class OrderListFragment :
930934
OrderListFilterCategory.CUSTOMER,
931935
listOf(customerId.toString())
932936
)
937+
orderFiltersRepository.loadCustomerInfoIfNeeded(customerId)
933938
viewModel.loadOrders()
934939
uiMessageResolver.showSnack(R.string.order_list_customer_filter_applied)
935940
}

0 commit comments

Comments
 (0)