mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-17 16:49:43 +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,11 @@
|
||||
package tachiyomi.data.libraryUpdateError
|
||||
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateError
|
||||
|
||||
val libraryUpdateErrorMapper: (Long, Long, Long) -> LibraryUpdateError = { id, mangaId, messageId ->
|
||||
LibraryUpdateError(
|
||||
id = id,
|
||||
mangaId = mangaId,
|
||||
messageId = messageId,
|
||||
)
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package tachiyomi.data.libraryUpdateError
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateError
|
||||
import tachiyomi.domain.libraryUpdateError.repository.LibraryUpdateErrorRepository
|
||||
|
||||
class LibraryUpdateErrorRepositoryImpl(
|
||||
private val handler: DatabaseHandler,
|
||||
) : LibraryUpdateErrorRepository {
|
||||
|
||||
override suspend fun getAll(): List<LibraryUpdateError> {
|
||||
return handler.awaitList {
|
||||
libraryUpdateErrorQueries.getAllErrors(
|
||||
libraryUpdateErrorMapper,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAllAsFlow(): Flow<List<LibraryUpdateError>> {
|
||||
return handler.subscribeToList {
|
||||
libraryUpdateErrorQueries.getAllErrors(
|
||||
libraryUpdateErrorMapper,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun deleteAll() {
|
||||
return handler.await { libraryUpdateErrorQueries.deleteAllErrors() }
|
||||
}
|
||||
|
||||
override suspend fun delete(errorId: Long) {
|
||||
return handler.await {
|
||||
libraryUpdateErrorQueries.deleteError(
|
||||
_id = errorId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun insert(libraryUpdateError: LibraryUpdateError) {
|
||||
return handler.await(inTransaction = true) {
|
||||
libraryUpdateErrorQueries.insert(
|
||||
mangaId = libraryUpdateError.mangaId,
|
||||
messageId = libraryUpdateError.messageId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun insertAll(libraryUpdateErrors: List<LibraryUpdateError>) {
|
||||
return handler.await(inTransaction = true) {
|
||||
libraryUpdateErrors.forEach {
|
||||
libraryUpdateErrorQueries.insert(
|
||||
mangaId = it.mangaId,
|
||||
messageId = it.messageId,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package tachiyomi.data.libraryUpdateError
|
||||
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateErrorWithRelations
|
||||
import tachiyomi.domain.manga.model.MangaCover
|
||||
|
||||
val libraryUpdateErrorWithRelationsMapper:
|
||||
(Long, String, Long, Boolean, String?, Long, Long, Long) -> LibraryUpdateErrorWithRelations =
|
||||
{ mangaId, mangaTitle, mangaSource, favorite, mangaThumbnail, coverLastModified, errorId, messageId ->
|
||||
LibraryUpdateErrorWithRelations(
|
||||
mangaId = mangaId,
|
||||
mangaTitle = mangaTitle,
|
||||
mangaSource = mangaSource,
|
||||
mangaCover = MangaCover(
|
||||
mangaId = mangaId,
|
||||
sourceId = mangaSource,
|
||||
isMangaFavorite = favorite,
|
||||
url = mangaThumbnail,
|
||||
lastModified = coverLastModified,
|
||||
),
|
||||
errorId = errorId,
|
||||
messageId = messageId,
|
||||
)
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
package tachiyomi.data.libraryUpdateError
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
import tachiyomi.domain.libraryUpdateError.model.LibraryUpdateErrorWithRelations
|
||||
import tachiyomi.domain.libraryUpdateError.repository.LibraryUpdateErrorWithRelationsRepository
|
||||
|
||||
class LibraryUpdateErrorWithRelationsRepositoryImpl(
|
||||
private val handler: DatabaseHandler,
|
||||
) : LibraryUpdateErrorWithRelationsRepository {
|
||||
|
||||
override fun subscribeAll(): Flow<List<LibraryUpdateErrorWithRelations>> {
|
||||
return handler.subscribeToList {
|
||||
libraryUpdateErrorViewQueries.errors(
|
||||
libraryUpdateErrorWithRelationsMapper,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
package tachiyomi.data.libraryUpdateErrorMessage
|
||||
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.model.LibraryUpdateErrorMessage
|
||||
|
||||
val LibraryUpdateErrorMessageMapper: (Long, String) -> LibraryUpdateErrorMessage = { id, message ->
|
||||
LibraryUpdateErrorMessage(
|
||||
id = id,
|
||||
message = message,
|
||||
)
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package tachiyomi.data.libraryUpdateErrorMessage
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.model.LibraryUpdateErrorMessage
|
||||
import tachiyomi.domain.libraryUpdateErrorMessage.repository.LibraryUpdateErrorMessageRepository
|
||||
|
||||
class LibraryUpdateErrorMessageRepositoryImpl(
|
||||
private val handler: DatabaseHandler,
|
||||
) : LibraryUpdateErrorMessageRepository {
|
||||
|
||||
override suspend fun getAll(): List<LibraryUpdateErrorMessage> {
|
||||
return handler.awaitList {
|
||||
libraryUpdateErrorMessageQueries.getAllErrorMessages(
|
||||
LibraryUpdateErrorMessageMapper,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getAllAsFlow(): Flow<List<LibraryUpdateErrorMessage>> {
|
||||
return handler.subscribeToList {
|
||||
libraryUpdateErrorMessageQueries.getAllErrorMessages(
|
||||
LibraryUpdateErrorMessageMapper,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun deleteAll() {
|
||||
return handler.await { libraryUpdateErrorMessageQueries.deleteAllErrorMessages() }
|
||||
}
|
||||
|
||||
override suspend fun insert(libraryUpdateErrorMessage: LibraryUpdateErrorMessage): Long? {
|
||||
return handler.awaitOneOrNullExecutable(inTransaction = true) {
|
||||
libraryUpdateErrorMessageQueries.insert(libraryUpdateErrorMessage.message)
|
||||
libraryUpdateErrorMessageQueries.selectLastInsertedRowId()
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun insertAll(libraryUpdateErrorMessages: List<LibraryUpdateErrorMessage>): List<Pair<Long, String>> {
|
||||
return handler.await(inTransaction = true) {
|
||||
libraryUpdateErrorMessages.map {
|
||||
libraryUpdateErrorMessageQueries.insert(it.message)
|
||||
libraryUpdateErrorMessageQueries.selectLastInsertedRowId().executeAsOne() to it.message
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE libraryUpdateError (
|
||||
_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
manga_id INTEGER NOT NULL,
|
||||
message_id INTEGER NOT NULL
|
||||
);
|
||||
|
||||
getAllErrors:
|
||||
SELECT *
|
||||
FROM libraryUpdateError;
|
||||
|
||||
insert:
|
||||
INSERT INTO libraryUpdateError(manga_id, message_id) VALUES (:mangaId, :messageId);
|
||||
|
||||
deleteAllErrors:
|
||||
DELETE FROM libraryUpdateError;
|
||||
|
||||
deleteError:
|
||||
DELETE FROM libraryUpdateError
|
||||
WHERE _id = :_id;
|
@@ -0,0 +1,17 @@
|
||||
CREATE TABLE libraryUpdateErrorMessage (
|
||||
_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
message TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
getAllErrorMessages:
|
||||
SELECT *
|
||||
FROM libraryUpdateErrorMessage;
|
||||
|
||||
insert:
|
||||
INSERT INTO libraryUpdateErrorMessage(message) VALUES (:message);
|
||||
|
||||
deleteAllErrorMessages:
|
||||
DELETE FROM libraryUpdateErrorMessage;
|
||||
|
||||
selectLastInsertedRowId:
|
||||
SELECT last_insert_rowid();
|
26
data/src/main/sqldelight/tachiyomi/migrations/4.sqm
Normal file
26
data/src/main/sqldelight/tachiyomi/migrations/4.sqm
Normal file
@@ -0,0 +1,26 @@
|
||||
DROP VIEW IF EXISTS libraryUpdateErrorView;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS libraryUpdateError (
|
||||
_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
manga_id INTEGER NOT NULL,
|
||||
message_id INTEGER NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS libraryUpdateErrorMessage (
|
||||
_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
message TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
CREATE VIEW libraryUpdateErrorView AS
|
||||
SELECT
|
||||
mangas._id AS mangaId,
|
||||
mangas.title AS mangaTitle,
|
||||
mangas.source,
|
||||
mangas.favorite,
|
||||
mangas.thumbnail_url AS thumbnailUrl,
|
||||
mangas.cover_last_modified AS coverLastModified,
|
||||
libraryUpdateError._id AS errorId,
|
||||
libraryUpdateError.message_id AS messageId
|
||||
FROM mangas JOIN libraryUpdateError
|
||||
ON mangas._id = libraryUpdateError.manga_id
|
||||
WHERE favorite = 1;
|
@@ -0,0 +1,17 @@
|
||||
CREATE VIEW libraryUpdateErrorView AS
|
||||
SELECT
|
||||
mangas._id AS mangaId,
|
||||
mangas.title AS mangaTitle,
|
||||
mangas.source,
|
||||
mangas.favorite,
|
||||
mangas.thumbnail_url AS thumbnailUrl,
|
||||
mangas.cover_last_modified AS coverLastModified,
|
||||
libraryUpdateError._id AS errorId,
|
||||
libraryUpdateError.message_id AS messageId
|
||||
FROM mangas JOIN libraryUpdateError
|
||||
ON mangas._id = libraryUpdateError.manga_id
|
||||
WHERE favorite = 1;
|
||||
|
||||
errors:
|
||||
SELECT *
|
||||
FROM libraryUpdateErrorView;
|
Reference in New Issue
Block a user