From 00ea180d9cea54284831fb3df486756acda2a9f7 Mon Sep 17 00:00:00 2001 From: Saad Nadeem Date: Sat, 22 Aug 2026 05:37:20 -0400 Subject: [PATCH 1/2] fix(ui): open non-animated pages immediately --- .../polyfrost/oneconfig/internal/ui/OneConfigInterface.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt index 296790546..7f452ffbf 100644 --- a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt +++ b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt @@ -39,6 +39,7 @@ import androidx.compose.ui.unit.Density import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner import androidx.navigation.compose.rememberNavController +import kotlinx.coroutines.flow.first import org.apache.logging.log4j.LogManager import org.polyfrost.oneconfig.internal.OneConfigConfig import org.polyfrost.oneconfig.internal.ui.hud.screens.HudDragLayer @@ -91,10 +92,12 @@ fun OneConfigInterface( // the page is only being put back which should look like it was never left ShellState.initialTransitionConsumed = false ShellState.animateOpeningPage = !restoring && OneConfigConfig.showOpeningPageAnimation + // non-animated opens navigate instantly when the graph is ready + if (!ShellState.animateOpeningPage) LocalNavController.current.currentBackStackEntryFlow.first() // the NavHost only sets its graph once the Shell is composed so wait for it or navigate() // crashes with "must call setGraph() before getGraph()" var attempts = 0 - while (attempts++ < 600) { + while (ShellState.animateOpeningPage && attempts++ < 600) { val ready = try { LocalNavController.current.graph; true } catch (_: IllegalStateException) { From 1a7db93128eb4003bd83fdc9ed1cda305897ec89 Mon Sep 17 00:00:00 2001 From: Julian Chang Date: Sun, 23 Aug 2026 05:15:30 +0700 Subject: [PATCH 2/2] minor fix --- .../internal/ui/OneConfigInterface.kt | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt index 7f452ffbf..21f118acc 100644 --- a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt +++ b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/OneConfigInterface.kt @@ -40,6 +40,7 @@ import androidx.lifecycle.compose.LocalLifecycleOwner import androidx.lifecycle.viewmodel.compose.LocalViewModelStoreOwner import androidx.navigation.compose.rememberNavController import kotlinx.coroutines.flow.first +import kotlinx.coroutines.withTimeoutOrNull import org.apache.logging.log4j.LogManager import org.polyfrost.oneconfig.internal.OneConfigConfig import org.polyfrost.oneconfig.internal.ui.hud.screens.HudDragLayer @@ -61,6 +62,8 @@ fun guiCloseAnimationMillis(): Long = private const val MAX_CLOSE_ANIMATION_MS = 160L +private const val GRAPH_WAIT_TIMEOUT_MS = 10_000L + @Composable fun OneConfigInterface( windowWidth: Float, @@ -92,19 +95,23 @@ fun OneConfigInterface( // the page is only being put back which should look like it was never left ShellState.initialTransitionConsumed = false ShellState.animateOpeningPage = !restoring && OneConfigConfig.showOpeningPageAnimation - // non-animated opens navigate instantly when the graph is ready - if (!ShellState.animateOpeningPage) LocalNavController.current.currentBackStackEntryFlow.first() // the NavHost only sets its graph once the Shell is composed so wait for it or navigate() // crashes with "must call setGraph() before getGraph()" - var attempts = 0 - while (ShellState.animateOpeningPage && attempts++ < 600) { - val ready = try { - LocalNavController.current.graph; true - } catch (_: IllegalStateException) { - false + if (ShellState.animateOpeningPage) { + var attempts = 0 + while (attempts++ < 600) { + val ready = try { + LocalNavController.current.graph; true + } catch (_: IllegalStateException) { + false + } + if (ready) break + withFrameNanos { } + } + } else { + withTimeoutOrNull(GRAPH_WAIT_TIMEOUT_MS) { + LocalNavController.current.currentBackStackEntryFlow.first() } - if (ready) break - withFrameNanos { } } try { LocalNavController.wrapper.navigate(initialRoute, clearSearch = !resuming)