Skip to content

Commit

Permalink
fix: address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ohassine committed Jan 10, 2025
1 parent aa0bce5 commit d4dfca8
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions app/src/main/kotlin/com/wire/android/util/CurrentScreenManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,22 @@ class CurrentScreenManager @Inject constructor(
}

override fun onDestinationChanged(controller: NavController, destination: NavDestination, arguments: Bundle?) {
val currentView = currentScreenState.value
handleViewAction(currentView) { screenName ->
AnonymousAnalyticsManagerImpl.stopView(screenName)
}
val currentScreenName = currentScreenName()
AnonymousAnalyticsManagerImpl.stopView(currentScreenName)

val currentItem = destination.toDestination()
currentScreenState.value = CurrentScreen.fromDestination(
currentItem,
arguments,
isApplicationVisibleFlow.value
)

val newView = currentScreenState.value
handleViewAction(newView) { screenName ->
AnonymousAnalyticsManagerImpl.recordView(screenName)
}
val newScreenName = currentScreenName()
AnonymousAnalyticsManagerImpl.recordView(newScreenName)
}

private fun handleViewAction(screen: CurrentScreen, action: (String) -> Unit) {
val screenName = (screen as? CurrentScreen.SomeOther)?.route ?: screen.javaClass.simpleName
action(screenName)
private fun currentScreenName() = currentScreenState.value.let { currentScreen ->
(currentScreen as? CurrentScreen.SomeOther)?.route ?: currentScreen.javaClass.simpleName
}

override fun onCreate(owner: LifecycleOwner) {
Expand Down

0 comments on commit d4dfca8

Please sign in to comment.