Skip to content

Commit

Permalink
Apply code review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
shabnix committed Aug 20, 2024
1 parent ac2a778 commit 1a2dce7
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 42 deletions.
4 changes: 1 addition & 3 deletions app/src/main/java/eu/kanade/domain/DomainModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import eu.kanade.domain.track.interactor.RefreshTracks
import eu.kanade.domain.track.interactor.SyncChapterProgressWithTrack
import eu.kanade.domain.track.interactor.TrackChapter
import mihon.data.repository.ExtensionRepoRepositoryImpl
import mihon.domain.chapter.interactor.GetReadChapterCountByMangaIdAndChapterNumber
import mihon.domain.extensionrepo.interactor.CreateExtensionRepo
import mihon.domain.extensionrepo.interactor.DeleteExtensionRepo
import mihon.domain.extensionrepo.interactor.GetExtensionRepo
Expand Down Expand Up @@ -151,9 +150,8 @@ class DomainModule : InjektModule {
addFactory { UpdateChapter(get()) }
addFactory { SetReadStatus(get(), get(), get(), get()) }
addFactory { ShouldUpdateDbChapter() }
addFactory { SyncChaptersWithSource(get(), get(), get(), get(), get(), get(), get(), get(), get(), get()) }
addFactory { SyncChaptersWithSource(get(), get(), get(), get(), get(), get(), get(), get(), get()) }
addFactory { GetAvailableScanlators(get()) }
addFactory { GetReadChapterCountByMangaIdAndChapterNumber(get()) }

addSingletonFactory<HistoryRepository> { HistoryRepositoryImpl(get()) }
addFactory { GetHistory(get()) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.data.download.DownloadProvider
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.online.HttpSource
import mihon.domain.chapter.interactor.GetReadChapterCountByMangaIdAndChapterNumber
import tachiyomi.data.chapter.ChapterSanitizer
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
import tachiyomi.domain.chapter.interactor.ShouldUpdateDbChapter
Expand All @@ -37,7 +36,6 @@ class SyncChaptersWithSource(
private val getChaptersByMangaId: GetChaptersByMangaId,
private val getExcludedScanlators: GetExcludedScanlators,
private val downloadPreferences: DownloadPreferences,
private val getReadChapterCount: GetReadChapterCountByMangaIdAndChapterNumber,
) {

/**
Expand Down Expand Up @@ -220,7 +218,10 @@ class SyncChaptersWithSource(
}

val chaptersToDownload = if (downloadPreferences.downloadUnreadChaptersOnly().get()) {
nonExcludedChapters.filter { getReadChapterCount.await(manga.id, it.chapterNumber) == 0L }
val groupedDbChapters = dbChapters.groupBy { it.chapterNumber }
nonExcludedChapters.filter { chapter ->
groupedDbChapters[chapter.chapterNumber]?.none { it.read } ?: true
}
} else {
nonExcludedChapters
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ class ChapterRepositoryImpl(
}
}

override suspend fun getReadChapterCountByMangaIdAndChapterNumber(mangaId: Long, chapterNumber: Double): Long {
return handler.awaitOne {
chaptersQueries.getReadChapterCountByMangaIdAndChapterNumber(mangaId, chapterNumber)
}
}

private fun mapChapter(
id: Long,
mangaId: Long,
Expand Down
9 changes: 1 addition & 8 deletions data/src/main/sqldelight/tachiyomi/data/chapters.sq
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,4 @@ SET manga_id = coalesce(:mangaId, manga_id),
WHERE _id = :chapterId;

selectLastInsertedRowId:
SELECT last_insert_rowid();

getReadChapterCountByMangaIdAndChapterNumber:
SELECT COUNT(*)
FROM chapters
WHERE manga_id = :mangaId
AND chapter_number =:chapterNumber
AND read = 1;
SELECT last_insert_rowid();

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,4 @@ interface ChapterRepository {
suspend fun getChapterByMangaIdAsFlow(mangaId: Long, applyScanlatorFilter: Boolean = false): Flow<List<Chapter>>

suspend fun getChapterByUrlAndMangaId(url: String, mangaId: Long): Chapter?

suspend fun getReadChapterCountByMangaIdAndChapterNumber(mangaId: Long, chapterNumber: Double): Long
}

0 comments on commit 1a2dce7

Please sign in to comment.