mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 16:10:00 +00:00
AppNav: introduce a owner param so we avoid crash on AppNavigationState when switching quickly between screens
This commit is contained in:
+14
-6
@@ -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)
|
||||
}
|
||||
|
||||
+8
-8
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user