Coffee journaling on ATProto (alpha) alpha.arabica.social
coffee

fix: fix profile and brew viewing bugs #9

closed opened by pdewey.com targeting main from refactor-svelte
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:hm5f3dnm6jdhrc55qp2npdja/sh.tangled.repo.pull/3mdercwj6w222
+29 -7
Diff #0
-4
BACKLOG.md
··· 58 58 - Profile page should show more details, and allow brew entries to take up more vertical space 59 59 60 60 - Show "view" button on brews in profile page (same as on brews list page) 61 - 62 - - Navigating to "my profile" while on another user's profile, the url changes but the page does not change 63 - 64 - - Clicking "back to brews" on brew view page returns user to their brews list, even if the brew belonged to another user
+23 -2
frontend/src/routes/BrewView.svelte
··· 13 13 let loading = true; 14 14 let error = null; 15 15 let isOwnProfile = false; 16 + let brewOwnerHandle = null; 17 + let brewOwnerDID = null; 16 18 17 19 $: isAuthenticated = $authStore.isAuthenticated; 18 20 $: currentUserDID = $authStore.user?.did; ··· 52 54 brew = brews.find((b) => b.rkey === brewRKey); 53 55 if (!brew) { 54 56 error = "Brew not found"; 57 + } else { 58 + // Set owner to current user for own brews 59 + brewOwnerDID = currentUserDID; 60 + brewOwnerHandle = $authStore.user?.handle; 55 61 } 56 62 } 57 63 ··· 60 66 // Fetch brew from API using AT-URI 61 67 const atURI = `at://${userDID}/social.arabica.alpha.brew/${brewRKey}`; 62 68 brew = await api.get(`/api/brew?uri=${encodeURIComponent(atURI)}`); 69 + brewOwnerDID = userDID; 70 + 71 + // Fetch the profile to get the handle 72 + const profileData = await api.get(`/api/profile-json/${userDID}`); 73 + brewOwnerHandle = profileData.profile?.handle; 63 74 } catch (err) { 64 75 console.error("Failed to load brew:", err); 65 76 error = err.message || "Failed to load brew"; ··· 341 352 <!-- Back button --> 342 353 <div class="mt-6"> 343 354 <button 344 - on:click={() => navigate("/brews")} 355 + on:click={() => { 356 + if (isOwnProfile) { 357 + navigate("/brews"); 358 + } else if (brewOwnerHandle) { 359 + navigate(`/profile/${brewOwnerHandle}`); 360 + } else if (brewOwnerDID) { 361 + navigate(`/profile/${brewOwnerDID}`); 362 + } else { 363 + navigate("/"); 364 + } 365 + }} 345 366 class="text-brown-700 hover:text-brown-900 font-medium hover:underline" 346 367 > 347 - ← Back to Brews 368 + ← {isOwnProfile ? "Back to My Brews" : "Back to Profile"} 348 369 </button> 349 370 </div> 350 371 </div>
+5
frontend/src/routes/Profile.svelte
··· 41 41 await loadProfile(); 42 42 }); 43 43 44 + // Reload profile when actor prop changes (e.g., navigating from one profile to another) 45 + $: if (actor) { 46 + loadProfile(); 47 + } 48 + 44 49 async function loadProfile() { 45 50 try { 46 51 const data = await api.get(`/api/profile-json/${actor}`);
+1 -1
static/app/index.html
··· 35 35 <!-- Web Manifest --> 36 36 <link rel="manifest" href="/static/manifest.json" /> 37 37 <meta name="theme-color" content="#78350f" /> 38 - <script type="module" crossorigin src="/static/app/assets/index-Byldwb2g.js"></script> 38 + <script type="module" crossorigin src="/static/app/assets/index-COWWPLMS.js"></script> 39 39 <link rel="stylesheet" crossorigin href="/static/app/assets/index-DUcERGgO.css"> 40 40 </head> 41 41 <body class="bg-brown-50 text-brown-900 min-h-screen">

History

1 round 0 comments
sign up or login to add to the discussion
pdewey.com submitted #0
1 commit
expand
fix: fix profile and brew viewing bugs
expand 0 comments
closed without merging