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:
parent
66b81b765d
commit
5ed32db323
4 changed files with 13 additions and 4 deletions
|
|
@ -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(" - ")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue