diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsCard.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsCard.kt index 244c14dc219..561247c2419 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsCard.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsCard.kt @@ -98,7 +98,7 @@ fun DashboardStatsCard( currencyFormatter = viewModel.currencyFormatter, usageTracksEventEmitter = viewModel.usageTracksEventEmitter, onAddCustomRangeClick = viewModel::onAddCustomRangeClicked, - onTabSelected = viewModel::onTabSelected, + onTabSelected = viewModel::onRangeChanged, onChartDateSelected = viewModel::onChartDateSelected ) } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModel.kt index 664dc9c3969..e1cbe2a4f25 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModel.kt @@ -123,7 +123,7 @@ class DashboardStatsViewModel @AssistedInject constructor( trackLocalTimezoneDifferenceFromStore() } - fun onTabSelected(selectionType: SelectionType) { + fun onRangeChanged(selectionType: SelectionType) { parentViewModel.trackCardInteracted(DashboardWidget.Type.STATS.trackingIdentifier) usageTracksEventEmitter.interacted() if (selectionType != SelectionType.CUSTOM) { @@ -151,7 +151,7 @@ class DashboardStatsViewModel @AssistedInject constructor( viewModelScope.launch { customDateRangeDataStore.updateDateRange(range) if (dateRangeState.value?.rangeSelection?.selectionType != SelectionType.CUSTOM) { - onTabSelected(SelectionType.CUSTOM) + onRangeChanged(SelectionType.CUSTOM) } } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersViewModel.kt index 82c2828cb59..f279156a4fb 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersViewModel.kt @@ -140,7 +140,7 @@ class DashboardTopPerformersViewModel @AssistedInject constructor( } } - fun onTabSelected(selectionType: SelectionType) { + fun onRangeChanged(selectionType: SelectionType) { parentViewModel.trackCardInteracted(DashboardWidget.Type.POPULAR_PRODUCTS.trackingIdentifier) usageTracksEventEmitter.interacted() if (selectionType != SelectionType.CUSTOM) { @@ -287,7 +287,7 @@ class DashboardTopPerformersViewModel @AssistedInject constructor( viewModelScope.launch { customDateRangeDataStore.updateDateRange(statsTimeRange) if (selectedDateRange.value?.rangeSelection?.selectionType != SelectionType.CUSTOM) { - onTabSelected(SelectionType.CUSTOM) + onRangeChanged(SelectionType.CUSTOM) } } } diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersWidgetCard.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersWidgetCard.kt index 9a06d8d7352..1b3a2e9ed90 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersWidgetCard.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/dashboard/topperformers/DashboardTopPerformersWidgetCard.kt @@ -95,7 +95,7 @@ fun DashboardTopPerformersWidgetCard( topPerformersState = topPerformersState, selectedDateRange = selectedDateRange, lastUpdateState = lastUpdateState, - onTabSelected = topPerformersViewModel::onTabSelected, + onTabSelected = topPerformersViewModel::onRangeChanged, onEditCustomRangeTapped = topPerformersViewModel::onEditCustomRangeTapped ) } diff --git a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModelTest.kt b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModelTest.kt index 6495032b0f4..27d868d8046 100644 --- a/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModelTest.kt +++ b/WooCommerce/src/test/kotlin/com/woocommerce/android/ui/dashboard/stats/DashboardStatsViewModelTest.kt @@ -141,7 +141,7 @@ class DashboardStatsViewModelTest : BaseUnitTest() { whenever(networkStatus.isConnected()).thenReturn(false) } - viewModel.onTabSelected(ANY_SELECTION_TYPE) + viewModel.onRangeChanged(ANY_SELECTION_TYPE) verify(getStats, never()).invoke(any(), any()) } @@ -155,7 +155,7 @@ class DashboardStatsViewModelTest : BaseUnitTest() { .thenReturn(ANY_SELECTION_TYPE.name) } - viewModel.onTabSelected(ANY_SELECTION_TYPE) + viewModel.onRangeChanged(ANY_SELECTION_TYPE) verify(getStats, times(2)).invoke( refresh = ArgumentMatchers.eq(false), @@ -196,7 +196,7 @@ class DashboardStatsViewModelTest : BaseUnitTest() { .thenReturn(ANY_SELECTION_TYPE.name) } - viewModel.onTabSelected(ANY_SELECTION_TYPE) + viewModel.onRangeChanged(ANY_SELECTION_TYPE) Assertions.assertThat(viewModel.revenueStatsState.value) .isInstanceOf(DashboardStatsViewModel.RevenueStatsViewState.Content::class.java) @@ -209,7 +209,7 @@ class DashboardStatsViewModelTest : BaseUnitTest() { testBlocking { setup() - viewModel.onTabSelected(ANY_SELECTION_TYPE) + viewModel.onRangeChanged(ANY_SELECTION_TYPE) verify(appPrefsWrapper).setActiveStatsTab(ANY_SELECTION_TYPE.name) } @@ -286,7 +286,7 @@ class DashboardStatsViewModelTest : BaseUnitTest() { val state = viewModel.dateRangeState.runAndCaptureValues { viewModel.onChartDateSelected("11") - viewModel.onTabSelected(ANY_SELECTION_TYPE) + viewModel.onRangeChanged(ANY_SELECTION_TYPE) }.last() verify(dateRangeFormatter, never())