Monorepo for Tangled tangled.org

appview: implement follower and following pages for users #484

merged opened by ptr.pet targeting master from [deleted fork]: followers-following-list
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dfl62fgb7wtjj3fcbb72naae/sh.tangled.repo.pull/3lwawsuk3de22
+33 -15
Interdiff #2 #3
appview/db/profile.go

This file has not been changed.

appview/db/timeline.go

This file has not been changed.

appview/pages/funcmap.go

This file has not been changed.

+6 -4
appview/pages/pages.go
··· 435 435 } 436 436 437 437 type FollowCard struct { 438 - UserDid string 439 - UserHandle string 440 - FollowStatus db.FollowStatus 441 - Profile *db.Profile 438 + UserDid string 439 + UserDisplayName string 440 + FollowStatus db.FollowStatus 441 + FollowersCount int 442 + FollowingCount int 443 + Profile *db.Profile 442 444 } 443 445 444 446 type FollowersPageParams struct {
appview/pages/templates/user/followers.html

This file has not been changed.

appview/pages/templates/user/following.html

This file has not been changed.

appview/pages/templates/user/fragments/follow.html

This file has not been changed.

+7 -1
appview/pages/templates/user/fragments/followCard.html
··· 7 7 8 8 <div class="flex-1 min-h-0 justify-around flex flex-col"> 9 9 <a href="/{{ .UserHandle }}"> 10 - <span class="font-bold dark:text-white overflow-hidden text-ellipsis whitespace-nowrap max-w-full">{{ .UserHandle | truncateAt30 }}</span> 10 + <span class="font-bold dark:text-white overflow-hidden text-ellipsis whitespace-nowrap max-w-full">{{ .UserDisplayName | truncateAt30 }}</span> 11 11 </a> 12 12 <p class="text-sm pb-2 md:pb-2">{{.Profile.Description}}</p> 13 + <div class="text-sm flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full"> 14 + <span class="flex-shrink-0">{{ i "users" "size-4" }}</span> 15 + <span id="followers">{{ .FollowersCount }} followers</span> 16 + <span class="select-none after:content-['·']"></span> 17 + <span id="following">{{ .FollowingCount }} following</span> 18 + </div> 13 19 </div> 14 20 15 21 {{ if ne .FollowStatus.String "IsSelf" }}
appview/pages/templates/user/fragments/profileCard.html

This file has not been changed.

+19 -9
appview/state/profile.go
··· 226 226 227 227 followCards := make([]pages.FollowCard, 0, len(follows)) 228 228 for _, did := range followDids { 229 - ident, err := s.idResolver.ResolveIdent(ctx, did) 230 - if err != nil { 229 + var handle string 230 + if ident, err := s.idResolver.ResolveIdent(ctx, did); err != nil { 231 231 log.Printf("can't resolve handle for %s: %s", did, err) 232 - return nil, err 232 + handle = did 233 + } else if ident.Handle.IsInvalidHandle() { 234 + handle = fmt.Sprintf("handle.invalid (%s)", did) 235 + } else { 236 + handle = ident.Handle.String() 237 + } 238 + followersCount, followingCount, err := db.GetFollowerFollowingCount(s.db, did) 239 + if err != nil { 240 + log.Printf("getting follow stats for %s: %s", did, err) 233 241 } 234 242 followStatus := db.IsNotFollowing 235 243 if loggedInUserFollowing != nil { ··· 247 255 profile.Did = did 248 256 } 249 257 followCards = append(followCards, pages.FollowCard{ 250 - UserDid: did, 251 - UserHandle: ident.Handle.String(), 252 - FollowStatus: followStatus, 253 - Profile: profile, 258 + UserDid: did, 259 + UserDisplayName: handle, 260 + FollowStatus: followStatus, 261 + FollowersCount: followersCount, 262 + FollowingCount: followingCount, 263 + Profile: profile, 254 264 }) 255 265 } 256 266 return followCards, nil ··· 291 301 292 302 followersCount, followingCount, err := db.GetFollowerFollowingCount(s.db, ident.DID.String()) 293 303 if err != nil { 294 - log.Printf("getting follow stats repos for %s: %s", ident.DID.String(), err) 304 + log.Printf("getting follow stats for %s: %s", ident.DID.String(), err) 295 305 } 296 306 297 307 s.pages.FollowersPage(w, pages.FollowersPageParams{ ··· 343 353 344 354 followersCount, followingCount, err := db.GetFollowerFollowingCount(s.db, ident.DID.String()) 345 355 if err != nil { 346 - log.Printf("getting follow stats repos for %s: %s", ident.DID.String(), err) 356 + log.Printf("getting follow stats for %s: %s", ident.DID.String(), err) 347 357 } 348 358 349 359 s.pages.FollowingPage(w, pages.FollowingPageParams{
appview/state/router.go

This file has not been changed.

appview/strings/strings.go

This file has not been changed.

+1 -1
appview/pages/templates/timeline.html
··· 150 150 {{ end }} 151 151 {{ end }} 152 152 {{ with $stat }} 153 - <div class="text-sm flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full text-sm"> 153 + <div class="text-sm flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full"> 154 154 <span class="flex-shrink-0">{{ i "users" "size-4" }}</span> 155 155 <span id="followers">{{ .Followers }} followers</span> 156 156 <span class="select-none after:content-['·']"></span>

History

14 rounds 6 comments
sign up or login to add to the discussion
1 commit
expand
cb75b373
appview: implement follower and following pages for users
expand 0 comments
pull request successfully merged
1 commit
expand
98413d89
appview: implement follower and following pages for users
expand 0 comments
1 commit
expand
118fb342
appview: implement follower and following pages for users
expand 0 comments
1 commit
expand
7a5c931a
appview: implement follower and following pages for users
expand 0 comments
1 commit
expand
773aa964
appview: implement follower and following pages for users
expand 1 comment
  • fixed timeline linking to wrong user (forgot to use subjectHandle instead of userHandle)
  • use ?tab= for followers / following like repo page does
  • fix repos opengraph url from /repos to ?tab=repos
1 commit
expand
ece60a35
appview: implement follower and following pages for users
expand 1 comment
  • added following / follower page links to timeline and follow cards
  • also added followers and following to profile tab switch case
1 commit
expand
a8bcde9d
appview: implement follower and following pages for users
expand 1 comment

using resolve in html instead of resolving handles in go code, and dedupped followers/followingPage into followPage

1 commit
expand
a285cd0f
appview: implement follower and following pages for users
expand 0 comments
1 commit
expand
3c2d8223
appview: implement follower and following pages for users
expand 1 comment

fixed some issues now that i got my dev setup working again

1 commit
expand
90b0a392
appview: implement follower and following pages for users
expand 1 comment

comments from #1 should be addressed now

on top of that changed GetProfiles to return a map instead of array, which seemed easier to do since it internally uses a map anyway and both places it's used in need it as a map

1 commit
expand
0dfc15e9
appview: implement follower and following pages for users
expand 0 comments
1 commit
expand
9643a898
appview: implement follower and following pages for users
expand 0 comments
1 commit
expand
cf9a2ce8
appview: implement follower and following pages for users
expand 1 comment

the pages themselves look pretty good for a start!

  • i'd like to add follower-following count to each item (to make these identical to the profile cards in the timeline)
  • this GetProfile call results in an N+1 query. we have a helper called GetProfiles to help with this, you can get profiles of multiple DIDs in one DB call. db/timeline.go has an example of the same.

overall, i'm loving this stack!

ptr.pet submitted #0
1 commit
expand
cbdbaf6d
appview: implement follower and following pages for users
expand 0 comments