From 61fde769292d46be97ca6cfcfee5c47e0abbdbae Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Thu, 2 Apr 2026 17:42:32 +0800 Subject: [PATCH] collection name and menu in toolbar --- next-ui/src/colada/collections.ts | 19 ++++++---- next-ui/src/components.d.ts | 1 + next-ui/src/components/ChipCount.vue | 1 - .../collection/menu/CollectionMenuButton.vue | 38 +++++++++++++++++++ next-ui/src/pages/collection/[id].vue | 13 ++++++- next-ui/src/pages/libraries/[id]/books.vue | 5 ++- .../src/pages/libraries/[id]/collections.vue | 5 ++- .../src/pages/libraries/[id]/readlists.vue | 5 ++- next-ui/src/pages/libraries/[id]/series.vue | 5 ++- 9 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 next-ui/src/components/collection/menu/CollectionMenuButton.vue diff --git a/next-ui/src/colada/collections.ts b/next-ui/src/colada/collections.ts index eafcab06..122b58c1 100644 --- a/next-ui/src/colada/collections.ts +++ b/next-ui/src/colada/collections.ts @@ -1,4 +1,4 @@ -import { defineMutation, defineQueryOptions, useMutation } from '@pinia/colada' +import { defineMutation, defineQueryOptions, useMutation, useQueryCache } from '@pinia/colada' import { komgaClient } from '@/api/komga-client' import type { PageRequest } from '@/types/PageRequest' import type { components } from '@/generated/openapi/komga' @@ -55,7 +55,7 @@ export const collectionDetailQuery = defineQueryOptions( ) export const useUpdateCollection = defineMutation(() => { - // const queryCache = useQueryCache() + const queryCache = useQueryCache() return useMutation({ mutation: ({ collectionId, @@ -73,14 +73,14 @@ export const useUpdateCollection = defineMutation(() => { body: data, }), onSuccess: () => { - //TODO: check how to invalidate cache - // void queryCache.invalidateQueries({ key: QUERY_KEYS_LIBRARIES.root }) + void queryCache.invalidateQueries({ key: QUERY_KEYS_COLLECTIONS.root }, 'all') }, }) }) -export const useDeleteCollection = defineMutation(() => - useMutation({ +export const useDeleteCollection = defineMutation(() => { + const queryCache = useQueryCache() + return useMutation({ mutation: (collectionId: string) => komgaClient.DELETE('/api/v1/collections/{id}', { params: { @@ -89,5 +89,8 @@ export const useDeleteCollection = defineMutation(() => }, }, }), - }), -) + onSuccess: () => { + void queryCache.invalidateQueries({ key: QUERY_KEYS_COLLECTIONS.root }, 'all') + }, + }) +}) diff --git a/next-ui/src/components.d.ts b/next-ui/src/components.d.ts index 9ea5572b..3b49bc03 100644 --- a/next-ui/src/components.d.ts +++ b/next-ui/src/components.d.ts @@ -28,6 +28,7 @@ declare module 'vue' { CollectionDeletionWarning: typeof import('./components/collection/DeletionWarning.vue')['default'] CollectionMenu: typeof import('./components/collection/menu/CollectionMenu.vue')['default'] CollectionMenuBottomSheet: typeof import('./components/collection/menu/CollectionMenuBottomSheet.vue')['default'] + CollectionMenuButton: typeof import('./components/collection/menu/CollectionMenuButton.vue')['default'] DialogBookPicker: typeof import('./components/dialog/BookPicker.vue')['default'] DialogConfirm: typeof import('./components/dialog/Confirm.vue')['default'] DialogConfirmEdit: typeof import('./components/dialog/ConfirmEdit.vue')['default'] diff --git a/next-ui/src/components/ChipCount.vue b/next-ui/src/components/ChipCount.vue index cf00d3d4..ecd94807 100644 --- a/next-ui/src/components/ChipCount.vue +++ b/next-ui/src/components/ChipCount.vue @@ -2,7 +2,6 @@ {{ count }} diff --git a/next-ui/src/components/collection/menu/CollectionMenuButton.vue b/next-ui/src/components/collection/menu/CollectionMenuButton.vue new file mode 100644 index 00000000..6cf6bf31 --- /dev/null +++ b/next-ui/src/components/collection/menu/CollectionMenuButton.vue @@ -0,0 +1,38 @@ + + + + + + + diff --git a/next-ui/src/pages/collection/[id].vue b/next-ui/src/pages/collection/[id].vue index 1861accd..01c17aaa 100644 --- a/next-ui/src/pages/collection/[id].vue +++ b/next-ui/src/pages/collection/[id].vue @@ -1,5 +1,12 @@