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
+9 -18
Interdiff #1 #2
+5 -5
appview/pages/funcmap.go
··· 257 "layoutCenter": func() string { 258 return "col-span-1 md:col-span-8 lg:col-span-6" 259 }, 260 - 261 - "normalizeForHtmlId": func(s string) string { 262 - // TODO: extend this to handle other cases? 263 - return strings.ReplaceAll(s, ":", "_") 264 - }, 265 } 266 } 267 ··· 276 "layoutCenter": func() string { 277 return "col-span-1 md:col-span-8 lg:col-span-6" 278 }, 279 } 280 } 281
··· 257 "layoutCenter": func() string { 258 return "col-span-1 md:col-span-8 lg:col-span-6" 259 }, 260 } 261 } 262 ··· 271 "layoutCenter": func() string { 272 return "col-span-1 md:col-span-8 lg:col-span-6" 273 }, 274 + 275 + "normalizeForHtmlId": func(s string) string { 276 + // TODO: extend this to handle other cases? 277 + return strings.ReplaceAll(s, ":", "_") 278 + }, 279 } 280 } 281
appview/pages/pages.go

This patch was likely rebased, as context lines do not match.

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.

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

This file has not been changed.

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

This file has not been changed.

appview/state/profile.go

This patch was likely rebased, as context lines do not match.

appview/state/router.go

This file has not been changed.

appview/strings/strings.go

This file has not been changed.

+2 -7
appview/db/profile.go
··· 348 return tx.Commit() 349 } 350 351 - func GetProfiles(e Execer, filters ...filter) ([]Profile, error) { 352 var conditions []string 353 var args []any 354 for _, filter := range filters { ··· 448 idxs[did] = idx + 1 449 } 450 451 - var profiles []Profile 452 - for _, p := range profileMap { 453 - profiles = append(profiles, *p) 454 - } 455 - 456 - return profiles, nil 457 } 458 459 func GetProfile(e Execer, did string) (*Profile, error) {
··· 348 return tx.Commit() 349 } 350 351 + func GetProfiles(e Execer, filters ...filter) (map[string]*Profile, error) { 352 var conditions []string 353 var args []any 354 for _, filter := range filters { ··· 448 idxs[did] = idx + 1 449 } 450 451 + return profileMap, nil 452 } 453 454 func GetProfile(e Execer, did string) (*Profile, error) {
+2 -6
appview/db/timeline.go
··· 151 return nil, nil 152 } 153 154 - profileMap := make(map[string]Profile) 155 profiles, err := GetProfiles(e, FilterIn("did", subjects)) 156 if err != nil { 157 return nil, err 158 } 159 - for _, p := range profiles { 160 - profileMap[p.Did] = p 161 - } 162 163 followStatMap := make(map[string]FollowStats) 164 for _, s := range subjects { ··· 174 175 var events []TimelineEvent 176 for _, f := range follows { 177 - profile, _ := profileMap[f.SubjectDid] 178 followStatMap, _ := followStatMap[f.SubjectDid] 179 180 events = append(events, TimelineEvent{ 181 Follow: &f, 182 - Profile: &profile, 183 FollowStats: &followStatMap, 184 EventAt: f.FollowedAt, 185 })
··· 151 return nil, nil 152 } 153 154 profiles, err := GetProfiles(e, FilterIn("did", subjects)) 155 if err != nil { 156 return nil, err 157 } 158 159 followStatMap := make(map[string]FollowStats) 160 for _, s := range subjects { ··· 170 171 var events []TimelineEvent 172 for _, f := range follows { 173 + profile, _ := profiles[f.SubjectDid] 174 followStatMap, _ := followStatMap[f.SubjectDid] 175 176 events = append(events, TimelineEvent{ 177 Follow: &f, 178 + Profile: profile, 179 FollowStats: &followStatMap, 180 EventAt: f.FollowedAt, 181 })

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