Skip to content

Commit 24f100d

Browse files
committed
Fix action avatar loading
Fixes: go-gitea#13883
1 parent 1a372e5 commit 24f100d

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,11 @@ func NewFuncMap() []template.FuncMap {
338338
}
339339
return false
340340
},
341-
"svg": SVG,
342-
"avatar": Avatar,
343-
"avatarByEmail": AvatarByEmail,
344-
"repoAvatar": RepoAvatar,
341+
"svg": SVG,
342+
"avatar": Avatar,
343+
"avatarByAction": AvatarByAction,
344+
"avatarByEmail": AvatarByEmail,
345+
"repoAvatar": RepoAvatar,
345346
"SortArrow": func(normSort, revSort, urlSort string, isDefault bool) template.HTML {
346347
// if needed
347348
if len(normSort) == 0 || len(urlSort) == 0 {
@@ -557,6 +558,12 @@ func Avatar(user *models.User, others ...interface{}) template.HTML {
557558
return template.HTML("")
558559
}
559560

561+
// AvatarByAction renders user avatars from action. args: action, size (int), class (string)
562+
func AvatarByAction(action *models.Action, others ...interface{}) template.HTML {
563+
action.LoadActUser()
564+
return Avatar(action.ActUser, others...)
565+
}
566+
560567
// RepoAvatar renders repo avatars. args: repo, size(int), class (string)
561568
func RepoAvatar(repo *models.Repository, others ...interface{}) template.HTML {
562569
size, class := parseOthers(28, "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)