Skip to content

Commit 754fdd8

Browse files
qwerty287lunny
andauthored
Fix visibility of org avatars (#17789)
* Fix visibility of org avatar * more clear syntax Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
1 parent 21f4401 commit 754fdd8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

modules/templates/helper.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -553,18 +553,24 @@ func SVG(icon string, others ...interface{}) template.HTML {
553553
func Avatar(item interface{}, others ...interface{}) template.HTML {
554554
size, class := parseOthers(avatars.DefaultAvatarPixelSize, "ui avatar image", others...)
555555

556-
if user, ok := item.(*models.User); ok {
557-
src := user.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
556+
switch t := item.(type) {
557+
case *models.User:
558+
src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
558559
if src != "" {
559-
return AvatarHTML(src, size, class, user.DisplayName())
560+
return AvatarHTML(src, size, class, t.DisplayName())
560561
}
561-
}
562-
if user, ok := item.(*models.Collaborator); ok {
563-
src := user.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
562+
case *models.Collaborator:
563+
src := t.AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
564+
if src != "" {
565+
return AvatarHTML(src, size, class, t.DisplayName())
566+
}
567+
case *models.Organization:
568+
src := t.AsUser().AvatarLinkWithSize(size * avatars.AvatarRenderedSizeFactor)
564569
if src != "" {
565-
return AvatarHTML(src, size, class, user.DisplayName())
570+
return AvatarHTML(src, size, class, t.AsUser().DisplayName())
566571
}
567572
}
573+
568574
return template.HTML("")
569575
}
570576

0 commit comments

Comments
 (0)