mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-25 12:30:41 +02:00
Added library update errors screen
(cherry picked from commit 7cf37d52f959ac65f53cf7657563fb4428bd9188)
This commit is contained in:
committed by
Cuong-Tran
parent
f7752a98b2
commit
ee78212c75
@@ -0,0 +1,36 @@
|
||||
package tachiyomi.domain.libraryUpdateError.interactor
|
||||
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.libraryUpdateError.repository.LibraryUpdateErrorRepository
|
||||
|
||||
class DeleteLibraryUpdateErrors(
|
||||
private val libraryUpdateErrorRepository: LibraryUpdateErrorRepository,
|
||||
) {
|
||||
|
||||
suspend fun await() = withNonCancellableContext {
|
||||
try {
|
||||
libraryUpdateErrorRepository.deleteAll()
|
||||
Result.Success
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
return@withNonCancellableContext Result.InternalError(e)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun await(errorId: Long) = withNonCancellableContext {
|
||||
try {
|
||||
libraryUpdateErrorRepository.delete(errorId)
|
||||
Result.Success
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
return@withNonCancellableContext Result.InternalError(e)
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Result {
|
||||
object Success : Result()
|
||||
data class InternalError(val error: Throwable) : Result()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package tachiyomi.domain.libraryUpdateError.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateErrorWithRelations
|
||||
import tachiyomi.domain.libraryUpdateError.repository.LibraryUpdateErrorWithRelationsRepository
|
||||
|
||||
class GetLibraryUpdateErrorWithRelations(
|
||||
private val libraryUpdateErrorWithRelationsRepository: LibraryUpdateErrorWithRelationsRepository,
|
||||
) {
|
||||
|
||||
fun subscribeAll(): Flow<List<LibraryUpdateErrorWithRelations>> {
|
||||
return libraryUpdateErrorWithRelationsRepository.subscribeAll()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tachiyomi.domain.libraryUpdateError.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateError
|
||||
import tachiyomi.domain.libraryUpdateError.repository.LibraryUpdateErrorRepository
|
||||
|
||||
class GetLibraryUpdateErrors(
|
||||
private val libraryUpdateErrorRepository: LibraryUpdateErrorRepository,
|
||||
) {
|
||||
|
||||
fun subscribe(): Flow<List<LibraryUpdateError>> {
|
||||
return libraryUpdateErrorRepository.getAllAsFlow()
|
||||
}
|
||||
|
||||
suspend fun await(): List<LibraryUpdateError> {
|
||||
return libraryUpdateErrorRepository.getAll()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package tachiyomi.domain.libraryUpdateError.interactor
|
||||
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateError
|
||||
import tachiyomi.domain.libraryUpdateError.repository.LibraryUpdateErrorRepository
|
||||
|
||||
class InsertLibraryUpdateErrors(
|
||||
private val libraryUpdateErrorRepository: LibraryUpdateErrorRepository,
|
||||
) {
|
||||
suspend fun insert(libraryUpdateError: LibraryUpdateError) {
|
||||
return libraryUpdateErrorRepository.insert(libraryUpdateError)
|
||||
}
|
||||
|
||||
suspend fun insertAll(libraryUpdateErrors: List<LibraryUpdateError>) {
|
||||
return libraryUpdateErrorRepository.insertAll(libraryUpdateErrors)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package tachiyomi.domain.libraryUpdateError.model
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
data class LibraryUpdateError(
|
||||
val id: Long,
|
||||
val mangaId: Long,
|
||||
val messageId: Long,
|
||||
) : Serializable
|
||||
@@ -0,0 +1,12 @@
|
||||
package tachiyomi.domain.libraryUpdateError.model
|
||||
|
||||
import tachiyomi.domain.manga.model.MangaCover
|
||||
|
||||
data class LibraryUpdateErrorWithRelations(
|
||||
val mangaId: Long,
|
||||
val mangaTitle: String,
|
||||
val mangaSource: Long,
|
||||
val mangaCover: MangaCover,
|
||||
val errorId: Long,
|
||||
val messageId: Long,
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
package tachiyomi.domain.libraryUpdateError.repository
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateError
|
||||
|
||||
interface LibraryUpdateErrorRepository {
|
||||
|
||||
suspend fun getAll(): List<LibraryUpdateError>
|
||||
|
||||
fun getAllAsFlow(): Flow<List<LibraryUpdateError>>
|
||||
|
||||
suspend fun deleteAll()
|
||||
|
||||
suspend fun delete(errorId: Long)
|
||||
|
||||
suspend fun insert(libraryUpdateError: LibraryUpdateError)
|
||||
|
||||
suspend fun insertAll(libraryUpdateErrors: List<LibraryUpdateError>)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package tachiyomi.domain.libraryUpdateError.repository
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateErrorWithRelations
|
||||
|
||||
interface LibraryUpdateErrorWithRelationsRepository {
|
||||
|
||||
fun subscribeAll(): Flow<List<LibraryUpdateErrorWithRelations>>
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package tachiyomi.domain.libraryUpdateErrorMessage.interactor
|
||||
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.repository.LibraryUpdateErrorMessageRepository
|
||||
import kotlin.Exception
|
||||
|
||||
class DeleteLibraryUpdateErrorMessages(
|
||||
private val libraryUpdateErrorMessageRepository: LibraryUpdateErrorMessageRepository,
|
||||
) {
|
||||
|
||||
suspend fun await() = withNonCancellableContext {
|
||||
try {
|
||||
libraryUpdateErrorMessageRepository.deleteAll()
|
||||
Result.Success
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
return@withNonCancellableContext Result.InternalError(e)
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Result {
|
||||
object Success : Result()
|
||||
data class InternalError(val error: Throwable) : Result()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package tachiyomi.domain.libraryUpdateErrorMessage.interactor
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.model.LibraryUpdateErrorMessage
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.repository.LibraryUpdateErrorMessageRepository
|
||||
|
||||
class GetLibraryUpdateErrorMessages(
|
||||
private val libraryUpdateErrorMessageRepository: LibraryUpdateErrorMessageRepository,
|
||||
) {
|
||||
|
||||
fun subscribe(): Flow<List<LibraryUpdateErrorMessage>> {
|
||||
return libraryUpdateErrorMessageRepository.getAllAsFlow()
|
||||
}
|
||||
|
||||
suspend fun await(): List<LibraryUpdateErrorMessage> {
|
||||
return libraryUpdateErrorMessageRepository.getAll()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.libraryUpdateErrorMessage.interactor
|
||||
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.model.LibraryUpdateErrorMessage
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.repository.LibraryUpdateErrorMessageRepository
|
||||
|
||||
class InsertLibraryUpdateErrorMessages(
|
||||
private val libraryUpdateErrorMessageRepository: LibraryUpdateErrorMessageRepository,
|
||||
) {
|
||||
|
||||
suspend fun insert(libraryUpdateErrorMessage: LibraryUpdateErrorMessage): Long? {
|
||||
return libraryUpdateErrorMessageRepository.insert(libraryUpdateErrorMessage)
|
||||
}
|
||||
|
||||
suspend fun insertAll(libraryUpdateErrorMessages: List<LibraryUpdateErrorMessage>): List<Pair<Long, String>> {
|
||||
return libraryUpdateErrorMessageRepository.insertAll(libraryUpdateErrorMessages)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package tachiyomi.domain.libraryUpdateErrorMessage.model
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
data class LibraryUpdateErrorMessage(
|
||||
val id: Long,
|
||||
val message: String,
|
||||
) : Serializable
|
||||
@@ -0,0 +1,17 @@
|
||||
package tachiyomi.domain.libraryUpdateErrorMessage.repository
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.model.LibraryUpdateErrorMessage
|
||||
|
||||
interface LibraryUpdateErrorMessageRepository {
|
||||
|
||||
suspend fun getAll(): List<LibraryUpdateErrorMessage>
|
||||
|
||||
fun getAllAsFlow(): Flow<List<LibraryUpdateErrorMessage>>
|
||||
|
||||
suspend fun deleteAll()
|
||||
|
||||
suspend fun insert(libraryUpdateErrorMessage: LibraryUpdateErrorMessage): Long?
|
||||
|
||||
suspend fun insertAll(libraryUpdateErrorMessages: List<LibraryUpdateErrorMessage>): List<Pair<Long, String>>
|
||||
}
|
||||
Reference in New Issue
Block a user