Kaynağa Gözat

Show the username as a fallback on feeds if full name is blank (#10461)

Co-authored-by: Lauris BH <lauris@nix.lv>
tags/v1.11.2
James Lakin 4 yıl önce
ebeveyn
işleme
7bf5834f2c
No account linked to committer's email address
2 değiştirilmiş dosya ile 10 ekleme ve 5 silme
  1. 5
    2
      models/action.go
  2. 5
    3
      models/user.go

+ 5
- 2
models/action.go Dosyayı Görüntüle

@@ -122,10 +122,13 @@ func (a *Action) ShortActUserName() string {
return base.EllipsisString(a.GetActUserName(), 20)
}

// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME
// GetDisplayName gets the action's display name based on DEFAULT_SHOW_FULL_NAME, or falls back to the username if it is blank.
func (a *Action) GetDisplayName() string {
if setting.UI.DefaultShowFullName {
return a.GetActFullName()
trimmedFullName := strings.TrimSpace(a.GetActFullName())
if len(trimmedFullName) > 0 {
return trimmedFullName
}
}
return a.ShortActUserName()
}

+ 5
- 3
models/user.go Dosyayı Görüntüle

@@ -712,9 +712,11 @@ func (u *User) DisplayName() string {
// GetDisplayName returns full name if it's not empty and DEFAULT_SHOW_FULL_NAME is set,
// returns username otherwise.
func (u *User) GetDisplayName() string {
trimmed := strings.TrimSpace(u.FullName)
if len(trimmed) > 0 && setting.UI.DefaultShowFullName {
return trimmed
if setting.UI.DefaultShowFullName {
trimmed := strings.TrimSpace(u.FullName)
if len(trimmed) > 0 {
return trimmed
}
}
return u.Name
}

Loading…
İptal
Kaydet