AppNav: introduce a owner param so we avoid crash on AppNavigationState when switching quickly between screens
This commit is contained in:
parent
105fce0b90
commit
a0da28b1ec
6 changed files with 73 additions and 49 deletions
|
|
@ -21,26 +21,34 @@ import io.element.android.libraries.matrix.api.core.SessionId
|
|||
import io.element.android.libraries.matrix.api.core.SpaceId
|
||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
|
||||
sealed interface AppNavigationState {
|
||||
object Root : AppNavigationState
|
||||
/**
|
||||
* Can represent the current global app navigation state.
|
||||
* @param owner mostly a Node identifier associated with the state.
|
||||
*/
|
||||
sealed class AppNavigationState(open val owner: String) {
|
||||
object Root : AppNavigationState("ROOT")
|
||||
|
||||
data class Session(
|
||||
override val owner: String,
|
||||
val sessionId: SessionId,
|
||||
) : AppNavigationState
|
||||
) : AppNavigationState(owner)
|
||||
|
||||
data class Space(
|
||||
override val owner: String,
|
||||
// Can be fake value, if no space is selected
|
||||
val spaceId: SpaceId,
|
||||
val parentSession: Session,
|
||||
) : AppNavigationState
|
||||
) : AppNavigationState(owner)
|
||||
|
||||
data class Room(
|
||||
override val owner: String,
|
||||
val roomId: RoomId,
|
||||
val parentSpace: Space,
|
||||
) : AppNavigationState
|
||||
) : AppNavigationState(owner)
|
||||
|
||||
data class Thread(
|
||||
override val owner: String,
|
||||
val threadId: ThreadId,
|
||||
val parentRoom: Room,
|
||||
) : AppNavigationState
|
||||
) : AppNavigationState(owner)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,15 +25,15 @@ import kotlinx.coroutines.flow.StateFlow
|
|||
interface AppNavigationStateService {
|
||||
val appNavigationStateFlow: StateFlow<AppNavigationState>
|
||||
|
||||
fun onNavigateToSession(sessionId: SessionId)
|
||||
fun onLeavingSession()
|
||||
fun onNavigateToSession(owner: String, sessionId: SessionId)
|
||||
fun onLeavingSession(owner: String)
|
||||
|
||||
fun onNavigateToSpace(spaceId: SpaceId)
|
||||
fun onLeavingSpace()
|
||||
fun onNavigateToSpace(owner: String, spaceId: SpaceId)
|
||||
fun onLeavingSpace(owner: String)
|
||||
|
||||
fun onNavigateToRoom(roomId: RoomId)
|
||||
fun onLeavingRoom()
|
||||
fun onNavigateToRoom(owner: String, roomId: RoomId)
|
||||
fun onLeavingRoom(owner: String)
|
||||
|
||||
fun onNavigateToThread(threadId: ThreadId)
|
||||
fun onLeavingThread()
|
||||
fun onNavigateToThread(owner: String, threadId: ThreadId)
|
||||
fun onLeavingThread(owner: String)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue