goBack() now uses ChatScreen as a fallback when the stack has only one item, preventing the Settings back-button crash. Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
62b1115924
commit
c6d7a45905
2 files changed
+16
-6
No files matched your search
@@ -53,8 +53,17 @@ object NavigationController {
|
||||
backStack?.add(key)
|
||||
}
|
||||
|
||||
fun goBack() {
|
||||
/**
|
||||
* Navigate back one step, or fall back to [fallback] when the stack has only one item.
|
||||
* Never leaves the stack empty.
|
||||
*/
|
||||
fun goBack(fallback: NavKey = ChatScreen) {
|
||||
val stack = backStack ?: return
|
||||
if (stack.size > 1) stack.removeLastOrNull()
|
||||
if (stack.size > 1) {
|
||||
stack.removeLastOrNull()
|
||||
} else if (stack.size == 1) {
|
||||
stack.clear()
|
||||
stack.add(fallback)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user