Skip to content

Commit 97ab820

Browse files
silverwind6543
andauthored
Fix action avatar loading (#13909)
Fixes #13883 Co-authored-by: 6543 <[email protected]>
1 parent 10b9a6d commit 97ab820

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

models/action.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ func (a *Action) GetOpType() ActionType {
7777
return a.OpType
7878
}
7979

80-
func (a *Action) loadActUser() {
80+
// LoadActUser loads a.ActUser
81+
func (a *Action) LoadActUser() {
8182
if a.ActUser != nil {
8283
return
8384
}
@@ -105,13 +106,13 @@ func (a *Action) loadRepo() {
105106

106107
// GetActFullName gets the action's user full name.
107108
func (a *Action) GetActFullName() string {
108-
a.loadActUser()
109+
a.LoadActUser()
109110
return a.ActUser.FullName
110111
}
111112

112113
// GetActUserName gets the action's user name.
113114
func (a *Action) GetActUserName() string {
114-
a.loadActUser()
115+
a.LoadActUser()
115116
return a.ActUser.Name
116117
}
117118

modules/templates/helper.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,12 @@ func NewFuncMap() []template.FuncMap {
338338
}
339339
return false
340340
},
341-
"svg": SVG,
342-
"avatar": Avatar,
343-
"avatarHTML": AvatarHTML,
344-
"avatarByEmail": AvatarByEmail,
345-
"repoAvatar": RepoAvatar,
341+
"svg": SVG,
342+
"avatar": Avatar,
343+
"avatarHTML": AvatarHTML,
344+
"avatarByAction": AvatarByAction,
345+
"avatarByEmail": AvatarByEmail,
346+
"repoAvatar": RepoAvatar,
346347
"SortArrow": func(normSort, revSort, urlSort string, isDefault bool) template.HTML {
347348
// if needed
348349
if len(normSort) == 0 || len(urlSort) == 0 {
@@ -559,6 +560,12 @@ func Avatar(user *models.User, others ...interface{}) template.HTML {
559560
return template.HTML("")
560561
}
561562

563+
// AvatarByAction renders user avatars from action. args: action, size (int), class (string)
564+
func AvatarByAction(action *models.Action, others ...interface{}) template.HTML {
565+
action.LoadActUser()
566+
return Avatar(action.ActUser, others...)
567+
}
568+
562569
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
563570
func RepoAvatar(repo *models.Repository, others ...interface{}) template.HTML {
564571
size, class := parseOthers(models.DefaultAvatarPixelSize, "ui avatar image", others...)

templates/user/dashboard/feeds.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{range .Feeds}}
22
<div class="news">
33
<div class="ui left">
4-
{{avatar .ActUser}}
4+
{{avatarByAction .}}
55
</div>
66
<div class="ui grid">
77
<div class="ui fourteen wide column">

0 commit comments

Comments
 (0)