Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd70e030 authored by Shawn Lee's avatar Shawn Lee Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Clear session storage if we are idle on Gone scene" into main

parents 3a4fae41 81f31fd3
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -172,12 +172,28 @@ constructor(

    private fun resetShadeSessions() {
        applicationScope.launch {
            combine(
                    sceneBackInteractor.backStack
                        // We are in a session if either Shade or QuickSettings is on the back stack
                        .map { backStack ->
                    backStack.asIterable().any { it == Scenes.Shade || it == Scenes.QuickSettings }
                            backStack.asIterable().any {
                                it == Scenes.Shade || it == Scenes.QuickSettings
                            }
                        }
                        .distinctUntilChanged(),
                    sceneInteractor.transitionState
                        .mapNotNull { state ->
                            // We are also in a session if either Shade or QuickSettings is the
                            // current scene
                            when (state) {
                                is ObservableTransitionState.Idle -> state.currentScene
                                is ObservableTransitionState.Transition -> state.fromScene
                            }.let { it == Scenes.Shade || it == Scenes.QuickSettings }
                        }
                        .distinctUntilChanged()
                ) { inBackStack, isCurrentScene ->
                    inBackStack || isCurrentScene
                }
                // Once a session has ended, clear the session storage.
                .filter { inSession -> !inSession }
                .collect { shadeSessionStorage.clear() }