fix: deduplicate LUT, frame, and DCP lists to prevent Compose key collisions
This commit is contained in:
1 parent
e37f1c435c
commit
420bebd219
5 files changed
+6
-6
No files matched your search
@@ -52,7 +52,7 @@ class FrameManager(private val context: Context) {
|
||||
fun initialize() {
|
||||
val builtInFrames = FrameTemplateParser.listAvailableFrames(context)
|
||||
val customFrames = customImportManager.getCustomFrames()
|
||||
availableFrames = builtInFrames + customFrames
|
||||
availableFrames = (builtInFrames + customFrames).distinctBy { it.id }
|
||||
PLog.d(TAG, "Found ${availableFrames.size} frame templates (${builtInFrames.size} built-in, ${customFrames.size} custom)")
|
||||
}
|
||||
|
||||
|
||||
@@ -165,8 +165,8 @@ class LutManager(private val context: Context) {
|
||||
val categoryOverrides = customImportManager.getCategoryOverrides()
|
||||
val favoriteOverrides = customImportManager.getFavoriteOverrides()
|
||||
|
||||
// 合并列表
|
||||
val allLuts = customLuts + builtInLuts
|
||||
// 合并列表并以 ID 去重,避免 ID 重复导致的 Jetpack Compose 主键重复崩溃
|
||||
val allLuts = (customLuts + builtInLuts).distinctBy { it.id }
|
||||
|
||||
// 应用分类重写 (用户手动创建的分类会通过这里恢复)
|
||||
availableLuts = allLuts.map { lut ->
|
||||
|
||||
@@ -862,7 +862,7 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
|
||||
}
|
||||
items(
|
||||
items = luts,
|
||||
key = { it.id }
|
||||
key = { "${groupTitle}_${it.id}" }
|
||||
) { lut ->
|
||||
val isSelected = lut.id == currentLutId
|
||||
Row(
|
||||
|
||||
@@ -7,7 +7,7 @@ class DcpManager(private val context: Context) {
|
||||
private val customImportManager = CustomImportManager(context)
|
||||
|
||||
fun getAvailableDcps(): List<DcpInfo> {
|
||||
return getBuiltInDcps() + customImportManager.getCustomDcps()
|
||||
return (getBuiltInDcps() + customImportManager.getCustomDcps()).distinctBy { it.id }
|
||||
}
|
||||
|
||||
private fun getBuiltInDcps(): List<DcpInfo> {
|
||||
|
||||
@@ -859,7 +859,7 @@ private fun ApplyLutScreen(
|
||||
modifier = Modifier.padding(top = 4.dp, bottom = 2.dp)
|
||||
)
|
||||
}
|
||||
items(luts, key = { it.id }) { lut ->
|
||||
items(luts, key = { "${groupTitle}_${it.id}" }) { lut ->
|
||||
val selectedLutId = currentPhotoLutId ?: lutData.third
|
||||
val isDefault = lut.id == selectedLutId
|
||||
Row(
|
||||
|
||||
Reference in new issue
Block a user