diff --git a/app/src/main/java/eu/kanade/domain/DomainModule.kt b/app/src/main/java/eu/kanade/domain/DomainModule.kt index 33be9a3b7..4f0c86eab 100644 --- a/app/src/main/java/eu/kanade/domain/DomainModule.kt +++ b/app/src/main/java/eu/kanade/domain/DomainModule.kt @@ -4,24 +4,24 @@ import eu.kanade.domain.chapter.interactor.GetAvailableScanlators import eu.kanade.domain.chapter.interactor.SetReadStatus import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource import eu.kanade.domain.download.interactor.DeleteDownload +import eu.kanade.domain.extension.interactor.CreateExtensionRepo +import eu.kanade.domain.extension.interactor.DeleteExtensionRepo import eu.kanade.domain.extension.interactor.GetExtensionLanguages +import eu.kanade.domain.extension.interactor.GetExtensionRepos import eu.kanade.domain.extension.interactor.GetExtensionSources import eu.kanade.domain.extension.interactor.GetExtensionsByType +import eu.kanade.domain.extension.interactor.TrustExtension import eu.kanade.domain.manga.interactor.GetExcludedScanlators import eu.kanade.domain.manga.interactor.SetExcludedScanlators import eu.kanade.domain.manga.interactor.SetMangaViewerFlags import eu.kanade.domain.manga.interactor.UpdateManga -import eu.kanade.domain.source.interactor.CreateSourceRepo -import eu.kanade.domain.source.interactor.DeleteSourceRepo import eu.kanade.domain.source.interactor.GetEnabledSources import eu.kanade.domain.source.interactor.GetLanguagesWithSources -import eu.kanade.domain.source.interactor.GetSourceRepos import eu.kanade.domain.source.interactor.GetSourcesWithFavoriteCount import eu.kanade.domain.source.interactor.SetMigrateSorting import eu.kanade.domain.source.interactor.ToggleLanguage import eu.kanade.domain.source.interactor.ToggleSource import eu.kanade.domain.source.interactor.ToggleSourcePin -import eu.kanade.domain.source.interactor.TrustExtension import eu.kanade.domain.track.interactor.AddTracks import eu.kanade.domain.track.interactor.RefreshTracks import eu.kanade.domain.track.interactor.SyncChapterProgressWithTrack @@ -173,8 +173,8 @@ class DomainModule : InjektModule { addFactory { ToggleSourcePin(get()) } addFactory { TrustExtension(get()) } - addFactory { CreateSourceRepo(get()) } - addFactory { DeleteSourceRepo(get()) } - addFactory { GetSourceRepos(get()) } + addFactory { CreateExtensionRepo(get()) } + addFactory { DeleteExtensionRepo(get()) } + addFactory { GetExtensionRepos(get()) } } } diff --git a/app/src/main/java/eu/kanade/domain/source/interactor/CreateSourceRepo.kt b/app/src/main/java/eu/kanade/domain/extension/interactor/CreateExtensionRepo.kt similarity index 82% rename from app/src/main/java/eu/kanade/domain/source/interactor/CreateSourceRepo.kt rename to app/src/main/java/eu/kanade/domain/extension/interactor/CreateExtensionRepo.kt index fc99f4e66..66b949fc9 100644 --- a/app/src/main/java/eu/kanade/domain/source/interactor/CreateSourceRepo.kt +++ b/app/src/main/java/eu/kanade/domain/extension/interactor/CreateExtensionRepo.kt @@ -1,9 +1,9 @@ -package eu.kanade.domain.source.interactor +package eu.kanade.domain.extension.interactor import eu.kanade.domain.source.service.SourcePreferences import tachiyomi.core.preference.plusAssign -class CreateSourceRepo(private val preferences: SourcePreferences) { +class CreateExtensionRepo(private val preferences: SourcePreferences) { fun await(name: String): Result { // Do not allow invalid formats diff --git a/app/src/main/java/eu/kanade/domain/source/interactor/DeleteSourceRepo.kt b/app/src/main/java/eu/kanade/domain/extension/interactor/DeleteExtensionRepo.kt similarity index 61% rename from app/src/main/java/eu/kanade/domain/source/interactor/DeleteSourceRepo.kt rename to app/src/main/java/eu/kanade/domain/extension/interactor/DeleteExtensionRepo.kt index 1bf109895..8762be0d0 100644 --- a/app/src/main/java/eu/kanade/domain/source/interactor/DeleteSourceRepo.kt +++ b/app/src/main/java/eu/kanade/domain/extension/interactor/DeleteExtensionRepo.kt @@ -1,9 +1,9 @@ -package eu.kanade.domain.source.interactor +package eu.kanade.domain.extension.interactor import eu.kanade.domain.source.service.SourcePreferences import tachiyomi.core.preference.minusAssign -class DeleteSourceRepo(private val preferences: SourcePreferences) { +class DeleteExtensionRepo(private val preferences: SourcePreferences) { fun await(repo: String) { preferences.extensionRepos() -= repo diff --git a/app/src/main/java/eu/kanade/domain/extension/interactor/GetExtensionRepos.kt b/app/src/main/java/eu/kanade/domain/extension/interactor/GetExtensionRepos.kt new file mode 100644 index 000000000..0d3b0e988 --- /dev/null +++ b/app/src/main/java/eu/kanade/domain/extension/interactor/GetExtensionRepos.kt @@ -0,0 +1,11 @@ +package eu.kanade.domain.extension.interactor + +import eu.kanade.domain.source.service.SourcePreferences +import kotlinx.coroutines.flow.Flow + +class GetExtensionRepos(private val preferences: SourcePreferences) { + + fun subscribe(): Flow> { + return preferences.extensionRepos().changes() + } +} diff --git a/app/src/main/java/eu/kanade/domain/source/interactor/TrustExtension.kt b/app/src/main/java/eu/kanade/domain/extension/interactor/TrustExtension.kt similarity index 95% rename from app/src/main/java/eu/kanade/domain/source/interactor/TrustExtension.kt rename to app/src/main/java/eu/kanade/domain/extension/interactor/TrustExtension.kt index cd0e02274..0ad6b2c56 100644 --- a/app/src/main/java/eu/kanade/domain/source/interactor/TrustExtension.kt +++ b/app/src/main/java/eu/kanade/domain/extension/interactor/TrustExtension.kt @@ -1,4 +1,4 @@ -package eu.kanade.domain.source.interactor +package eu.kanade.domain.extension.interactor import android.content.pm.PackageInfo import androidx.core.content.pm.PackageInfoCompat diff --git a/app/src/main/java/eu/kanade/domain/source/interactor/GetSourceRepos.kt b/app/src/main/java/eu/kanade/domain/source/interactor/GetSourceRepos.kt deleted file mode 100644 index fdebe8147..000000000 --- a/app/src/main/java/eu/kanade/domain/source/interactor/GetSourceRepos.kt +++ /dev/null @@ -1,13 +0,0 @@ -package eu.kanade.domain.source.interactor - -import eu.kanade.domain.source.service.SourcePreferences -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map - -class GetSourceRepos(private val preferences: SourcePreferences) { - - fun subscribe(): Flow> { - return preferences.extensionRepos().changes() - .map { it.sortedWith(String.CASE_INSENSITIVE_ORDER) } - } -} diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 9f046480e..4b8f2b9d7 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -24,7 +24,7 @@ import androidx.core.net.toUri import cafe.adriel.voyager.navigator.LocalNavigator import cafe.adriel.voyager.navigator.currentOrThrow import eu.kanade.domain.base.BasePreferences -import eu.kanade.domain.source.interactor.TrustExtension +import eu.kanade.domain.extension.interactor.TrustExtension import eu.kanade.presentation.more.settings.Preference import eu.kanade.presentation.more.settings.screen.advanced.ClearDatabaseScreen import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreen.kt index b9247f807..4801829d5 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreen.kt @@ -52,7 +52,7 @@ class ExtensionReposScreen( ExtensionRepoCreateDialog( onDismissRequest = screenModel::dismissDialog, onCreate = { screenModel.createRepo(it) }, - categories = successState.repos, + repos = successState.repos, ) } is RepoDialog.Delete -> { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreenModel.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreenModel.kt index fc1d3893c..353ad1bd6 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreenModel.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/ExtensionReposScreenModel.kt @@ -4,11 +4,11 @@ import androidx.compose.runtime.Immutable import cafe.adriel.voyager.core.model.StateScreenModel import cafe.adriel.voyager.core.model.screenModelScope import dev.icerock.moko.resources.StringResource -import eu.kanade.domain.source.interactor.CreateSourceRepo -import eu.kanade.domain.source.interactor.DeleteSourceRepo -import eu.kanade.domain.source.interactor.GetSourceRepos -import kotlinx.collections.immutable.ImmutableList -import kotlinx.collections.immutable.toImmutableList +import eu.kanade.domain.extension.interactor.CreateExtensionRepo +import eu.kanade.domain.extension.interactor.DeleteExtensionRepo +import eu.kanade.domain.extension.interactor.GetExtensionRepos +import kotlinx.collections.immutable.ImmutableSet +import kotlinx.collections.immutable.toImmutableSet import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.receiveAsFlow @@ -19,9 +19,9 @@ import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get class ExtensionReposScreenModel( - private val getSourceRepos: GetSourceRepos = Injekt.get(), - private val createSourceRepo: CreateSourceRepo = Injekt.get(), - private val deleteSourceRepo: DeleteSourceRepo = Injekt.get(), + private val getExtensionRepos: GetExtensionRepos = Injekt.get(), + private val createExtensionRepo: CreateExtensionRepo = Injekt.get(), + private val deleteExtensionRepo: DeleteExtensionRepo = Injekt.get(), ) : StateScreenModel(RepoScreenState.Loading) { private val _events: Channel = Channel(Int.MAX_VALUE) @@ -29,11 +29,11 @@ class ExtensionReposScreenModel( init { screenModelScope.launchIO { - getSourceRepos.subscribe() + getExtensionRepos.subscribe() .collectLatest { repos -> mutableState.update { RepoScreenState.Success( - repos = repos.toImmutableList(), + repos = repos.toImmutableSet(), ) } } @@ -47,8 +47,8 @@ class ExtensionReposScreenModel( */ fun createRepo(name: String) { screenModelScope.launchIO { - when (createSourceRepo.await(name)) { - is CreateSourceRepo.Result.InvalidUrl -> _events.send(RepoEvent.InvalidUrl) + when (createExtensionRepo.await(name)) { + is CreateExtensionRepo.Result.InvalidUrl -> _events.send(RepoEvent.InvalidUrl) else -> {} } } @@ -61,7 +61,7 @@ class ExtensionReposScreenModel( */ fun deleteRepo(repo: String) { screenModelScope.launchIO { - deleteSourceRepo.await(repo) + deleteExtensionRepo.await(repo) } } @@ -101,7 +101,7 @@ sealed class RepoScreenState { @Immutable data class Success( - val repos: ImmutableList, + val repos: ImmutableSet, val dialog: RepoDialog? = null, ) : RepoScreenState() { diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt index 8281f5874..3d4772836 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposContent.kt @@ -7,7 +7,6 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState -import androidx.compose.foundation.lazy.items import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.outlined.Label import androidx.compose.material.icons.outlined.Delete @@ -19,12 +18,12 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.ImmutableSet import tachiyomi.presentation.core.components.material.padding @Composable fun ExtensionReposContent( - repos: ImmutableList, + repos: ImmutableSet, lazyListState: LazyListState, paddingValues: PaddingValues, onClickDelete: (String) -> Unit, @@ -36,12 +35,14 @@ fun ExtensionReposContent( verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small), modifier = modifier, ) { - items(repos) { repo -> - ExtensionRepoListItem( - modifier = Modifier.animateItemPlacement(), - repo = repo, - onDelete = { onClickDelete(repo) }, - ) + repos.forEach { + item { + ExtensionRepoListItem( + modifier = Modifier.animateItemPlacement(), + repo = it, + onDelete = { onClickDelete(it) }, + ) + } } } } diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt index 9f20b196d..b4ef8b575 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/browse/components/ExtensionReposDialogs.kt @@ -14,7 +14,7 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester -import kotlinx.collections.immutable.ImmutableList +import kotlinx.collections.immutable.ImmutableSet import kotlinx.coroutines.delay import tachiyomi.i18n.MR import tachiyomi.presentation.core.i18n.stringResource @@ -24,12 +24,12 @@ import kotlin.time.Duration.Companion.seconds fun ExtensionRepoCreateDialog( onDismissRequest: () -> Unit, onCreate: (String) -> Unit, - categories: ImmutableList, + repos: ImmutableSet, ) { var name by remember { mutableStateOf("") } val focusRequester = remember { FocusRequester() } - val nameAlreadyExists = remember(name) { categories.contains(name) } + val nameAlreadyExists = remember(name) { repos.contains(name) } AlertDialog( onDismissRequest = onDismissRequest, diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt index 6b7594e86..b252c0fbe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/ExtensionManager.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.extension import android.content.Context import android.graphics.drawable.Drawable -import eu.kanade.domain.source.interactor.TrustExtension +import eu.kanade.domain.extension.interactor.TrustExtension import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.extension.api.ExtensionApi import eu.kanade.tachiyomi.extension.api.ExtensionUpdateNotifier diff --git a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt index 6c765edf5..ef603f934 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/extension/util/ExtensionLoader.kt @@ -7,7 +7,7 @@ import android.content.pm.PackageManager import android.os.Build import androidx.core.content.pm.PackageInfoCompat import dalvik.system.PathClassLoader -import eu.kanade.domain.source.interactor.TrustExtension +import eu.kanade.domain.extension.interactor.TrustExtension import eu.kanade.domain.source.service.SourcePreferences import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.LoadResult diff --git a/data/src/main/java/tachiyomi/data/source/SourceRepositoryImpl.kt b/data/src/main/java/tachiyomi/data/source/SourceRepositoryImpl.kt index 65bf33ac0..f2b2e0e05 100644 --- a/data/src/main/java/tachiyomi/data/source/SourceRepositoryImpl.kt +++ b/data/src/main/java/tachiyomi/data/source/SourceRepositoryImpl.kt @@ -41,7 +41,7 @@ class SourceRepositoryImpl( override fun getSourcesWithFavoriteCount(): Flow>> { return combine( handler.subscribeToList { mangasQueries.getSourceIdWithFavoriteCount() }, - sourceManager.catalogueSources + sourceManager.catalogueSources, ) { sourceIdWithFavoriteCount, _ -> sourceIdWithFavoriteCount } .map { it.map { (sourceId, count) ->