fix: 阅读界面电量显示
This commit is contained in:
1 file changed
+8
-8
@@ -46,9 +46,9 @@ import io.legado.app.ui.replace.ReplaceEditRoute
|
||||
import io.legado.app.ui.replace.ReplaceRuleActivity
|
||||
import io.legado.app.utils.StartActivityContract
|
||||
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.yield
|
||||
|
||||
|
||||
data class ReadBookViewRefs(
|
||||
@@ -233,9 +233,11 @@ fun ReadBookRouteScreen(
|
||||
// ── Effect collection: route handles launcher effects, rest goes to bridge ──
|
||||
|
||||
LaunchedEffect(viewModel) {
|
||||
coroutineScope {
|
||||
val collector = launch {
|
||||
viewModel.effects.collect { effect ->
|
||||
val effectsSubscribed = CompletableDeferred<Unit>()
|
||||
launch {
|
||||
viewModel.effects
|
||||
.onSubscription { effectsSubscribed.complete(Unit) }
|
||||
.collect { effect ->
|
||||
try {
|
||||
when (effect) {
|
||||
// Launcher-dependent effects — handled directly by route
|
||||
@@ -353,10 +355,8 @@ fun ReadBookRouteScreen(
|
||||
}
|
||||
}
|
||||
}
|
||||
yield()
|
||||
effectsSubscribed.await()
|
||||
onEffectsReady()
|
||||
collector.join()
|
||||
}
|
||||
}
|
||||
|
||||
// ── System UI sync ────────────────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user