mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 10:41:50 +01:00
Maybe avoid extensions list rendering crashes
This commit is contained in:
parent
fbda243c0d
commit
4138a17e29
@ -119,14 +119,14 @@ private fun ExtensionContent(
|
|||||||
items = state.items,
|
items = state.items,
|
||||||
contentType = {
|
contentType = {
|
||||||
when (it) {
|
when (it) {
|
||||||
|
is ExtensionUiModel.Header -> "header"
|
||||||
is ExtensionUiModel.Item -> "item"
|
is ExtensionUiModel.Item -> "item"
|
||||||
else -> "header"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
key = {
|
key = {
|
||||||
when (it) {
|
when (it) {
|
||||||
is ExtensionUiModel.Header -> "extensionHeader-${it.hashCode()}"
|
is ExtensionUiModel.Header -> "extensionHeader-${it.hashCode()}"
|
||||||
is ExtensionUiModel.Item -> "extension-${it.extension.hashCode()}"
|
is ExtensionUiModel.Item -> "extension-${it.hashCode()}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) { item ->
|
) { item ->
|
||||||
|
@ -52,7 +52,7 @@ import java.util.Date
|
|||||||
fun LazyListScope.updatesLastUpdatedItem(
|
fun LazyListScope.updatesLastUpdatedItem(
|
||||||
lastUpdated: Long,
|
lastUpdated: Long,
|
||||||
) {
|
) {
|
||||||
item(key = "last_updated") {
|
item(key = "updates-lastUpdated") {
|
||||||
val time = remember(lastUpdated) {
|
val time = remember(lastUpdated) {
|
||||||
DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS)
|
DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS)
|
||||||
}
|
}
|
||||||
@ -92,8 +92,8 @@ fun LazyListScope.updatesUiItems(
|
|||||||
},
|
},
|
||||||
key = {
|
key = {
|
||||||
when (it) {
|
when (it) {
|
||||||
is UpdatesUiModel.Header -> it.hashCode()
|
is UpdatesUiModel.Header -> "updatesHeader-${it.hashCode()}"
|
||||||
is UpdatesUiModel.Item -> "updates-${it.item.update.chapterId}"
|
is UpdatesUiModel.Item -> "updates-${it.item.update.mangaId}-${it.item.update.chapterId}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) { item ->
|
) { item ->
|
||||||
|
@ -20,6 +20,7 @@ import kotlinx.coroutines.flow.StateFlow
|
|||||||
import kotlinx.coroutines.flow.asStateFlow
|
import kotlinx.coroutines.flow.asStateFlow
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.combine
|
import kotlinx.coroutines.flow.combine
|
||||||
|
import kotlinx.coroutines.flow.debounce
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
@ -114,10 +115,12 @@ class ExtensionsPresenter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
items
|
items
|
||||||
}.collectLatest {
|
|
||||||
state.isLoading = false
|
|
||||||
state.items = it
|
|
||||||
}
|
}
|
||||||
|
.debounce(500) // Avoid crashes due to LazyColumn rendering
|
||||||
|
.collectLatest {
|
||||||
|
state.isLoading = false
|
||||||
|
state.items = it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
presenterScope.launchIO { findAvailableExtensions() }
|
presenterScope.launchIO { findAvailableExtensions() }
|
||||||
|
Loading…
Reference in New Issue
Block a user