feat(provenance): gallery store post_id filter (mutually exclusive with tag_id)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 20:16:09 -04:00
parent 7bfd700671
commit b33253429a
2 changed files with 71 additions and 7 deletions
+19 -7
View File
@@ -10,7 +10,7 @@ export const useGalleryStore = defineStore('gallery', () => {
const nextCursor = ref(null)
const loading = ref(false)
const error = ref(null)
const filter = ref({ tag_id: null })
const filter = ref({ tag_id: null, post_id: null })
const timelineBuckets = ref([])
const timelineLoading = ref(false)
@@ -30,8 +30,7 @@ export const useGalleryStore = defineStore('gallery', () => {
error.value = null
const myId = ++inflightId
try {
const params = { limit: 50 }
if (filter.value.tag_id) params.tag_id = filter.value.tag_id
const params = { limit: 50, ...activeFilterParam() }
if (nextCursor.value) params.cursor = nextCursor.value
const body = await api.get('/api/gallery/scroll', { params })
if (myId !== inflightId) return // stale response
@@ -48,7 +47,7 @@ export const useGalleryStore = defineStore('gallery', () => {
async function loadTimeline() {
timelineLoading.value = true
try {
const params = filter.value.tag_id ? { tag_id: filter.value.tag_id } : {}
const params = activeFilterParam()
timelineBuckets.value = await api.get('/api/gallery/timeline', { params })
} finally {
timelineLoading.value = false
@@ -56,8 +55,7 @@ export const useGalleryStore = defineStore('gallery', () => {
}
async function jumpTo(year, month) {
const params = { year, month }
if (filter.value.tag_id) params.tag_id = filter.value.tag_id
const params = { year, month, ...activeFilterParam() }
const body = await api.get('/api/gallery/jump', { params })
if (body.cursor) {
images.value = []
@@ -67,8 +65,22 @@ export const useGalleryStore = defineStore('gallery', () => {
}
}
function activeFilterParam() {
if (filter.value.tag_id) return { tag_id: filter.value.tag_id }
if (filter.value.post_id) return { post_id: filter.value.post_id }
return {}
}
function setTagFilter(tagId) {
filter.value.tag_id = tagId
filter.value.post_id = null
loadInitial()
loadTimeline()
}
function setPostFilter(postId) {
filter.value.post_id = postId
filter.value.tag_id = null
loadInitial()
loadTimeline()
}
@@ -79,7 +91,7 @@ export const useGalleryStore = defineStore('gallery', () => {
return {
images, dateGroups, hasMore, isEmpty, loading, error,
filter, timelineBuckets, timelineLoading,
loadInitial, loadMore, loadTimeline, jumpTo, setTagFilter
loadInitial, loadMore, loadTimeline, jumpTo, setTagFilter, setPostFilter
}
})