Move some things to the domain module
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
package tachiyomi.domain
|
||||
|
||||
import tachiyomi.core.preference.PreferenceStore
|
||||
|
||||
class UnsortedPreferences(
|
||||
private val preferenceStore: PreferenceStore,
|
||||
) {
|
||||
|
||||
// SY -->
|
||||
|
||||
fun migrateFlags() = preferenceStore.getInt("migrate_flags", Int.MAX_VALUE)
|
||||
|
||||
fun defaultMangaOrder() = preferenceStore.getString("default_manga_order", "")
|
||||
|
||||
fun migrationSources() = preferenceStore.getString("migrate_sources", "")
|
||||
|
||||
fun smartMigration() = preferenceStore.getBoolean("smart_migrate", false)
|
||||
|
||||
fun useSourceWithMost() = preferenceStore.getBoolean("use_source_with_most", false)
|
||||
|
||||
fun skipPreMigration() = preferenceStore.getBoolean("skip_pre_migration", false)
|
||||
|
||||
fun hideNotFoundMigration() = preferenceStore.getBoolean("hide_not_found_migration", false)
|
||||
|
||||
fun isHentaiEnabled() = preferenceStore.getBoolean("eh_is_hentai_enabled", true)
|
||||
|
||||
fun enableExhentai() = preferenceStore.getBoolean("enable_exhentai", false)
|
||||
|
||||
fun imageQuality() = preferenceStore.getString("ehentai_quality", "auto")
|
||||
|
||||
fun useHentaiAtHome() = preferenceStore.getInt("eh_enable_hah", 0)
|
||||
|
||||
fun useJapaneseTitle() = preferenceStore.getBoolean("use_jp_title", false)
|
||||
|
||||
fun exhUseOriginalImages() = preferenceStore.getBoolean("eh_useOrigImages", false)
|
||||
|
||||
fun ehTagFilterValue() = preferenceStore.getInt("eh_tag_filtering_value", 0)
|
||||
|
||||
fun ehTagWatchingValue() = preferenceStore.getInt("eh_tag_watching_value", 0)
|
||||
|
||||
// EH Cookies
|
||||
fun memberIdVal() = preferenceStore.getString("eh_ipb_member_id", "")
|
||||
|
||||
fun passHashVal() = preferenceStore.getString("eh_ipb_pass_hash", "")
|
||||
fun igneousVal() = preferenceStore.getString("eh_igneous", "")
|
||||
fun ehSettingsProfile() = preferenceStore.getInt("eh_ehSettingsProfile", -1)
|
||||
fun exhSettingsProfile() = preferenceStore.getInt("eh_exhSettingsProfile", -1)
|
||||
fun exhSettingsKey() = preferenceStore.getString("eh_settingsKey", "")
|
||||
fun exhSessionCookie() = preferenceStore.getString("eh_sessionCookie", "")
|
||||
fun exhHathPerksCookies() = preferenceStore.getString("eh_hathPerksCookie", "")
|
||||
|
||||
fun exhShowSyncIntro() = preferenceStore.getBoolean("eh_show_sync_intro", true)
|
||||
|
||||
fun exhReadOnlySync() = preferenceStore.getBoolean("eh_sync_read_only", false)
|
||||
|
||||
fun exhLenientSync() = preferenceStore.getBoolean("eh_lenient_sync", false)
|
||||
|
||||
fun exhShowSettingsUploadWarning() = preferenceStore.getBoolean("eh_showSettingsUploadWarning2", true)
|
||||
|
||||
fun logLevel() = preferenceStore.getInt("eh_log_level", 0)
|
||||
|
||||
fun exhAutoUpdateFrequency() = preferenceStore.getInt("eh_auto_update_frequency", 1)
|
||||
|
||||
fun exhAutoUpdateRequirements() = preferenceStore.getStringSet("eh_auto_update_restrictions", emptySet())
|
||||
|
||||
fun exhAutoUpdateStats() = preferenceStore.getString("eh_auto_update_stats", "")
|
||||
|
||||
fun exhWatchedListDefaultState() = preferenceStore.getBoolean("eh_watched_list_default_state", false)
|
||||
|
||||
fun exhSettingsLanguages() = preferenceStore.getString(
|
||||
"eh_settings_languages",
|
||||
"false*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false\nfalse*false*false",
|
||||
)
|
||||
|
||||
fun exhEnabledCategories() = preferenceStore.getString(
|
||||
"eh_enabled_categories",
|
||||
"false,false,false,false,false,false,false,false,false,false",
|
||||
)
|
||||
|
||||
fun enhancedEHentaiView() = preferenceStore.getBoolean("enhanced_e_hentai_view", true)
|
||||
|
||||
fun preferredMangaDexId() = preferenceStore.getString("preferred_mangaDex_id", "0")
|
||||
|
||||
fun mangadexSyncToLibraryIndexes() = preferenceStore.getStringSet("pref_mangadex_sync_to_library_indexes", emptySet())
|
||||
|
||||
fun allowLocalSourceHiddenFolders() = preferenceStore.getBoolean("allow_local_source_hidden_folders", false)
|
||||
|
||||
fun extensionRepos() = preferenceStore.getStringSet("extension_repos", emptySet())
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.chapter.interactor
|
||||
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
|
||||
class DeleteChapters(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(chapters: List<Long>) {
|
||||
chapterRepository.removeChaptersWithIds(chapters)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package tachiyomi.domain.chapter.interactor
|
||||
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
|
||||
class GetChapterByUrl(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(url: String): List<Chapter> {
|
||||
return try {
|
||||
chapterRepository.getChapterByUrl(url)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.repository.MangaMergeRepository
|
||||
|
||||
class DeleteByMergeId(
|
||||
private val mangaMergeRepository: MangaMergeRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(id: Long) {
|
||||
return mangaMergeRepository.deleteByMergeId(id)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.repository.FavoritesEntryRepository
|
||||
|
||||
class DeleteFavoriteEntries(
|
||||
private val favoriteEntryRepository: FavoritesEntryRepository,
|
||||
) {
|
||||
|
||||
suspend fun await() {
|
||||
return favoriteEntryRepository.deleteAll()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
|
||||
class DeleteMangaById(
|
||||
private val mangaRepository: MangaRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(id: Long) {
|
||||
return mangaRepository.deleteManga(id)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.repository.MangaMergeRepository
|
||||
|
||||
class DeleteMergeById(
|
||||
private val mangaMergeRepository: MangaMergeRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(id: Long) {
|
||||
return mangaMergeRepository.deleteById(id)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
|
||||
class GetAllManga(
|
||||
private val mangaRepository: MangaRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): List<Manga> {
|
||||
return mangaRepository.getAll()
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaMetadataRepository
|
||||
|
||||
class GetExhFavoriteMangaWithMetadata(
|
||||
private val mangaMetadataRepository: MangaMetadataRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): List<Manga> {
|
||||
return mangaMetadataRepository.getExhFavoriteMangaWithMetadata()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.FavoriteEntry
|
||||
import tachiyomi.domain.manga.repository.FavoritesEntryRepository
|
||||
|
||||
class GetFavoriteEntries(
|
||||
private val favoriteEntryRepository: FavoritesEntryRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): List<FavoriteEntry> {
|
||||
return favoriteEntryRepository.selectAll()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.source.online.MetadataSource
|
||||
import exh.metadata.metadata.base.FlatMetadata
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.manga.repository.MangaMetadataRepository
|
||||
|
||||
class GetFlatMetadataById(
|
||||
private val mangaMetadataRepository: MangaMetadataRepository,
|
||||
) : MetadataSource.GetFlatMetadataById {
|
||||
|
||||
override suspend fun await(id: Long): FlatMetadata? {
|
||||
return try {
|
||||
val meta = mangaMetadataRepository.getMetadataById(id)
|
||||
return if (meta != null) {
|
||||
val tags = mangaMetadataRepository.getTagsById(id)
|
||||
val titles = mangaMetadataRepository.getTitlesById(id)
|
||||
|
||||
FlatMetadata(meta, tags, titles)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun subscribe(id: Long): Flow<FlatMetadata?> {
|
||||
return combine(
|
||||
mangaMetadataRepository.subscribeMetadataById(id),
|
||||
mangaMetadataRepository.subscribeTagsById(id),
|
||||
mangaMetadataRepository.subscribeTitlesById(id),
|
||||
) { meta, tags, titles ->
|
||||
if (meta != null) {
|
||||
FlatMetadata(meta, tags, titles)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.repository.MangaMetadataRepository
|
||||
|
||||
class GetIdsOfFavoriteMangaWithMetadata(
|
||||
private val mangaMetadataRepository: MangaMetadataRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): List<Long> {
|
||||
return mangaMetadataRepository.getIdsOfFavoriteMangaWithMetadata()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
|
||||
class GetMangaBySource(
|
||||
private val mangaRepository: MangaRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(sourceId: Long): List<Manga> {
|
||||
return mangaRepository.getMangaBySourceId(sourceId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaMergeRepository
|
||||
|
||||
class GetMergedManga(
|
||||
private val mangaMergeRepository: MangaMergeRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): List<Manga> {
|
||||
return try {
|
||||
mangaMergeRepository.getMergedManga()
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun subscribe(): Flow<List<Manga>> {
|
||||
return mangaMergeRepository.subscribeMergedManga()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaMergeRepository
|
||||
|
||||
class GetMergedMangaById(
|
||||
private val mangaMergeRepository: MangaMergeRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(id: Long): List<Manga> {
|
||||
return try {
|
||||
mangaMergeRepository.getMergedMangaById(id)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun subscribe(id: Long): Flow<List<Manga>> {
|
||||
return mangaMergeRepository.subscribeMergedMangaById(id)
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.repository.MangaMergeRepository
|
||||
|
||||
class GetMergedMangaForDownloading(
|
||||
private val mangaMergeRepository: MangaMergeRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(mergeId: Long): List<Manga> {
|
||||
return mangaMergeRepository.getMergeMangaForDownloading(mergeId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import exh.metadata.sql.models.SearchMetadata
|
||||
import tachiyomi.domain.manga.repository.MangaMetadataRepository
|
||||
|
||||
class GetSearchMetadata(
|
||||
private val mangaMetadataRepository: MangaMetadataRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long): SearchMetadata? {
|
||||
return mangaMetadataRepository.getMetadataById(mangaId)
|
||||
}
|
||||
|
||||
suspend fun await(): List<SearchMetadata> {
|
||||
return mangaMetadataRepository.getSearchMetadata()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import exh.metadata.sql.models.SearchTag
|
||||
import tachiyomi.domain.manga.repository.MangaMetadataRepository
|
||||
|
||||
class GetSearchTags(
|
||||
private val mangaMetadataRepository: MangaMetadataRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long): List<SearchTag> {
|
||||
return mangaMetadataRepository.getTagsById(mangaId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import exh.metadata.sql.models.SearchTitle
|
||||
import tachiyomi.domain.manga.repository.MangaMetadataRepository
|
||||
|
||||
class GetSearchTitles(
|
||||
private val mangaMetadataRepository: MangaMetadataRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long): List<SearchTitle> {
|
||||
return mangaMetadataRepository.getTitlesById(mangaId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.FavoriteEntry
|
||||
import tachiyomi.domain.manga.repository.FavoritesEntryRepository
|
||||
|
||||
class InsertFavoriteEntries(
|
||||
private val favoriteEntryRepository: FavoritesEntryRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(entries: List<FavoriteEntry>) {
|
||||
return favoriteEntryRepository.insertAll(entries)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import eu.kanade.tachiyomi.source.online.MetadataSource
|
||||
import exh.metadata.metadata.base.FlatMetadata
|
||||
import exh.metadata.metadata.base.RaisedSearchMetadata
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.manga.repository.MangaMetadataRepository
|
||||
|
||||
class InsertFlatMetadata(
|
||||
private val mangaMetadataRepository: MangaMetadataRepository,
|
||||
) : MetadataSource.InsertFlatMetadata {
|
||||
|
||||
suspend fun await(flatMetadata: FlatMetadata) {
|
||||
try {
|
||||
mangaMetadataRepository.insertFlatMetadata(flatMetadata)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun await(metadata: RaisedSearchMetadata) {
|
||||
try {
|
||||
mangaMetadataRepository.insertMetadata(metadata)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.MergedMangaReference
|
||||
import tachiyomi.domain.manga.repository.MangaMergeRepository
|
||||
|
||||
class InsertMergedReference(
|
||||
private val mangaMergedRepository: MangaMergeRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(reference: MergedMangaReference): Long? {
|
||||
return mangaMergedRepository.insert(reference)
|
||||
}
|
||||
|
||||
suspend fun awaitAll(references: List<MergedMangaReference>) {
|
||||
mangaMergedRepository.insertAll(references)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaUpdate
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
|
||||
class SetMangaFilteredScanlators(private val mangaRepository: MangaRepository) {
|
||||
|
||||
suspend fun awaitSetFilteredScanlators(manga: Manga, filteredScanlators: List<String>): Boolean {
|
||||
return mangaRepository.update(
|
||||
MangaUpdate(
|
||||
id = manga.id,
|
||||
filteredScanlators = filteredScanlators,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.manga.interactor
|
||||
|
||||
import tachiyomi.domain.manga.model.MergeMangaSettingsUpdate
|
||||
import tachiyomi.domain.manga.repository.MangaMergeRepository
|
||||
|
||||
class UpdateMergedSettings(
|
||||
private val mangaMergeRepository: MangaMergeRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(mergeUpdate: MergeMangaSettingsUpdate): Boolean {
|
||||
return mangaMergeRepository.updateSettings(mergeUpdate)
|
||||
}
|
||||
|
||||
suspend fun awaitAll(values: List<MergeMangaSettingsUpdate>): Boolean {
|
||||
return mangaMergeRepository.updateAllSettings(values)
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class CountFeedSavedSearchBySourceId(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(sourceId: Long): Long {
|
||||
return feedSavedSearchRepository.countBySourceId(sourceId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class CountFeedSavedSearchGlobal(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): Long {
|
||||
return feedSavedSearchRepository.countGlobal()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class DeleteFeedSavedSearchById(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(feedSavedSearchId: Long) {
|
||||
return feedSavedSearchRepository.delete(feedSavedSearchId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.source.repository.SavedSearchRepository
|
||||
|
||||
class DeleteSavedSearchById(
|
||||
private val savedSearchRepository: SavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(savedSearchId: Long) {
|
||||
return savedSearchRepository.delete(savedSearchId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
|
||||
class DeleteSourceRepos(private val preferences: UnsortedPreferences) {
|
||||
|
||||
fun await(repos: List<String>) {
|
||||
preferences.extensionRepos().set(
|
||||
preferences.extensionRepos().get().filterNot { it in repos }.toSet(),
|
||||
)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.source.model.FeedSavedSearch
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class GetFeedSavedSearchBySourceId(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(sourceId: Long): List<FeedSavedSearch> {
|
||||
return feedSavedSearchRepository.getBySourceId(sourceId)
|
||||
}
|
||||
|
||||
fun subscribe(sourceId: Long): Flow<List<FeedSavedSearch>> {
|
||||
return feedSavedSearchRepository.getBySourceIdAsFlow(sourceId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.source.model.FeedSavedSearch
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class GetFeedSavedSearchGlobal(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): List<FeedSavedSearch> {
|
||||
return feedSavedSearchRepository.getGlobal()
|
||||
}
|
||||
|
||||
fun subscribe(): Flow<List<FeedSavedSearch>> {
|
||||
return feedSavedSearchRepository.getGlobalAsFlow()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.source.model.SavedSearch
|
||||
import tachiyomi.domain.source.repository.SavedSearchRepository
|
||||
|
||||
class GetSavedSearchById(
|
||||
private val savedSearchRepository: SavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(savedSearchId: Long): SavedSearch {
|
||||
return savedSearchRepository.getById(savedSearchId)!!
|
||||
}
|
||||
|
||||
suspend fun awaitOrNull(savedSearchId: Long): SavedSearch? {
|
||||
return savedSearchRepository.getById(savedSearchId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.source.model.SavedSearch
|
||||
import tachiyomi.domain.source.repository.SavedSearchRepository
|
||||
|
||||
class GetSavedSearchBySourceId(
|
||||
private val savedSearchRepository: SavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(sourceId: Long): List<SavedSearch> {
|
||||
return savedSearchRepository.getBySourceId(sourceId)
|
||||
}
|
||||
|
||||
fun subscribe(sourceId: Long): Flow<List<SavedSearch>> {
|
||||
return savedSearchRepository.getBySourceIdAsFlow(sourceId)
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.source.model.SavedSearch
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class GetSavedSearchBySourceIdFeed(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(sourceId: Long): List<SavedSearch> {
|
||||
return feedSavedSearchRepository.getBySourceIdFeedSavedSearch(sourceId)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import tachiyomi.domain.source.model.SavedSearch
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class GetSavedSearchGlobalFeed(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(): List<SavedSearch> {
|
||||
return feedSavedSearchRepository.getGlobalFeedSavedSearch()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import tachiyomi.domain.UnsortedPreferences
|
||||
|
||||
class GetSourceRepos(private val preferences: UnsortedPreferences) {
|
||||
|
||||
fun subscribe(): Flow<List<String>> {
|
||||
return preferences.extensionRepos().changes().map { it.sortedWith(String.CASE_INSENSITIVE_ORDER) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import logcat.LogPriority
|
||||
import logcat.asLog
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.source.model.FeedSavedSearch
|
||||
import tachiyomi.domain.source.repository.FeedSavedSearchRepository
|
||||
|
||||
class InsertFeedSavedSearch(
|
||||
private val feedSavedSearchRepository: FeedSavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(feedSavedSearch: FeedSavedSearch): Long? {
|
||||
return try {
|
||||
feedSavedSearchRepository.insert(feedSavedSearch)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR) { e.asLog() }
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun awaitAll(feedSavedSearch: List<FeedSavedSearch>) {
|
||||
try {
|
||||
feedSavedSearchRepository.insertAll(feedSavedSearch)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR) { e.asLog() }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package tachiyomi.domain.source.interactor
|
||||
|
||||
import logcat.LogPriority
|
||||
import logcat.asLog
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.domain.source.model.SavedSearch
|
||||
import tachiyomi.domain.source.repository.SavedSearchRepository
|
||||
|
||||
class InsertSavedSearch(
|
||||
private val savedSearchRepository: SavedSearchRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(savedSearch: SavedSearch): Long? {
|
||||
return try {
|
||||
savedSearchRepository.insert(savedSearch)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR) { e.asLog() }
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun awaitAll(savedSearch: List<SavedSearch>) {
|
||||
try {
|
||||
savedSearchRepository.insertAll(savedSearch)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR) { e.asLog() }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user