diff --git a/backend/app/api/tags.py b/backend/app/api/tags.py index de086eb..94bddff 100644 --- a/backend/app/api/tags.py +++ b/backend/app/api/tags.py @@ -194,6 +194,24 @@ async def remove_tag_from_image(image_id: int, tag_id: int): return "", 204 +@tags_bp.route("/tags/", methods=["GET"]) +async def get_tag(tag_id: int): + """Resolve a single tag (used by the gallery to label its active + tag-filter chip).""" + async with get_session() as session: + tag = await session.get(Tag, tag_id) + if tag is None: + return jsonify({"error": "tag not found"}), 404 + return jsonify( + { + "id": tag.id, + "name": tag.name, + "kind": tag.kind.value, + "fandom_id": tag.fandom_id, + } + ) + + @tags_bp.route("/tags/", methods=["PATCH"]) async def update_tag(tag_id: int): """Rename and/or re-fandom a tag. Body may carry `name` and/or diff --git a/frontend/src/stores/gallery.js b/frontend/src/stores/gallery.js index de52d5b..407b3a4 100644 --- a/frontend/src/stores/gallery.js +++ b/frontend/src/stores/gallery.js @@ -22,6 +22,9 @@ export const useGalleryStore = defineStore('gallery', () => { const loading = ref(false) const error = ref(null) const filter = ref({ tag_id: null, post_id: null }) + // Display name for the active tag filter, so the gallery can label a + // "Tag: X ✕" chip instead of leaving the filter invisible/unclearable. + const filterTagName = ref(null) const timelineBuckets = ref([]) const timelineLoading = ref(false) @@ -94,10 +97,20 @@ export const useGalleryStore = defineStore('gallery', () => { function setTagFilter(tagId) { filter.value.tag_id = tagId filter.value.post_id = null + filterTagName.value = null + if (tagId) _resolveTagName(tagId) // fire-and-forget; chip label only loadInitial() loadTimeline() } + async function _resolveTagName(tagId) { + try { + filterTagName.value = (await api.get(`/api/tags/${tagId}`)).name + } catch { + // Leave null — the chip falls back to "#". + } + } + function setPostFilter(postId) { filter.value.post_id = postId filter.value.tag_id = null @@ -110,7 +123,7 @@ export const useGalleryStore = defineStore('gallery', () => { return { images, dateGroups, hasMore, isEmpty, loading, error, - filter, timelineBuckets, timelineLoading, + filter, filterTagName, timelineBuckets, timelineLoading, loadInitial, loadMore, loadTimeline, jumpTo, setTagFilter, setPostFilter } }) diff --git a/frontend/src/views/GalleryView.vue b/frontend/src/views/GalleryView.vue index 03c804c..ea318fe 100644 --- a/frontend/src/views/GalleryView.vue +++ b/frontend/src/views/GalleryView.vue @@ -12,6 +12,13 @@