feat(ui/chat): display friend's nickname in DM node (#757)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ken Perkins 2026-02-28 22:29:20 -08:00 • committed by GitHub
parent 66b81b765d
commit 5ed32db323
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 13 additions and 4 deletions

View file

@ -115,7 +115,7 @@ func (cp *channelsPicker) update() {
func (cp *channelsPicker) addChannel(guild *discord.Guild, channel discord.Channel) {
var b strings.Builder
b.WriteString(ui.ChannelToString(channel, cp.chatView.cfg.Icons))
b.WriteString(ui.ChannelToString(channel, cp.chatView.cfg.Icons, cp.chatView.state))
if guild != nil {
b.WriteString(" - ")

View file

@ -204,7 +204,7 @@ func (gt *guildsTree) createChannelNode(node *tview.TreeNode, channel discord.Ch
return
}
channelNode := tview.NewTreeNode(ui.ChannelToString(channel, gt.cfg.Icons)).SetReference(channel.ID)
channelNode := tview.NewTreeNode(ui.ChannelToString(channel, gt.cfg.Icons, gt.chatView.state)).SetReference(channel.ID)
if channel.Type == discord.GuildForum {
channelNode.SetExpandable(true).SetExpanded(false)
}

View file

@ -112,7 +112,7 @@ func (ml *messagesList) reset() {
}
func (ml *messagesList) setTitle(channel discord.Channel) {
title := ui.ChannelToString(channel, ml.cfg.Icons)
title := ui.ChannelToString(channel, ml.cfg.Icons, ml.chatView.state)
if topic := channel.Topic; topic != "" {
title += " - " + topic
}

View file

@ -8,6 +8,7 @@ import (
"github.com/ayn2op/discordo/internal/config"
"github.com/ayn2op/tview"
"github.com/diamondburned/arikawa/v3/discord"
"github.com/diamondburned/ningen/v3"
"github.com/gdamore/tcell/v3"
)
@ -61,7 +62,7 @@ func Centered(p tview.Primitive, width, height int) tview.Primitive {
AddItem(p, 1, 1, 1, 1, 0, 0, true)
}
func ChannelToString(channel discord.Channel, icons config.Icons) string {
func ChannelToString(channel discord.Channel, icons config.Icons, state *ningen.State) string {
var icon string
switch channel.Type {
case discord.DirectMessage, discord.GroupDM:
@ -71,6 +72,14 @@ func ChannelToString(channel discord.Channel, icons config.Icons) string {
recipients := make([]string, len(channel.DMRecipients))
for i, r := range channel.DMRecipients {
if state != nil && channel.Type == discord.DirectMessage {
if rel, ok := state.RelationshipState.FullRelationship(r.ID); ok && rel.Type == discord.FriendRelationship {
if rel.Nickname != nil && *rel.Nickname != "" {
recipients[i] = *rel.Nickname
continue
}
}
}
recipients[i] = r.DisplayOrUsername()
}