diff --git a/internal/ui/chat/channels_picker.go b/internal/ui/chat/channels_picker.go index ab38ef4..a0f8018 100644 --- a/internal/ui/chat/channels_picker.go +++ b/internal/ui/chat/channels_picker.go @@ -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(" - ") diff --git a/internal/ui/chat/guilds_tree.go b/internal/ui/chat/guilds_tree.go index 3f73945..6978fcb 100644 --- a/internal/ui/chat/guilds_tree.go +++ b/internal/ui/chat/guilds_tree.go @@ -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) } diff --git a/internal/ui/chat/messages_list.go b/internal/ui/chat/messages_list.go index aadcd48..4a2d07c 100644 --- a/internal/ui/chat/messages_list.go +++ b/internal/ui/chat/messages_list.go @@ -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 } diff --git a/internal/ui/util.go b/internal/ui/util.go index 102a805..56f05dd 100644 --- a/internal/ui/util.go +++ b/internal/ui/util.go @@ -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() }