Monorepo for Tangled
0
fork

Configure Feed

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

Merge remote-tracking branch 'upstream/master'

+37 -35
+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 })
+9 -33
hook/setup.go
··· 48 48 // 49 49 // directory structure is typically like so: 50 50 // 51 - // did:plc:foobar/repo1 52 - // did:plc:foobar/repo2 53 - // did:web:barbaz/repo1 51 + // did:plc:repo1 52 + // did:plc:repo2 53 + // did:web:repo1 54 54 func Setup(config config) error { 55 55 // iterate over all directories in current directory: 56 - userDirs, err := os.ReadDir(config.scanPath) 56 + repoDirs, err := os.ReadDir(config.scanPath) 57 57 if err != nil { 58 58 return err 59 59 } 60 60 61 - for _, user := range userDirs { 62 - if !user.IsDir() { 61 + for _, repo := range repoDirs { 62 + if !repo.IsDir() { 63 63 continue 64 64 } 65 65 66 - did := user.Name() 66 + did := repo.Name() 67 67 if !strings.HasPrefix(did, "did:") { 68 68 continue 69 69 } 70 70 71 71 userPath := filepath.Join(config.scanPath, did) 72 - if err := SetupUser(config, userPath); err != nil { 73 - return err 74 - } 75 - } 76 - 77 - return nil 78 - } 79 - 80 - // setup hooks in /scanpath/did:plc:user 81 - func SetupUser(config config, userPath string) error { 82 - repos, err := os.ReadDir(userPath) 83 - if err != nil { 84 - return err 85 - } 86 - 87 - for _, repo := range repos { 88 - if !repo.IsDir() { 89 - continue 90 - } 91 - 92 - path := filepath.Join(userPath, repo.Name()) 93 - if err := SetupRepo(config, path); err != nil { 94 - if errors.Is(err, ErrNoGitRepo) { 95 - continue 96 - } 72 + if err := SetupRepo(config, userPath); err != nil { 97 73 return err 98 74 } 99 75 } ··· 101 77 return nil 102 78 } 103 79 104 - // setup hook in /scanpath/did:plc:user/repo 80 + // setup hook in /scanpath/did:plc:repo 105 81 func SetupRepo(config config, path string) error { 106 82 if _, err := git.PlainOpen(path); err != nil { 107 83 return fmt.Errorf("%s: %w", path, ErrNoGitRepo)