Add channel name and topic as MessagesTextView title on channel select
This commit is contained in:
parent
e4d9332eff
commit
f9ed9a7a12
2 changed files with 10 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ package ui
|
|||
|
||||
import (
|
||||
"github.com/ayntgl/astatine"
|
||||
"github.com/ayntgl/discordo/discord"
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
|
|
@ -30,7 +31,8 @@ func (ctv *ChannelsTreeView) onSelected(n *tview.TreeNode) {
|
|||
ctv.app.SelectedMessage = -1
|
||||
ctv.app.MessagesTextView.
|
||||
Highlight().
|
||||
Clear()
|
||||
Clear().
|
||||
SetTitle("")
|
||||
ctv.app.MessageInputField.SetText("")
|
||||
|
||||
c, err := ctv.app.Session.State.Channel(n.GetReference().(string))
|
||||
|
|
@ -46,6 +48,12 @@ func (ctv *ChannelsTreeView) onSelected(n *tview.TreeNode) {
|
|||
ctv.app.SelectedChannel = c
|
||||
ctv.app.SetFocus(ctv.app.MessageInputField)
|
||||
|
||||
title := discord.ChannelToString(c)
|
||||
if c.Topic != "" {
|
||||
title += " - " + discord.ParseMarkdown(c.Topic)
|
||||
}
|
||||
ctv.app.MessagesTextView.SetTitle(title)
|
||||
|
||||
go func() {
|
||||
ms, err := ctv.app.Session.ChannelMessages(c.ID, ctv.app.Config.General.FetchMessagesLimit, "", "", "")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ func NewMessagesTextView(app *App) *MessagesTextView {
|
|||
mtv.SetChangedFunc(func() {
|
||||
mtv.app.Draw()
|
||||
})
|
||||
mtv.SetTitleAlign(tview.AlignLeft)
|
||||
mtv.SetBorder(true)
|
||||
mtv.SetBorderPadding(0, 0, 1, 1)
|
||||
mtv.SetInputCapture(mtv.onInputCapture)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue