Skip to content

Commit

Permalink
Revert "[#3592] Use the currentBase stored in preference at onResume (#…
Browse files Browse the repository at this point in the history
…3594)"

This reverts commit 583c415.
  • Loading branch information
mustafaozhan committed Jun 30, 2024
1 parent a623fb4 commit e9174c9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class CalculatorFragment : BaseVBFragment<FragmentCalculatorBinding>() {
super.onResume()
Logger.i { "CalculatorFragment onResume" }
analyticsManager.trackScreen(ScreenName.Calculator)
calculatorViewModel.event.onBaseChange(null)
}

override fun onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface CalculatorEvent : BaseEvent {
fun onPasteToInput(text: String)
fun onBarClick()
fun onSettingsClicked()
fun onBaseChange(base: String?)
fun onBaseChange(base: String)
}

// Effect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,9 @@ class CalculatorViewModel(
_effect.emit(CalculatorEffect.OpenSettings)
}

override fun onBaseChange(base: String?) {
override fun onBaseChange(base: String) {
Logger.d { "CalculatorViewModel onBaseChange $base" }
val newBase = base ?: calculationStorage.currentBase
currentBaseChanged(newBase)
currentBaseChanged(base)
calculateOutput(_state.value.input)
}
// endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,6 @@ internal class CalculatorViewModelTest {
}
}

@Test
fun `when app resumes it calls onBaseChange with null and it sets the base according to the preference`() =
runTest {
every { calculationStorage.currentBase }
.returns(currency1.code)

everySuspend { backendApiService.getConversion(currency1.code) }
.returns(conversion)

viewModel.state.onSubscription {
viewModel.event.onBaseChange(null)
}.firstOrNull().let {
assertNotNull(it)
assertNotNull(viewModel.data.conversion)
assertEquals(currency1.code, viewModel.data.conversion!!.base)
assertEquals(currency1.code, it.base)

verify { analyticsManager.trackEvent(Event.BaseChange(Param.Base(currency1.code))) }
verify { analyticsManager.setUserProperty(UserProperty.BaseCurrency(currency1.code)) }
}
}

// Event
@Test
fun onBarClick() = runTest {
Expand Down

0 comments on commit e9174c9

Please sign in to comment.