Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- [Internal][Wear] Remove unused dependencies and optimize dependency scopes [https://github.com/woocommerce/woocommerce-android/pull/14710]
- [Internal] Remove unused dependencies and optimize dependency scopes [https://github.com/woocommerce/woocommerce-android/pull/14710]
- [*] Fix a rare crash in order refund flow [https://github.com/woocommerce/woocommerce-android/pull/14742]
- [*] Fix customer name display when filtering orders from order details [https://github.com/woocommerce/woocommerce-android/pull/14761]

23.4
-----
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.wordpress.android.fluxc.store.WCCustomerStore
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class OrderFiltersRepository @Inject constructor(
private val appSharedPrefs: AppPrefsWrapper,
private val customerStore: WCCustomerStore,
private val selectedSite: SelectedSite,
@AppCoroutineScope private val appCoroutineScope: CoroutineScope
) {
Expand Down Expand Up @@ -56,6 +59,14 @@ class OrderFiltersRepository @Inject constructor(
}
}

fun loadCustomerInfoIfNeeded(customerId: Long) {
appCoroutineScope.launch {
if (customerStore.getCustomerByRemoteId(selectedSite.get(), customerId) == null) {
customerStore.fetchSingleCustomer(selectedSite.get(), customerId)
}
}
}

fun getCurrentFilterSelection(filterCategory: OrderListFilterCategory): List<String> {
val preferenceFilters = selectedSite.getIfExists()?.let { site ->
appSharedPrefs.getOrderFilters(site.id, filterCategory.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import com.woocommerce.android.ui.orders.OrdersCommunicationViewModel
import com.woocommerce.android.ui.orders.creation.CodeScannerStatus
import com.woocommerce.android.ui.orders.creation.GoogleBarcodeFormatMapper.BarcodeFormat
import com.woocommerce.android.ui.orders.creation.OrderCreateEditViewModel
import com.woocommerce.android.ui.orders.creation.customerlist.CustomerListRepository
import com.woocommerce.android.ui.orders.details.OrderStatusSelectorDialog
import com.woocommerce.android.ui.orders.filters.data.OrderFiltersRepository
import com.woocommerce.android.ui.orders.filters.data.OrderListFilterCategory
Expand Down Expand Up @@ -117,6 +118,9 @@ class OrderListFragment :
@Inject
internal lateinit var orderFiltersRepository: OrderFiltersRepository

@Inject
internal lateinit var customerListRepository: CustomerListRepository

private var tracker: SelectionTracker<Long>? = null
private var actionMode: ActionMode? = null
private val selectionPredicate = MutableMultipleSelectionPredicate<Long>(
Expand Down Expand Up @@ -930,6 +934,7 @@ class OrderListFragment :
OrderListFilterCategory.CUSTOMER,
listOf(customerId.toString())
)
orderFiltersRepository.loadCustomerInfoIfNeeded(customerId)
viewModel.loadOrders()
uiMessageResolver.showSnack(R.string.order_list_customer_filter_applied)
}
Expand Down
Loading