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 *Profile 20 *FollowStats 21 *FollowStatus 22 } 23 24 // TODO: this gathers heterogenous events from different sources and aggregates ··· 161 followStatMap, _ := followStatMap[f.SubjectDid] 162 163 followStatus := IsNotFollowing 164 - if loggedInUserDid != "" { 165 - followStatus = GetFollowStatus(e, loggedInUserDid, f.SubjectDid) 166 } 167 168 events = append(events, TimelineEvent{
··· 19 *Profile 20 *FollowStats 21 *FollowStatus 22 + 23 + // optional: populate only if event is Repo 24 + IsStarred bool 25 + StarCount int64 26 } 27 28 // TODO: this gathers heterogenous events from different sources and aggregates ··· 165 followStatMap, _ := followStatMap[f.SubjectDid] 166 167 followStatus := IsNotFollowing 168 + if followStatuses != nil { 169 + followStatus = followStatuses[f.SubjectDid] 170 } 171 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 func (s *State) Timeline(w http.ResponseWriter, r *http.Request) { 204 user := s.oauth.GetUser(r) 205 206 - var userDid string 207 - if user != nil { 208 - userDid = user.Did 209 - } 210 - timeline, err := db.MakeTimeline(s.db, 50, userDid) 211 if err != nil { 212 log.Println(err) 213 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 215 func (s *State) Timeline(w http.ResponseWriter, r *http.Request) { 216 user := s.oauth.GetUser(r) 217 218 - timeline, err := db.MakeTimeline(s.db, 50) 219 if err != nil { 220 log.Println(err) 221 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 228 } 229 230 func (s *State) Home(w http.ResponseWriter, r *http.Request) { 231 - timeline, err := db.MakeTimeline(s.db, 15, "") 232 if err != nil { 233 log.Println(err) 234 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 270 } 271 272 func (s *State) Home(w http.ResponseWriter, r *http.Request) { 273 - timeline, err := db.MakeTimeline(s.db, 5) 274 if err != nil { 275 log.Println(err) 276 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.")
··· 203 func (s *State) Timeline(w http.ResponseWriter, r *http.Request) { 204 user := s.oauth.GetUser(r) 205 206 + timeline, err := db.MakeTimeline(s.db, 50) 207 if err != nil { 208 log.Println(err) 209 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 211 func (s *State) Timeline(w http.ResponseWriter, r *http.Request) { 212 user := s.oauth.GetUser(r) 213 214 + var userDid string 215 + if user != nil { 216 + userDid = user.Did 217 + } 218 + timeline, err := db.MakeTimeline(s.db, 50, userDid) 219 if err != nil { 220 log.Println(err) 221 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 228 } 229 230 func (s *State) Home(w http.ResponseWriter, r *http.Request) { 231 + timeline, err := db.MakeTimeline(s.db, 15) 232 if err != nil { 233 log.Println(err) 234 s.pages.Notice(w, "timeline", "Uh oh! Failed to load timeline.") ··· 270 } 271 272 func (s *State) Home(w http.ResponseWriter, r *http.Request) { 273 + timeline, err := db.MakeTimeline(s.db, 5, "") 274 if err != nil { 275 log.Println(err) 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.