From 241abc3956a1c335a85077c5dbf7c0a82ccac4f2 Mon Sep 17 00:00:00 2001 From: Mitchell Syer Date: Sat, 27 May 2023 14:09:47 -0400 Subject: [PATCH] Add items that are related to the deleted meta (#562) --- .../graphql/mutations/CategoryMutation.kt | 15 +++++++++++---- .../graphql/mutations/ChapterMutation.kt | 13 +++++++++---- .../tachidesk/graphql/mutations/MangaMutation.kt | 13 +++++++++---- 3 files changed, 29 insertions(+), 12 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt index a79e3a03..45c177e5 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/CategoryMutation.kt @@ -6,8 +6,10 @@ import org.jetbrains.exposed.sql.deleteWhere import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.transactions.transaction import suwayomi.tachidesk.graphql.types.CategoryMetaType +import suwayomi.tachidesk.graphql.types.CategoryType import suwayomi.tachidesk.manga.impl.Category import suwayomi.tachidesk.manga.model.table.CategoryMetaTable +import suwayomi.tachidesk.manga.model.table.CategoryTable /** * TODO Mutations @@ -43,26 +45,31 @@ class CategoryMutation { ) data class DeleteCategoryMetaPayload( val clientMutationId: String?, - val meta: CategoryMetaType? + val meta: CategoryMetaType?, + val category: CategoryType ) fun deleteCategoryMeta( input: DeleteCategoryMetaInput ): DeleteCategoryMetaPayload { val (clientMutationId, categoryId, key) = input - val meta = transaction { + val (meta, category) = transaction { val meta = CategoryMetaTable.select { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } .firstOrNull() CategoryMetaTable.deleteWhere { (CategoryMetaTable.ref eq categoryId) and (CategoryMetaTable.key eq key) } + val category= transaction { + CategoryType(CategoryTable.select { CategoryTable.id eq categoryId }.first()) + } + if (meta != null) { CategoryMetaType(meta) } else { null - } + } to category } - return DeleteCategoryMetaPayload(clientMutationId, meta) + return DeleteCategoryMetaPayload(clientMutationId, meta, category) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt index 7142519c..7036c8a1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt @@ -156,26 +156,31 @@ class ChapterMutation { ) data class DeleteChapterMetaPayload( val clientMutationId: String?, - val meta: ChapterMetaType? + val meta: ChapterMetaType?, + val chapter: ChapterType ) fun deleteChapterMeta( input: DeleteChapterMetaInput ): DeleteChapterMetaPayload { val (clientMutationId, chapterId, key) = input - val meta = transaction { + val (meta, chapter) = transaction { val meta = ChapterMetaTable.select { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } .firstOrNull() ChapterMetaTable.deleteWhere { (ChapterMetaTable.ref eq chapterId) and (ChapterMetaTable.key eq key) } + val chapter= transaction { + ChapterType(ChapterTable.select { ChapterTable.id eq chapterId }.first()) + } + if (meta != null) { ChapterMetaType(meta) } else { null - } + } to chapter } - return DeleteChapterMetaPayload(clientMutationId, meta) + return DeleteChapterMetaPayload(clientMutationId, meta, chapter) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt index f0d19622..9621d173 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/MangaMutation.kt @@ -140,26 +140,31 @@ class MangaMutation { ) data class DeleteMangaMetaPayload( val clientMutationId: String?, - val meta: MangaMetaType? + val meta: MangaMetaType?, + val manga: MangaType ) fun deleteMangaMeta( input: DeleteMangaMetaInput ): DeleteMangaMetaPayload { val (clientMutationId, mangaId, key) = input - val meta = transaction { + val (meta, manga) = transaction { val meta = MangaMetaTable.select { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } .firstOrNull() MangaMetaTable.deleteWhere { (MangaMetaTable.ref eq mangaId) and (MangaMetaTable.key eq key) } + val manga = transaction { + MangaType(MangaTable.select { MangaTable.id eq mangaId }.first()) + } + if (meta != null) { MangaMetaType(meta) } else { null - } + } to manga } - return DeleteMangaMetaPayload(clientMutationId, meta) + return DeleteMangaMetaPayload(clientMutationId, meta, manga) } }