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

fix: don't redirect on adding new gear

pdewey.com 49490655 b98de5f8

verified
+29 -7
+6
BACKLOG.md
··· 25 25 - For now, monolithic approach is appropriate for HTMX-based web app with decentralized storage 26 26 27 27 ## Fixes 28 + 29 + - Adding new gear (grinders, etc.) from profile page redirects to brews on profile page after (should stay on current page) 30 + - Brews on profile page are stored in chronological order, should be reverse chronological (newest first) 31 + 32 + - [Future work]: adjust timing of caching in feed, maybe use firehose and a sqlite database since we are only storing a few anyway 33 + - Goal: reduce pings to server when idling
+11
internal/handlers/handlers.go
··· 4 4 "context" 5 5 "encoding/json" 6 6 "net/http" 7 + "sort" 7 8 "strconv" 8 9 "strings" 9 10 ··· 1416 1417 } 1417 1418 } 1418 1419 1420 + // Sort brews in reverse chronological order (newest first) 1421 + sort.Slice(brews, func(i, j int) bool { 1422 + return brews[i].CreatedAt.After(brews[j].CreatedAt) 1423 + }) 1424 + 1419 1425 // Check if current user is authenticated (for nav bar state) 1420 1426 didStr, err := atproto.GetAuthenticatedDID(ctx) 1421 1427 isAuthenticated := err == nil && didStr != "" ··· 1621 1627 } 1622 1628 } 1623 1629 } 1630 + 1631 + // Sort brews in reverse chronological order (newest first) 1632 + sort.Slice(brews, func(i, j int) bool { 1633 + return brews[i].CreatedAt.After(brews[j].CreatedAt) 1634 + }) 1624 1635 1625 1636 // Check if the viewing user is the profile owner 1626 1637 didStr, err := atproto.GetAuthenticatedDID(ctx)
+7 -7
templates/profile.tmpl
··· 61 61 </div> 62 62 63 63 <!-- Tabs for content sections --> 64 - <div x-data="{ activeTab: 'brews' }"> 64 + <div> 65 65 <!-- Tab buttons (show immediately) --> 66 66 <div class="bg-gradient-to-br from-brown-100 to-brown-200 rounded-xl shadow-md mb-4 border border-brown-300"> 67 67 <div class="flex border-b border-brown-300"> 68 - <button 69 - @click="activeTab = 'brews'" 68 + <button 69 + @click="activeTab = 'brews'" 70 70 :class="activeTab === 'brews' ? 'border-b-2 border-brown-700 text-brown-900' : 'text-brown-600 hover:text-brown-800'" 71 71 class="flex-1 py-3 px-4 text-center font-medium transition-colors"> 72 72 Brews 73 73 </button> 74 - <button 75 - @click="activeTab = 'beans'" 74 + <button 75 + @click="activeTab = 'beans'" 76 76 :class="activeTab === 'beans' ? 'border-b-2 border-brown-700 text-brown-900' : 'text-brown-600 hover:text-brown-800'" 77 77 class="flex-1 py-3 px-4 text-center font-medium transition-colors"> 78 78 Beans 79 79 </button> 80 - <button 81 - @click="activeTab = 'gear'" 80 + <button 81 + @click="activeTab = 'gear'" 82 82 :class="activeTab === 'gear' ? 'border-b-2 border-brown-700 text-brown-900' : 'text-brown-600 hover:text-brown-800'" 83 83 class="flex-1 py-3 px-4 text-center font-medium transition-colors"> 84 84 Gear
+5
web/static/js/manage-page.js
··· 5 5 function managePage() { 6 6 return { 7 7 tab: localStorage.getItem("manageTab") || "beans", 8 + activeTab: localStorage.getItem("profileTab") || "brews", 8 9 showBeanForm: false, 9 10 showRoasterForm: false, 10 11 showGrinderForm: false, ··· 28 29 init() { 29 30 this.$watch("tab", (value) => { 30 31 localStorage.setItem("manageTab", value); 32 + }); 33 + 34 + this.$watch("activeTab", (value) => { 35 + localStorage.setItem("profileTab", value); 31 36 }); 32 37 33 38 // Initialize cache in background