feat: add placeholder text for message input widget (#618)
This commit is contained in:
parent
924658f0c7
commit
18e0378955
3 changed files with 16 additions and 4 deletions
|
|
@ -119,7 +119,9 @@ func (a *application) onPagesInputCapture(event *tcell.EventKey) *tcell.EventKey
|
|||
a.SetFocus(a.messagesList)
|
||||
return nil
|
||||
case a.cfg.Keys.FocusMessageInput:
|
||||
a.SetFocus(a.messageInput)
|
||||
if !a.messageInput.GetDisabled() {
|
||||
a.SetFocus(a.messageInput)
|
||||
}
|
||||
return nil
|
||||
case a.cfg.Keys.FocusPrevious:
|
||||
a.focusPrevious()
|
||||
|
|
|
|||
|
|
@ -189,12 +189,17 @@ func (gt *guildsTree) onSelected(node *tview.TreeNode) {
|
|||
app.messagesList.drawMessages(messages)
|
||||
app.messagesList.ScrollToEnd()
|
||||
|
||||
hasPerm := channel.Type != discord.DirectMessage && channel.Type != discord.GroupDM && !discordState.HasPermissions(channel.ID, discord.PermissionSendMessages)
|
||||
app.messageInput.SetDisabled(hasPerm)
|
||||
hasNoPerm := channel.Type != discord.DirectMessage && channel.Type != discord.GroupDM && !discordState.HasPermissions(channel.ID, discord.PermissionSendMessages)
|
||||
app.messageInput.SetDisabled(hasNoPerm)
|
||||
if hasNoPerm {
|
||||
app.messageInput.SetPlaceholder("You do not have permission to send messages in this channel.")
|
||||
} else {
|
||||
app.messageInput.SetPlaceholder("Message...")
|
||||
app.SetFocus(app.messageInput)
|
||||
}
|
||||
|
||||
gt.selectedChannelID = channel.ID
|
||||
gt.selectedGuildID = channel.GuildID
|
||||
app.SetFocus(app.messageInput)
|
||||
case nil: // Direct messages
|
||||
channels, err := discordState.PrivateChannels()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -84,6 +84,11 @@ func newMessageInput(cfg *config.Config) *messageInput {
|
|||
b.BottomLeft, b.BottomRight = b.BottomT, b.BottomT
|
||||
mi.mentionsList.SetBorderSet(b)
|
||||
|
||||
mi.TextArea.
|
||||
SetPlaceholder("Select a channel to start chatting").
|
||||
SetPlaceholderStyle(tcell.StyleDefault.Dim(true)).
|
||||
SetDisabled(true)
|
||||
|
||||
return mi
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue