fix: 阅读界面电量显示

This commit is contained in:
HapeLee
2026-06-09 13:08:05 +08:00
parent 0adb3a1484
commit b731d201c1
@@ -46,9 +46,9 @@ import io.legado.app.ui.replace.ReplaceEditRoute
import io.legado.app.ui.replace.ReplaceRuleActivity import io.legado.app.ui.replace.ReplaceRuleActivity
import io.legado.app.utils.StartActivityContract import io.legado.app.utils.StartActivityContract
import io.legado.app.utils.takePersistablePermissionSafely import io.legado.app.utils.takePersistablePermissionSafely
import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.flow.onSubscription
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.yield
data class ReadBookViewRefs( data class ReadBookViewRefs(
@@ -233,9 +233,11 @@ fun ReadBookRouteScreen(
// ── Effect collection: route handles launcher effects, rest goes to bridge ── // ── Effect collection: route handles launcher effects, rest goes to bridge ──
LaunchedEffect(viewModel) { LaunchedEffect(viewModel) {
coroutineScope { val effectsSubscribed = CompletableDeferred<Unit>()
val collector = launch { launch {
viewModel.effects.collect { effect -> viewModel.effects
.onSubscription { effectsSubscribed.complete(Unit) }
.collect { effect ->
try { try {
when (effect) { when (effect) {
// Launcher-dependent effects — handled directly by route // Launcher-dependent effects — handled directly by route
@@ -353,10 +355,8 @@ fun ReadBookRouteScreen(
} }
} }
} }
yield() effectsSubscribed.await()
onEffectsReady() onEffectsReady()
collector.join()
}
} }
// ── System UI sync ──────────────────────────────────────────────── // ── System UI sync ────────────────────────────────────────────────