tangled
alpha
login
or
join now
lewis.moe
/
tangled-core
0
fork
atom
Monorepo for Tangled
0
fork
atom
overview
issues
1
pulls
pipelines
appview/profile: show dummy profile when no tangled profile
lewis.moe
4 weeks ago
1cb98d85
0c73203f
+40
-6
6 changed files
expand all
collapse all
unified
split
appview
db
profile.go
oauth
handler.go
pages
pages.go
templates
layouts
profilebase.html
state
profile.go
state.go
+1
-3
appview/db/profile.go
···
360
did,
361
).Scan(&avatar, &profile.Description, &includeBluesky, &profile.Location, &pronouns)
362
if err == sql.ErrNoRows {
363
-
profile := models.Profile{}
364
-
profile.Did = did
365
-
return &profile, nil
366
}
367
368
if err != nil {
···
360
did,
361
).Scan(&avatar, &profile.Description, &includeBluesky, &profile.Location, &pronouns)
362
if err == sql.ErrNoRows {
363
+
return nil, nil
0
0
364
}
365
366
if err != nil {
+2
-2
appview/oauth/handler.go
···
199
did := sessData.AccountDID.String()
200
l := o.Logger.With("did", did)
201
202
-
_, err := db.GetProfile(o.Db, did)
203
-
if err == nil {
204
l.Debug("profile already exists in DB")
205
return
206
}
···
199
did := sessData.AccountDID.String()
200
l := o.Logger.With("did", did)
201
202
+
profile, _ := db.GetProfile(o.Db, did)
203
+
if profile != nil {
204
l.Debug("profile already exists in DB")
205
return
206
}
+1
appview/pages/pages.go
···
523
524
type ProfileCard struct {
525
UserDid string
0
526
FollowStatus models.FollowStatus
527
Punchcard *models.Punchcard
528
Profile *models.Profile
···
523
524
type ProfileCard struct {
525
UserDid string
526
+
HasProfile bool
527
FollowStatus models.FollowStatus
528
Punchcard *models.Punchcard
529
Profile *models.Profile
+13
appview/pages/templates/layouts/profilebase.html
···
18
{{ end }}
19
20
{{ define "content" }}
0
0
0
0
0
0
0
0
0
0
0
0
21
{{ template "profileTabs" . }}
22
<section class="bg-white dark:bg-gray-800 px-2 py-6 md:p-6 rounded w-full dark:text-white drop-shadow-sm">
23
<div class="grid grid-cols-1 md:grid-cols-11 gap-4">
···
35
{{ block "profileContent" . }} {{ end }}
36
</div>
37
</section>
0
38
{{ end }}
39
40
{{ define "profileTabs" }}
···
18
{{ end }}
19
20
{{ define "content" }}
21
+
{{ if not .Card.HasProfile }}
22
+
<section class="bg-white dark:bg-gray-800 px-2 py-6 md:p-6 rounded w-full dark:text-white drop-shadow-sm">
23
+
<div class="flex items-center gap-6 p-4">
24
+
<img class="w-28 h-28 shrink-0 object-cover rounded-full" src="{{ profileAvatarUrl .Card.Profile "" }}" />
25
+
<div>
26
+
<p class="text-lg font-bold">{{ resolve .Card.UserDid }}</p>
27
+
<p class="text-gray-700 dark:text-gray-300 mt-2">This user hasn't joined Tangled yet.</p>
28
+
<p class="text-sm text-gray-500 dark:text-gray-400 mt-1">Let them know we're waiting for them!</p>
29
+
</div>
30
+
</div>
31
+
</section>
32
+
{{ else }}
33
{{ template "profileTabs" . }}
34
<section class="bg-white dark:bg-gray-800 px-2 py-6 md:p-6 rounded w-full dark:text-white drop-shadow-sm">
35
<div class="grid grid-cols-1 md:grid-cols-11 gap-4">
···
47
{{ block "profileContent" . }} {{ end }}
48
</div>
49
</section>
50
+
{{ end }}
51
{{ end }}
52
53
{{ define "profileTabs" }}
+22
appview/state/profile.go
···
58
return nil, fmt.Errorf("failed to get profile: %w", err)
59
}
60
0
0
0
0
0
61
repoCount, err := db.CountRepos(s.db, orm.FilterEq("did", did))
62
if err != nil {
63
return nil, fmt.Errorf("failed to get repo count: %w", err)
···
98
99
return &pages.ProfileCard{
100
UserDid: did,
0
101
Profile: profile,
102
FollowStatus: followStatus,
103
Stats: pages.ProfileStats{
···
533
if err != nil {
534
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
535
}
0
0
0
536
537
profile.Description = r.FormValue("description")
538
profile.IncludeBluesky = r.FormValue("includeBluesky") == "on"
···
580
profile, err := db.GetProfile(s.db, user.Active.Did)
581
if err != nil {
582
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
0
0
0
583
}
584
585
i := 0
···
681
if err != nil {
682
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
683
}
0
0
0
684
685
s.pages.EditBioFragment(w, pages.EditBioParams{
686
LoggedInUser: user,
···
694
profile, err := db.GetProfile(s.db, user.Active.Did)
695
if err != nil {
696
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
0
0
0
697
}
698
699
repos, err := db.GetRepos(s.db, 0, orm.FilterEq("did", user.Active.Did))
···
821
profile, err := db.GetProfile(s.db, user.Did)
822
if err != nil {
823
l.Warn("getting profile data from DB", "err", err)
0
0
824
profile = &models.Profile{Did: user.Did}
825
}
826
profile.Avatar = uploadBlobResp.Blob.Ref.String()
···
897
profile, err := db.GetProfile(s.db, user.Did)
898
if err != nil {
899
l.Warn("getting profile data from DB", "err", err)
0
0
900
profile = &models.Profile{Did: user.Did}
901
}
902
profile.Avatar = ""
···
58
return nil, fmt.Errorf("failed to get profile: %w", err)
59
}
60
61
+
hasProfile := profile != nil
62
+
if !hasProfile {
63
+
profile = &models.Profile{Did: did}
64
+
}
65
+
66
repoCount, err := db.CountRepos(s.db, orm.FilterEq("did", did))
67
if err != nil {
68
return nil, fmt.Errorf("failed to get repo count: %w", err)
···
103
104
return &pages.ProfileCard{
105
UserDid: did,
106
+
HasProfile: hasProfile,
107
Profile: profile,
108
FollowStatus: followStatus,
109
Stats: pages.ProfileStats{
···
539
if err != nil {
540
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
541
}
542
+
if profile == nil {
543
+
profile = &models.Profile{Did: user.Active.Did}
544
+
}
545
546
profile.Description = r.FormValue("description")
547
profile.IncludeBluesky = r.FormValue("includeBluesky") == "on"
···
589
profile, err := db.GetProfile(s.db, user.Active.Did)
590
if err != nil {
591
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
592
+
}
593
+
if profile == nil {
594
+
profile = &models.Profile{Did: user.Active.Did}
595
}
596
597
i := 0
···
693
if err != nil {
694
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
695
}
696
+
if profile == nil {
697
+
profile = &models.Profile{Did: user.Active.Did}
698
+
}
699
700
s.pages.EditBioFragment(w, pages.EditBioParams{
701
LoggedInUser: user,
···
709
profile, err := db.GetProfile(s.db, user.Active.Did)
710
if err != nil {
711
log.Printf("getting profile data for %s: %s", user.Active.Did, err)
712
+
}
713
+
if profile == nil {
714
+
profile = &models.Profile{Did: user.Active.Did}
715
}
716
717
repos, err := db.GetRepos(s.db, 0, orm.FilterEq("did", user.Active.Did))
···
839
profile, err := db.GetProfile(s.db, user.Did)
840
if err != nil {
841
l.Warn("getting profile data from DB", "err", err)
842
+
}
843
+
if profile == nil {
844
profile = &models.Profile{Did: user.Did}
845
}
846
profile.Avatar = uploadBlobResp.Blob.Ref.String()
···
917
profile, err := db.GetProfile(s.db, user.Did)
918
if err != nil {
919
l.Warn("getting profile data from DB", "err", err)
920
+
}
921
+
if profile == nil {
922
profile = &models.Profile{Did: user.Did}
923
}
924
profile.Avatar = ""
+1
-1
appview/state/state.go
···
126
wrapper,
127
false,
128
129
-
// in-memory filter is inapplicalble to appview so
130
// we'll never log dids anyway.
131
false,
132
)
···
126
wrapper,
127
false,
128
129
+
// in-memory filter is inapplicable to appview so
130
// we'll never log dids anyway.
131
false,
132
)