From 0778b4a58d5550b2d4e642e96bc64442bbd46b0b Mon Sep 17 00:00:00 2001 From: Sahil Garg Date: Mon, 6 Jul 2026 16:18:50 +0530 Subject: [PATCH] fix: fixed the message button to go to individual chat page instead of messages page. --- .../src/routes/(protected)/profile/[id]/+page.svelte | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platforms/pictique/client/src/routes/(protected)/profile/[id]/+page.svelte b/platforms/pictique/client/src/routes/(protected)/profile/[id]/+page.svelte index a19ed7ef2..3379c8104 100644 --- a/platforms/pictique/client/src/routes/(protected)/profile/[id]/+page.svelte +++ b/platforms/pictique/client/src/routes/(protected)/profile/[id]/+page.svelte @@ -5,7 +5,7 @@ import { selectedPost } from '$lib/store/store.svelte'; import { comments as commentsStore, createComment, fetchComments } from '$lib/stores/comments'; import { toggleLike } from '$lib/stores/posts'; - import type { PostData, userProfile } from '$lib/types'; + import type { Chat, PostData, userProfile } from '$lib/types'; import { Modal } from '$lib/ui'; import { apiClient, getAuthId } from '$lib/utils/axios'; import { onMount } from 'svelte'; @@ -71,14 +71,14 @@ async function handleMessage() { try { - await apiClient.post('/api/chats/', { - name: profile?.username, + // Omit `name` so the API treats this as a 1-to-1 chat and returns the + // existing conversation between these two users instead of duplicating it. + const { data: chat } = await apiClient.post('/api/chats', { participantIds: [profileId] }); - goto('/messages'); - await fetchProfile(); // Refresh profile to update follower count + goto(`/messages/${chat.id}`); } catch (err) { - error = err instanceof Error ? err.message : 'Failed to follow user'; + error = err instanceof Error ? err.message : 'Failed to message user'; } }