File tree Expand file tree Collapse file tree 3 files changed +15
-15
lines changed
WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders Expand file tree Collapse file tree 3 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -367,13 +367,17 @@ class OrderFilterCategoriesViewModel @Inject constructor(
367367
368368 private suspend fun getCustomerDisplayValueFrom (customerId : Long? ): String =
369369 customerId?.let { id ->
370- orderFilterRepository.customerFilterDisplayName
371- ? : customerStore.getCustomerByRemoteId(selectedSite.get(), id)
372- ?.let { customer ->
373- (customer.firstName + " " + customer.lastName)
374- .ifBlank { customer.email }
375- .ifBlank { customer.username }
376- } ? : resourceProvider.getString(
370+ orderFilterRepository.customerFilterCustomer?.let { customer ->
371+ buildString {
372+ val fullName = " ${customer.firstName.orEmpty()} ${customer.lastName.orEmpty()} " .trim()
373+ append(fullName.ifBlank { customer.email ? : customer.username.orEmpty() })
374+ }
375+ } ? : customerStore.getCustomerByRemoteId(selectedSite.get(), id)
376+ ?.let { customer ->
377+ (customer.firstName + " " + customer.lastName)
378+ .ifBlank { customer.email }
379+ .ifBlank { customer.username }
380+ } ? : resourceProvider.getString(
377381 R .string.orderfilters_selected_filter_fallback_display_value,
378382 id
379383 )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.woocommerce.android.ui.orders.filters.data
22
33import com.woocommerce.android.AppPrefsWrapper
44import com.woocommerce.android.di.AppCoroutineScope
5+ import com.woocommerce.android.model.Order
56import com.woocommerce.android.tools.SelectedSite
67import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.CUSTOMER
78import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory.PRODUCT
@@ -22,15 +23,15 @@ class OrderFiltersRepository @Inject constructor(
2223
2324 var customerFilter: Long? = null
2425
25- var customerFilterDisplayName : String ? = null
26+ var customerFilterCustomer : Order . Customer ? = null
2627
2728 init {
2829 selectedSite.observe()
2930 .distinctUntilChanged { old, new -> old?.id == new?.id }
3031 .onEach {
3132 productFilter = null
3233 customerFilter = null
33- customerFilterDisplayName = null
34+ customerFilterCustomer = null
3435 }.launchIn(appCoroutineScope)
3536 }
3637
Original file line number Diff line number Diff line change @@ -927,13 +927,8 @@ class OrderListFragment :
927927 searchQuery = " "
928928 val customerId = customer.customerId ? : return
929929
930- val displayName = buildString {
931- val fullName = " ${customer.firstName.orEmpty()} ${customer.lastName.orEmpty()} " .trim()
932- append(fullName.ifBlank { customer.email ? : customer.username.orEmpty() })
933- }
934-
935930 orderFiltersRepository.customerFilter = customerId
936- orderFiltersRepository.customerFilterDisplayName = displayName
931+ orderFiltersRepository.customerFilterCustomer = customer
937932 viewModel.loadOrders()
938933
939934 uiMessageResolver.showSnack(R .string.order_list_customer_filter_applied)
You can’t perform that action at this time.
0 commit comments