Skip to content

Commit a6c5925

Browse files
authored
Fix/dreamsync welcome (#676)
* fix: follow-button-message * fix: dreamsync-welcome * fix: pictique timer * fix: code rabbit suggestion * fix: removed another pr changes * fix: suggestion added as we discussed on slack thread
1 parent 2e0fffc commit a6c5925

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

platforms/dreamSync/client/src/pages/wishlist-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export default function WishlistEditor() {
113113
<Sparkles className="w-8 h-8 text-blue-400" />
114114
</div>
115115
<p className="text-lg text-gray-300">
116-
Welcome back, <span className="font-semibold text-white">{user?.firstName || user?.email || 'User'}</span>!
116+
Welcome back, <span className="font-semibold text-white">{user?.name|| user?.email || 'User'}</span>!
117117
</p>
118118
<p className="text-sm text-gray-400 mt-2">
119119
{existingWishlist ? 'Edit your wishlist' : 'Create and share your dreams, goals, and what you can offer to the world'}

platforms/dreamSync/shared/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ export type GroupSuggestion = Suggestion;
302302

303303
// Extended types for API responses
304304
export type UserWithProfile = User & {
305+
name?:string;
305306
profile?: Profile;
306307
skills?: Skill[];
307308
interests?: Interest[];

platforms/pictique/src/lib/fragments/Profile/Profile.svelte

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,26 @@
1212
handleFollow,
1313
handleSinglePost,
1414
handleMessage,
15-
isFollowing = $bindable(false)
15+
isFollowing = $bindable(false),
16+
didFollowed = $bindable(false)
1617
}: {
1718
variant: 'user' | 'other';
1819
profileData: userProfile;
1920
handleSinglePost: (post: PostData) => void;
2021
handleFollow: () => Promise<void>;
2122
handleMessage: () => Promise<void>;
2223
isFollowing: boolean;
24+
didFollowed: boolean;
2325
} = $props();
2426
2527
let imgPosts = $derived(profileData.posts.filter((e) => e.imgUris && e.imgUris.length > 0));
26-
let requestSent = $state(false);
2728
2829
const btnScale = new Spring(1, { stiffness: 0.2, damping: 0.4 });
2930
3031
async function wrappedFollow() {
31-
if (isFollowing || requestSent) return;
32-
3332
btnScale.target = 0.95;
34-
35-
try {
36-
await handleFollow();
37-
38-
requestSent = true;
39-
btnScale.target = 1;
40-
41-
setTimeout(() => {
42-
requestSent = false;
43-
}, 2000);
44-
} catch (e) {
45-
console.error(e);
46-
btnScale.target = 1;
47-
}
33+
await handleFollow();
34+
btnScale.target = 1;
4835
}
4936
</script>
5037

@@ -69,15 +56,14 @@
6956
variant={'primary'}
7057
size="sm"
7158
callback={wrappedFollow}
72-
disabled={isFollowing || requestSent}
73-
class="min-w-[110px] transition-all duration-500 {requestSent
59+
class="min-w-[110px] transition-all duration-500 {didFollowed
7460
? 'opacity-80'
7561
: ''}"
7662
>
7763
<div class="flex items-center justify-center gap-2">
78-
{#if requestSent}
64+
{#if didFollowed}
7965
<HugeiconsIcon icon={Tick01Icon} size={16} />
80-
<span>Followed</span>
66+
<span>Following</span>
8167
{:else if isFollowing}
8268
<span class="flex gap-0.5">
8369
<span class="animate-bounce">.</span>

platforms/pictique/src/routes/(protected)/profile/[id]/+page.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
let loading = $state(true);
2929
let ownerId: string | null = $derived(getAuthId());
3030
let isFollowing = $state(false);
31+
let didFollowed = $state(false);
3132
let ownerProfile = $derived.by(async () => {
3233
if (ownerId) {
3334
const response = await apiClient.get<userProfile>(`/api/users/${ownerId}`);
@@ -52,10 +53,17 @@
5253
async function handleFollow() {
5354
try {
5455
isFollowing = true;
55-
await apiClient.post(`/api/users/${profileId}/follow`);
56-
// await fetchProfile(); // Refresh profile to update follower count
56+
const response = await apiClient.post(`/api/users/${profileId}/follow`);
57+
if (response) {
58+
didFollowed = true;
59+
setTimeout(async () => {
60+
await fetchProfile();
61+
didFollowed = false;
62+
}, 1000);
63+
}
5764
} catch (err) {
5865
error = err instanceof Error ? err.message : 'Failed to follow user';
66+
didFollowed = false;
5967
} finally {
6068
isFollowing = false;
6169
}
@@ -99,6 +107,7 @@
99107
{:else if profile}
100108
<Profile
101109
bind:isFollowing
110+
bind:didFollowed
102111
variant={ownerId === profileId ? 'user' : 'other'}
103112
profileData={profile}
104113
handleSinglePost={(post) => handlePostClick(post)}

0 commit comments

Comments
 (0)