diff --git a/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/SettingsViewModel.kt b/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/SettingsViewModel.kt index f92d92aa01..0bcd0a402b 100644 --- a/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/SettingsViewModel.kt +++ b/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/SettingsViewModel.kt @@ -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 @@ -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 @@ -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) }, diff --git a/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/tabs/media/source/MediaSourceGroupState.kt b/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/tabs/media/source/MediaSourceGroupState.kt index 851aae7c71..73b301c2a7 100644 --- a/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/tabs/media/source/MediaSourceGroupState.kt +++ b/app/shared/ui-settings/src/commonMain/kotlin/ui/settings/tabs/media/source/MediaSourceGroupState.kt @@ -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 @@ -126,7 +135,7 @@ class MediaSourceGroupState( class EditMediaSourceState( private val getConfigFlow: (instanceId: String) -> Flow, - 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, @@ -182,6 +191,7 @@ class EditMediaSourceState( is EditMediaSourceMode.Add -> { onAdd( state.factoryId, + state.editingMediaSourceId, state.createConfig(), ) withContext(Dispatchers.Main) { cancelEdit() }