Fix intent emitted before collection being missed
This commit is contained in:
1 parent
828a3d09b6
commit
124ff2f190
1 file changed
+8
-4
@@ -129,9 +129,12 @@ import com.ramcosta.composedestinations.utils.currentDestinationAsState
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import kotlinx.coroutines.launch
|
||||
import moe.tarsin.coroutines.runSuspendCatching
|
||||
import splitties.systemservices.clipboardManager
|
||||
@@ -187,11 +190,12 @@ class MainActivity : EhActivity() {
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
super.onNewIntent(intent)
|
||||
intentFlow.tryEmit(intent)
|
||||
intentChannel.trySend(intent)
|
||||
}
|
||||
|
||||
private val tipFlow = MutableSharedFlow<String>(extraBufferCapacity = 1)
|
||||
private val intentFlow = MutableSharedFlow<Intent>(extraBufferCapacity = 4)
|
||||
private val intentChannel = Channel<Intent>(capacity = 4, onBufferOverflow = BufferOverflow.DROP_OLDEST)
|
||||
private val intentFlow = intentChannel.receiveAsFlow()
|
||||
|
||||
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -211,8 +215,8 @@ class MainActivity : EhActivity() {
|
||||
|
||||
val cannotParse = stringResource(R.string.error_cannot_parse_the_url)
|
||||
LaunchedEffect(Unit) {
|
||||
intentFlow.collect {
|
||||
when (intent?.action) {
|
||||
intentFlow.collect { intent ->
|
||||
when (intent.action) {
|
||||
Intent.ACTION_VIEW -> {
|
||||
val url = intent.data?.toString()
|
||||
if (url != null && !navController.navWithUrl(url)) {
|
||||
|
||||
Reference in new issue
Block a user