Merge branch 'master' into devel
This commit is contained in:
@@ -15,7 +15,7 @@ android {
|
|||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 29
|
targetSdkVersion 29
|
||||||
versionCode gitCommits
|
versionCode gitCommits
|
||||||
versionName '0.1.2'
|
versionName '0.1.3'
|
||||||
|
|
||||||
buildConfigField 'String', 'GIT_BRANCH', "\"${gitBranch}\""
|
buildConfigField 'String', 'GIT_BRANCH', "\"${gitBranch}\""
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.domain
|
package org.koitharu.kotatsu.domain
|
||||||
|
|
||||||
|
import androidx.room.withTransaction
|
||||||
import org.koin.core.KoinComponent
|
import org.koin.core.KoinComponent
|
||||||
import org.koin.core.inject
|
import org.koin.core.inject
|
||||||
import org.koitharu.kotatsu.core.db.MangaDatabase
|
import org.koitharu.kotatsu.core.db.MangaDatabase
|
||||||
@@ -31,6 +32,10 @@ class MangaDataRepository : KoinComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun storeManga(manga: Manga) {
|
suspend fun storeManga(manga: Manga) {
|
||||||
db.mangaDao.upsert(MangaEntity.from(manga), manga.tags.map(TagEntity.Companion::fromMangaTag))
|
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
||||||
|
db.withTransaction {
|
||||||
|
db.tagsDao.upsert(tags)
|
||||||
|
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.domain.favourites
|
package org.koitharu.kotatsu.domain.favourites
|
||||||
|
|
||||||
|
import androidx.room.withTransaction
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.koin.core.KoinComponent
|
import org.koin.core.KoinComponent
|
||||||
@@ -48,10 +49,12 @@ class FavouritesRepository : KoinComponent {
|
|||||||
|
|
||||||
suspend fun addToCategory(manga: Manga, categoryId: Long) {
|
suspend fun addToCategory(manga: Manga, categoryId: Long) {
|
||||||
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
||||||
db.tagsDao.upsert(tags)
|
db.withTransaction {
|
||||||
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
db.tagsDao.upsert(tags)
|
||||||
val entity = FavouriteEntity(manga.id, categoryId, System.currentTimeMillis())
|
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
||||||
db.favouritesDao.add(entity)
|
val entity = FavouriteEntity(manga.id, categoryId, System.currentTimeMillis())
|
||||||
|
db.favouritesDao.add(entity)
|
||||||
|
}
|
||||||
notifyFavouritesChanged(manga.id)
|
notifyFavouritesChanged(manga.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package org.koitharu.kotatsu.domain.history
|
package org.koitharu.kotatsu.domain.history
|
||||||
|
|
||||||
|
import androidx.room.withTransaction
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.koin.core.KoinComponent
|
import org.koin.core.KoinComponent
|
||||||
@@ -24,19 +25,22 @@ class HistoryRepository : KoinComponent {
|
|||||||
|
|
||||||
suspend fun addOrUpdate(manga: Manga, chapterId: Long, page: Int, scroll: Float) {
|
suspend fun addOrUpdate(manga: Manga, chapterId: Long, page: Int, scroll: Float) {
|
||||||
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
val tags = manga.tags.map(TagEntity.Companion::fromMangaTag)
|
||||||
db.tagsDao.upsert(tags)
|
db.withTransaction {
|
||||||
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
db.tagsDao.upsert(tags)
|
||||||
if (db.historyDao.upsert(
|
db.mangaDao.upsert(MangaEntity.from(manga), tags)
|
||||||
HistoryEntity(
|
if (db.historyDao.upsert(
|
||||||
mangaId = manga.id,
|
HistoryEntity(
|
||||||
createdAt = System.currentTimeMillis(),
|
mangaId = manga.id,
|
||||||
updatedAt = System.currentTimeMillis(),
|
createdAt = System.currentTimeMillis(),
|
||||||
chapterId = chapterId,
|
updatedAt = System.currentTimeMillis(),
|
||||||
page = page,
|
chapterId = chapterId,
|
||||||
scroll = scroll
|
page = page,
|
||||||
)
|
scroll = scroll
|
||||||
)) {
|
)
|
||||||
TrackingRepository().insertOrNothing(manga)
|
)
|
||||||
|
) {
|
||||||
|
TrackingRepository().insertOrNothing(manga)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
notifyHistoryChanged()
|
notifyHistoryChanged()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user