placeholder profile for when sailor profile is not found

This commit is contained in:
Evan Jarrett
2025-12-10 14:34:18 -06:00
parent cefe0038fc
commit 111cc4cc18
2 changed files with 23 additions and 9 deletions
+15 -7
View File
@@ -21,7 +21,7 @@ func (h *UserPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
identifier := chi.URLParam(r, "handle")
// Resolve identifier (handle or DID) to canonical DID and current handle
did, resolvedHandle, _, err := atproto.ResolveIdentity(r.Context(), identifier)
did, resolvedHandle, pdsEndpoint, err := atproto.ResolveIdentity(r.Context(), identifier)
if err != nil {
http.Error(w, "User not found", http.StatusNotFound)
return
@@ -33,13 +33,19 @@ func (h *UserPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if viewedUser == nil {
http.Error(w, "User not found", http.StatusNotFound)
return
}
// Opportunistically update cached handle if it changed
if viewedUser.Handle != resolvedHandle {
hasProfile := true
if viewedUser == nil {
// Valid ATProto user but hasn't set up ATCR profile
hasProfile = false
viewedUser = &db.User{
DID: did,
Handle: resolvedHandle,
PDSEndpoint: pdsEndpoint,
// Avatar intentionally empty - template shows '?' placeholder
}
} else if viewedUser.Handle != resolvedHandle {
// Opportunistically update cached handle if it changed
_ = db.UpdateUserHandle(h.DB, did, resolvedHandle)
viewedUser.Handle = resolvedHandle
}
@@ -77,10 +83,12 @@ func (h *UserPageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
PageData
ViewedUser *db.User // User whose page we're viewing
Repositories []db.RepoCardData
HasProfile bool
}{
PageData: NewPageData(r, h.RegistryURL),
ViewedUser: viewedUser,
Repositories: cards,
HasProfile: hasProfile,
}
if err := h.Templates.ExecuteTemplate(w, "user", data); err != nil {
+8 -2
View File
@@ -13,13 +13,19 @@
<div class="user-profile">
{{ if .ViewedUser.Avatar }}
<img src="{{ .ViewedUser.Avatar }}" alt="{{ .ViewedUser.Handle }}" class="profile-avatar">
{{ else }}
{{ else if .HasProfile }}
<div class="profile-avatar-placeholder">{{ firstChar .ViewedUser.Handle }}</div>
{{ else }}
<div class="profile-avatar-placeholder">?</div>
{{ end }}
<h1>{{ .ViewedUser.Handle }}</h1>
</div>
{{ if .Repositories }}
{{ if not .HasProfile }}
<div class="empty-state">
<p>This user hasn't set up their ATCR profile yet.</p>
</div>
{{ else if .Repositories }}
<div class="featured-grid">
{{ range .Repositories }}
{{ template "repo-card" . }}