Skip to content

Commit

Permalink
修复初次添加 RSS/Selector 数据源时编辑配置无效
Browse files Browse the repository at this point in the history
  • Loading branch information
Him188 committed Sep 23, 2024
1 parent d16aef7 commit 98da565
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright (C) 2024 OpenAni and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link.
*
* https://github.com/open-ani/ani/blob/main/LICENSE
*/

package me.him188.ani.app.ui.settings

import androidx.compose.runtime.derivedStateOf
Expand Down Expand Up @@ -41,7 +50,6 @@ import me.him188.ani.datasources.api.source.asAutoCloseable
import me.him188.ani.datasources.api.subject.SubjectProvider
import me.him188.ani.datasources.bangumi.BangumiSubjectProvider
import me.him188.ani.utils.ktor.createDefaultHttpClient
import me.him188.ani.utils.platform.Uuid
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject

Expand Down Expand Up @@ -177,8 +185,7 @@ class SettingsViewModel : AbstractSettingsViewModel(), KoinComponent {
checkNotNull(it) { "Could not find MediaSourceConfig for id $id" }
}
},
onAdd = { factoryId, config ->
val instanceId = Uuid.randomString()
onAdd = { factoryId, instanceId, config ->
mediaSourceManager.addInstance(instanceId, instanceId, factoryId, config)
},
onEdit = { instanceId, config -> mediaSourceManager.updateConfig(instanceId, config) },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright (C) 2024 OpenAni and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license, which can be found at the following link.
*
* https://github.com/open-ani/ani/blob/main/LICENSE
*/

package me.him188.ani.app.ui.settings.tabs.media.source

import androidx.compose.runtime.Immutable
Expand Down Expand Up @@ -126,7 +135,7 @@ class MediaSourceGroupState(

class EditMediaSourceState(
private val getConfigFlow: (instanceId: String) -> Flow<MediaSourceConfig>,
private val onAdd: suspend (factoryId: FactoryId, config: MediaSourceConfig) -> Unit,
private val onAdd: suspend (factoryId: FactoryId, instanceId: String, config: MediaSourceConfig) -> Unit,
private val onEdit: suspend (instanceId: String, config: MediaSourceConfig) -> Unit,
private val onDelete: suspend (instanceId: String) -> Unit,
private val onSetEnabled: suspend (instanceId: String, enabled: Boolean) -> Unit,
Expand Down Expand Up @@ -182,6 +191,7 @@ class EditMediaSourceState(
is EditMediaSourceMode.Add -> {
onAdd(
state.factoryId,
state.editingMediaSourceId,
state.createConfig(),
)
withContext(Dispatchers.Main) { cancelEdit() }
Expand Down

0 comments on commit 98da565

Please sign in to comment.