Monorepo for Tangled tangled.org

appview/{pages,db}: show follow/unfollow button on the timeline #553

merged opened by anirudh.fi targeting master from push-qrltzqmlrlln
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:hwevmowznbiukdf6uk5dwrrq/sh.tangled.repo.pull/3lxwlj7lerd22
+14 -10
Interdiff #0 โ†’ #1
+6 -2
appview/db/timeline.go
··· 19 19 *Profile 20 20 *FollowStats 21 21 *FollowStatus 22 + 23 + // optional: populate only if event is Repo 24 + IsStarred bool 25 + StarCount int64 22 26 } 23 27 24 28 // TODO: this gathers heterogenous events from different sources and aggregates ··· 161 165 followStatMap, _ := followStatMap[f.SubjectDid] 162 166 163 167 followStatus := IsNotFollowing 164 - if loggedInUserDid != "" { 165 - followStatus = GetFollowStatus(e, loggedInUserDid, f.SubjectDid) 168 + if followStatuses != nil { 169 + followStatus = followStatuses[f.SubjectDid] 166 170 } 167 171 168 172 events = append(events, TimelineEvent{
appview/pages/templates/timeline/fragments/timeline.html

This file has not been changed.

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

This file has not been changed.

+8 -8
appview/state/state.go
··· 203 203 func (s *State) Timeline(w http.ResponseWriter, r *http.Request) { 204 204 user := s.oauth.GetUser(r) 205 205 206 - var userDid string 207 - if user != nil { 208 - userDid = user.Did 209 - } 210 - timeline, err := db.MakeTimeline(s.db, 50, userDid) 206 + timeline, err := db.MakeTimeline(s.db, 50) 211 207 if err != nil { 212 208 log.Println(err) 213 209 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 215 211 func (s *State) Timeline(w http.ResponseWriter, r *http.Request) { 216 212 user := s.oauth.GetUser(r) 217 213 218 - timeline, err := db.MakeTimeline(s.db, 50) 214 + var userDid string 215 + if user != nil { 216 + userDid = user.Did 217 + } 218 + timeline, err := db.MakeTimeline(s.db, 50, userDid) 219 219 if err != nil { 220 220 log.Println(err) 221 221 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 228 228 } 229 229 230 230 func (s *State) Home(w http.ResponseWriter, r *http.Request) { 231 - timeline, err := db.MakeTimeline(s.db, 15, "") 231 + timeline, err := db.MakeTimeline(s.db, 15) 232 232 if err != nil { 233 233 log.Println(err) 234 234 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 270 270 } 271 271 272 272 func (s *State) Home(w http.ResponseWriter, r *http.Request) { 273 - timeline, err := db.MakeTimeline(s.db, 5) 273 + timeline, err := db.MakeTimeline(s.db, 5, "") 274 274 if err != nil { 275 275 log.Println(err) 276 276 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.")

History

2 rounds 1 comment
sign up or login to add to the discussion
1 commit
expand
appview/{pages,db}: show follow/unfollow button on the timeline
expand 0 comments
pull request successfully merged
1 commit
expand
appview/{pages,db}: show follow/unfollow button on the timeline
expand 1 comment

GetFollowStatus here is an N+1 query. it is run N times for each follows. we should add a db helper to get follow status in bulk and use that instead.