fix: 阅读界面电量显示
This commit is contained in:
@@ -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 ────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user