Monorepo for Tangled tangled.org
855
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview/state: fix pagination in vouches tab

Signed-off-by: oppiliappan <me@oppi.li>

+28 -2
+17
appview/db/vouch.go
··· 169 169 return err 170 170 } 171 171 172 + func CountNetworkVouchTimeline(e Execer, viewerDid, profileDid string) (int, error) { 173 + var count int 174 + err := e.QueryRow( 175 + `select count(*) from ( 176 + select v.id from vouches v 177 + where ( 178 + v.subject_did = ? and v.did in (select subject_did from vouches where did = ? and kind = 'vouch') 179 + ) or ( 180 + v.did = ? and v.subject_did in (select subject_did from vouches where did = ? and kind = 'vouch') 181 + ) 182 + group by v.did, v.subject_did 183 + )`, 184 + profileDid, viewerDid, profileDid, viewerDid, 185 + ).Scan(&count) 186 + return count, err 187 + } 188 + 172 189 func GetNetworkVouchTimeline(e Execer, viewerDid, profileDid string, page pagination.Page) ([]models.Vouch, error) { 173 190 pageClause := "" 174 191 if page.Limit > 0 {
+1
appview/pages/pages.go
··· 717 717 Suggestions []models.VouchSuggestion 718 718 Card *ProfileCard 719 719 Page pagination.Page 720 + VouchCount int 720 721 Active string 721 722 EvidencePulls map[syntax.ATURI]*models.Pull 722 723 EvidenceIssues map[syntax.ATURI]*models.Issue
+2 -2
appview/pages/templates/user/vouches.html
··· 5 5 <div id="all-vouches" class="md:col-span-8 order-2 md:order-2 flex flex-col gap-6"> 6 6 {{ if $isSelf }}{{ template "vouchSuggestions" . }}{{ end }} 7 7 {{ block "vouchTimeline" . }}{{ end }} 8 - {{ if ge (len .Vouches) .Page.Limit }} 8 + {{ if gt .VouchCount .Page.Limit }} 9 9 {{ $handle := resolve .Card.UserDid }} 10 10 {{ template "fragments/pagination" (dict 11 11 "Page" .Page 12 - "TotalCount" (add (len .Vouches) .Page.Offset) 12 + "TotalCount" .VouchCount 13 13 "BasePath" (printf "/%s" $handle) 14 14 "QueryParams" (queryParams "tab" "vouches") 15 15 ) }}
+8
appview/state/profile.go
··· 406 406 page := pagination.FromContext(r.Context()) 407 407 408 408 var vouches []models.Vouch 409 + var vouchCount int 409 410 if loggedInUser != nil { 410 411 vouches, err = db.GetNetworkVouchTimeline(s.db, loggedInUser.Did, profile.UserDid, page) 411 412 if err != nil { 412 413 l.Error("failed to get vouch timeline", "err", err) 414 + s.pages.Error500(w) 415 + return 416 + } 417 + vouchCount, err = db.CountNetworkVouchTimeline(s.db, loggedInUser.Did, profile.UserDid) 418 + if err != nil { 419 + l.Error("failed to count vouch timeline", "err", err) 413 420 s.pages.Error500(w) 414 421 return 415 422 } ··· 480 487 Suggestions: suggestions, 481 488 Card: profile, 482 489 Page: page, 490 + VouchCount: vouchCount, 483 491 EvidencePulls: evidencePulls, 484 492 EvidenceIssues: evidenceIssues, 485 493 })