mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Restrict raw database access to the data module
app no longer touches the database directly. Backup restore's queries move into a new RestoreRepository in :data, which restores a batch of entries all or nothing, stopping between entries if cancelled, as before. The remaining direct calls (excluded scanlators, clear database, backup creation, store and category restore) go through their repositories, and the database bindings move from AppBindings into :data.
This commit is contained in:
@@ -28,7 +28,7 @@ dependencies {
|
||||
|
||||
implementation(libs.unifile)
|
||||
|
||||
api(libs.sqldelight.androidxPaging)
|
||||
api(libs.androidx.paging.runtime)
|
||||
|
||||
compileOnly(platform(libs.androidx.compose.bom))
|
||||
compileOnly(libs.androidx.compose.runtimeAnnotation)
|
||||
|
||||
@@ -9,6 +9,8 @@ interface ExtensionStoreRepository {
|
||||
|
||||
suspend fun insertFromPreference(indexUrl: String, name: String)
|
||||
|
||||
suspend fun upsert(store: ExtensionStore)
|
||||
|
||||
suspend fun refreshAll()
|
||||
|
||||
suspend fun fetchExtensions(): List<Extension.Available>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package tachiyomi.domain.backup.model
|
||||
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.track.model.Track
|
||||
import java.util.Date
|
||||
|
||||
data class RestoredManga(
|
||||
val manga: Manga,
|
||||
val chapters: List<Chapter>,
|
||||
val categoryIds: List<Long>,
|
||||
val history: List<RestoredHistory>,
|
||||
val tracks: List<Track>,
|
||||
val excludedScanlators: List<String>,
|
||||
)
|
||||
|
||||
data class RestoredHistory(
|
||||
val chapterUrl: String,
|
||||
val readAt: Date?,
|
||||
val readDuration: Long,
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package tachiyomi.domain.backup.repository
|
||||
|
||||
import tachiyomi.domain.backup.model.RestoredManga
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaUpdate
|
||||
|
||||
interface RestoreRepository {
|
||||
|
||||
suspend fun getMangaUrlsBySourceId(): Map<Long, List<String>>
|
||||
|
||||
/**
|
||||
* Restores [entries] all together: either every one of them is restored or none is. [update] is what to change on each
|
||||
* entry once its chapters and history are in place, and is part of the same all-or-nothing restore.
|
||||
*/
|
||||
suspend fun restoreManga(entries: List<RestoredManga>, update: suspend (Manga) -> MangaUpdate)
|
||||
}
|
||||
@@ -17,6 +17,8 @@ interface CategoryRepository {
|
||||
|
||||
suspend fun insert(category: Category)
|
||||
|
||||
suspend fun insertAll(categories: List<Category>)
|
||||
|
||||
suspend fun updateName(categoryId: Long, name: String)
|
||||
|
||||
suspend fun updateFlags(categoryId: Long, flags: Long)
|
||||
|
||||
@@ -21,5 +21,7 @@ interface HistoryRepository {
|
||||
|
||||
suspend fun deleteAllHistory(): Boolean
|
||||
|
||||
suspend fun deleteResetHistory()
|
||||
|
||||
suspend fun upsertHistory(historyUpdate: HistoryUpdate)
|
||||
}
|
||||
|
||||
@@ -37,8 +37,16 @@ interface MangaRepository {
|
||||
|
||||
suspend fun resetViewerFlags(): Boolean
|
||||
|
||||
suspend fun deleteNonLibraryManga(sourceIds: List<Long>, keepReadManga: Boolean)
|
||||
|
||||
suspend fun setMangaCategories(mangaId: Long, categoryIds: List<Long>)
|
||||
|
||||
suspend fun getExcludedScanlators(mangaId: Long): Set<String>
|
||||
|
||||
fun getExcludedScanlatorsAsFlow(mangaId: Long): Flow<Set<String>>
|
||||
|
||||
suspend fun setExcludedScanlators(mangaId: Long, excludedScanlators: Set<String>)
|
||||
|
||||
suspend fun update(update: MangaUpdate): Boolean
|
||||
|
||||
suspend fun updateRemote(update: MangaRemoteUpdate): Boolean
|
||||
|
||||
Reference in New Issue
Block a user