From 98da56583a7a9199f1a00e50a8795565dfe55783 Mon Sep 17 00:00:00 2001 From: Him188 Date: Mon, 23 Sep 2024 21:54:03 +0100 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9D=E6=AC=A1=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20RSS/Selector=20=E6=95=B0=E6=8D=AE=E6=BA=90=E6=97=B6?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=85=8D=E7=BD=AE=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/ui/settings/SettingsViewModel.kt | 13 ++++++++++--- .../tabs/media/source/MediaSourceGroupState.kt | 12 +++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) 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() }