Skip to content

Commit

Permalink
Rename function to remove the old concept of "tab"
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeMucientes committed Dec 3, 2024
1 parent d431e71 commit f4e045c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fun DashboardStatsCard(
currencyFormatter = viewModel.currencyFormatter,
usageTracksEventEmitter = viewModel.usageTracksEventEmitter,
onAddCustomRangeClick = viewModel::onAddCustomRangeClicked,
onTabSelected = viewModel::onTabSelected,
onTabSelected = viewModel::onRangeChanged,
onChartDateSelected = viewModel::onChartDateSelected
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fun DashboardTopPerformersWidgetCard(
topPerformersState = topPerformersState,
selectedDateRange = selectedDateRange,
lastUpdateState = lastUpdateState,
onTabSelected = topPerformersViewModel::onTabSelected,
onTabSelected = topPerformersViewModel::onRangeChanged,
onEditCustomRangeTapped = topPerformersViewModel::onEditCustomRangeTapped
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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),
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit f4e045c

Please sign in to comment.