diff --git a/platforms/pictique/src/lib/fragments/Post/Post.svelte b/platforms/pictique/src/lib/fragments/Post/Post.svelte index 977d5a773..3d7f6618a 100644 --- a/platforms/pictique/src/lib/fragments/Post/Post.svelte +++ b/platforms/pictique/src/lib/fragments/Post/Post.svelte @@ -7,6 +7,7 @@ import { ArrowLeftIcon, ArrowRightIcon, RecordIcon } from '@hugeicons/core-free-icons'; import { HugeiconsIcon } from '@hugeicons/svelte'; import type { HTMLAttributes } from 'svelte/elements'; + import { Spring } from 'svelte/motion'; interface IPostProps extends HTMLAttributes { avatar: string; @@ -92,6 +93,20 @@ const img = event.target as HTMLImageElement; img.src = 'https://picsum.photos/200'; } + + const scale = new Spring(1, { + stiffness: 0.15, + damping: 0.25 + }); + + async function handleLikeWithInteraction() { + scale.target = 1.4; + try { + await callback.like(); + } finally { + setTimeout(() => (scale.target = 1), 150); + } + }
@@ -168,14 +183,19 @@ {#if count}
-

{new Date(time).toLocaleDateString()} diff --git a/platforms/pictique/src/routes/(protected)/+layout.svelte b/platforms/pictique/src/routes/(protected)/+layout.svelte index 63dd40ce0..2de8e230f 100644 --- a/platforms/pictique/src/routes/(protected)/+layout.svelte +++ b/platforms/pictique/src/routes/(protected)/+layout.svelte @@ -197,8 +197,8 @@ core concepts of the W3DS ecosystem.

- It is not a production-grade platform and may lack full reliability, performance, - and security guarantees. + It is not a production-grade platform and may lack full reliability, performance, and + security guarantees.

We strongly recommend that you avoid sharing sensitive or private content, diff --git a/platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte b/platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte index 3db8438df..76048abff 100644 --- a/platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte +++ b/platforms/pictique/src/routes/(protected)/group/[id]/+page.svelte @@ -156,13 +156,13 @@ {@const nextMessage = index < messages.length - 1 ? messages[index + 1] : null} {@const isHeadNeeded = Boolean( !prevMessage || - prevMessage.isOwn !== msg.isOwn || - (prevMessage.senderId && msg.senderId && prevMessage.senderId !== msg.senderId) + prevMessage.isOwn !== msg.isOwn || + (prevMessage.senderId && msg.senderId && prevMessage.senderId !== msg.senderId) )} {@const isTimestampNeeded = Boolean( !nextMessage || - nextMessage.isOwn !== msg.isOwn || - (nextMessage.senderId && msg.senderId && nextMessage.senderId !== msg.senderId) + nextMessage.isOwn !== msg.isOwn || + (nextMessage.senderId && msg.senderId && nextMessage.senderId !== msg.senderId) )} (null); let error = $state(null); @@ -22,7 +34,6 @@ return response.data; } }); - async function fetchProfile() { try { loading = true; @@ -59,10 +70,14 @@ } } - function handlePostClick(post: PostData) { - console.log(post); + async function handlePostClick(post: PostData) { selectedPost.value = post; - // goto("/profile/post"); + try { + // Trigger the store to fetch comments for this specific post + await fetchComments(post.id); + } catch (err) { + console.error('Error loading comments:', err); + } } onMount(fetchProfile); @@ -130,15 +145,33 @@ text={selectedPost.value?.caption ?? ''} count={selectedPost.value?.count ?? { likes: 0, comments: 0 }} {ownerProfile} + isLiked={ownerProfile + ? ((selectedPost.value as any)?.likedBy?.some( + (user: any) => user.id === ownerProfile.id + ) ?? false) + : false} callback={{ like: async () => { - await toggleLike(selectedPost.value?.id ?? ''); + if (!selectedPost.value?.id) return; + try { + const result = await toggleLike(selectedPost.value.id); + if (selectedPost.value && result?.likedBy) { + (selectedPost.value as any).likedBy = result.likedBy; + } + } catch (err) { + console.error('Failed to toggle like:', err); + } }, comment: async (comment) => { if (!selectedPost.value) return; - await createComment(selectedPost.value?.id, comment); + try { + await createComment(selectedPost.value.id, comment); + } catch (err) { + console.error('Failed to create comment:', err); + } } }} + comments={$commentsStore} time={selectedPost.value?.time ?? ''} />