From 90c176b195c164064749fab4643b6323937c847f Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 26 May 2026 20:48:49 -0400 Subject: [PATCH] =?UTF-8?q?feat(postmodal-store):=20Pinia=20store=20drivin?= =?UTF-8?q?g=20the=20app-level=20PostModal=20=E2=80=94=20open(post)=20fetc?= =?UTF-8?q?hes=20full=20detail=20via=20posts=20store;=20close()=20clears?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/src/stores/postModal.js | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 frontend/src/stores/postModal.js diff --git a/frontend/src/stores/postModal.js b/frontend/src/stores/postModal.js new file mode 100644 index 0000000..64fd1c9 --- /dev/null +++ b/frontend/src/stores/postModal.js @@ -0,0 +1,39 @@ +import { defineStore } from 'pinia' +import { ref, computed } from 'vue' +import { usePostsStore } from './posts.js' + +export const usePostModalStore = defineStore('postModal', () => { + const postsStore = usePostsStore() + + // Feed-shape on open; upgraded to detail shape (full description + + // uncapped thumbnails) once getPostFull resolves. + const currentPost = ref(null) + const detailLoaded = ref(false) + const error = ref(null) + const isOpen = computed(() => currentPost.value !== null) + + async function open (post) { + currentPost.value = post + detailLoaded.value = false + error.value = null + try { + const detail = await postsStore.getPostFull(post.id) + if (currentPost.value?.id === post.id) { + currentPost.value = detail + detailLoaded.value = true + } + } catch (e) { + // Keep feed-shape data; PostModal can still render title + truncated + // description + the up-to-6 feed thumbnails. Just surface the error. + error.value = e.message + } + } + + function close () { + currentPost.value = null + detailLoaded.value = false + error.value = null + } + + return { currentPost, detailLoaded, error, isOpen, open, close } +})