diff --git a/appview/pages/pages.go b/appview/pages/pages.go index 322895a..d89add7 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -366,7 +366,7 @@ type RepoBlobParams struct { func (p *Pages) RepoBlob(w io.Writer, params RepoBlobParams) error { if params.Lines < 5000 { c := params.Contents - style := styles.Get("xcode") + style := styles.Get("bw") formatter := chromahtml.New( chromahtml.InlineCode(true), chromahtml.WithLineNumbers(true), diff --git a/appview/pages/templates/repo/blob.html b/appview/pages/templates/repo/blob.html index 8967635..e6c5095 100644 --- a/appview/pages/templates/repo/blob.html +++ b/appview/pages/templates/repo/blob.html @@ -22,7 +22,7 @@ {{ end }} {{ end }} -
{{- range .TextFragments -}}
- {{ .Comment }}
+ {{ .Header }}
{{- range .Lines -}}
{{- if eq .Op.String "+" -}}
diff --git a/appview/resolver.go b/appview/resolver.go
index 409d68b..a8119aa 100644
--- a/appview/resolver.go
+++ b/appview/resolver.go
@@ -2,6 +2,7 @@ package appview
import (
"context"
+ "sync"
"github.com/bluesky-social/indigo/atproto/identity"
"github.com/bluesky-social/indigo/atproto/syntax"
@@ -25,3 +26,34 @@ func (r *Resolver) ResolveIdent(ctx context.Context, arg string) (*identity.Iden
return r.directory.Lookup(ctx, *id)
}
+
+func (r *Resolver) ResolveIdents(ctx context.Context, idents []string) []*identity.Identity {
+ results := make([]*identity.Identity, len(idents))
+ var wg sync.WaitGroup
+
+ // Create a channel to handle context cancellation
+ done := make(chan struct{})
+ defer close(done)
+
+ // Start a goroutine for each identifier
+ for idx, ident := range idents {
+ wg.Add(1)
+ go func(index int, id string) {
+ defer wg.Done()
+
+ select {
+ case <-ctx.Done():
+ results[index] = nil
+ case <-done:
+ results[index] = nil
+ default:
+ // Resolve the identifier - if error, identity will be nil
+ identity, _ := r.ResolveIdent(ctx, id)
+ results[index] = identity
+ }
+ }(idx, ident)
+ }
+
+ wg.Wait()
+ return results
+}
diff --git a/appview/state/repo.go b/appview/state/repo.go
index a798ed3..ad03dbe 100644
--- a/appview/state/repo.go
+++ b/appview/state/repo.go
@@ -480,22 +480,27 @@ func (f *FullyResolvedRepo) Collaborators(ctx context.Context, s *State) ([]page
did := item[0]
- var handle string
- id, err := s.resolver.ResolveIdent(ctx, did)
- if err != nil {
- handle = ""
- } else {
- handle = string(id.Handle)
- }
-
c := pages.Collaborator{
Did: did,
- Handle: handle,
+ Handle: "",
Role: role,
}
collaborators = append(collaborators, c)
}
+ // populate all collborators with handles
+ identsToResolve := make([]string, len(collaborators))
+ for i, collab := range collaborators {
+ identsToResolve[i] = collab.Did
+ }
+
+ resolvedIdents := s.resolver.ResolveIdents(ctx, identsToResolve)
+ for i, resolved := range resolvedIdents {
+ if resolved != nil {
+ collaborators[i].Handle = resolved.Handle.String()
+ }
+ }
+
return collaborators, nil
}
diff --git a/knotserver/git/diff.go b/knotserver/git/diff.go
index aebb7e0..415c771 100644
--- a/knotserver/git/diff.go
+++ b/knotserver/git/diff.go
@@ -66,8 +66,8 @@ func (g *GitRepo) Diff() (*types.NiceDiff, error) {
for _, tf := range d.TextFragments {
ndiff.TextFragments = append(ndiff.TextFragments, types.TextFragment{
- Comment: tf.Comment,
- Lines: tf.Lines,
+ Header: tf.Header(),
+ Lines: tf.Lines,
})
for _, l := range tf.Lines {
switch l.Op {
diff --git a/types/diff.go b/types/diff.go
index 75592fa..a17e569 100644
--- a/types/diff.go
+++ b/types/diff.go
@@ -6,8 +6,8 @@ import (
)
type TextFragment struct {
- Comment string `json:"comment"`
- Lines []gitdiff.Line `json:"lines"`
+ Header string `json:"comment"`
+ Lines []gitdiff.Line `json:"lines"`
}
type Diff struct {