parent
e85d6b5ec1
commit
156128a127
@ -19,7 +19,7 @@ type Chat struct {
|
||||
}
|
||||
|
||||
// CreateChat is the constructor for the Chat struct
|
||||
func CreateChat(svc *service.SlackService, inputHeight int, selectedChannel interface{}, selectedChannelName string) *Chat {
|
||||
func CreateChat(svc *service.SlackService, inputHeight int, selectedSlackChannel interface{}, selectedChannel service.Channel) *Chat {
|
||||
chat := &Chat{
|
||||
List: termui.NewList(),
|
||||
Offset: 0,
|
||||
@ -28,8 +28,8 @@ func CreateChat(svc *service.SlackService, inputHeight int, selectedChannel inte
|
||||
chat.List.Height = termui.TermHeight() - inputHeight
|
||||
chat.List.Overflow = "wrap"
|
||||
|
||||
chat.GetMessages(svc, selectedChannel)
|
||||
chat.SetBorderLabel(selectedChannelName)
|
||||
chat.GetMessages(svc, selectedSlackChannel)
|
||||
chat.SetBorderLabel(selectedChannel)
|
||||
|
||||
return chat
|
||||
}
|
||||
@ -208,8 +208,17 @@ func (c *Chat) ScrollDown() {
|
||||
}
|
||||
|
||||
// SetBorderLabel will set Label of the Chat pane to the specified string
|
||||
func (c *Chat) SetBorderLabel(label string) {
|
||||
c.List.BorderLabel = label
|
||||
func (c *Chat) SetBorderLabel(channel service.Channel) {
|
||||
var channelName string
|
||||
if channel.Topic != "" {
|
||||
channelName = fmt.Sprintf("%s - %s",
|
||||
channel.Name,
|
||||
channel.Topic,
|
||||
)
|
||||
} else {
|
||||
channelName = channel.Name
|
||||
}
|
||||
c.List.BorderLabel = channelName
|
||||
}
|
||||
|
||||
// Help shows the usage and key bindings in the chat pane
|
||||
|
@ -251,7 +251,7 @@ func actionChangeChannel(ctx *context.AppContext) {
|
||||
|
||||
// Set channel name for the Chat pane
|
||||
ctx.View.Chat.SetBorderLabel(
|
||||
ctx.Service.Channels[ctx.View.Channels.SelectedChannel].Name,
|
||||
ctx.Service.Channels[ctx.View.Channels.SelectedChannel],
|
||||
)
|
||||
|
||||
// Set read mark
|
||||
|
@ -19,8 +19,9 @@ type SlackService struct {
|
||||
}
|
||||
|
||||
type Channel struct {
|
||||
ID string
|
||||
Name string
|
||||
ID string
|
||||
Name string
|
||||
Topic string
|
||||
}
|
||||
|
||||
// NewSlackService is the constructor for the SlackService and will initialize
|
||||
@ -71,7 +72,7 @@ func (s *SlackService) GetChannels() []Channel {
|
||||
}
|
||||
for _, chn := range slackChans {
|
||||
s.SlackChannels = append(s.SlackChannels, chn)
|
||||
chans = append(chans, Channel{chn.ID, chn.Name})
|
||||
chans = append(chans, Channel{chn.ID, chn.Name, chn.Topic.Value})
|
||||
}
|
||||
|
||||
// Groups
|
||||
@ -81,7 +82,7 @@ func (s *SlackService) GetChannels() []Channel {
|
||||
}
|
||||
for _, grp := range slackGroups {
|
||||
s.SlackChannels = append(s.SlackChannels, grp)
|
||||
chans = append(chans, Channel{grp.ID, grp.Name})
|
||||
chans = append(chans, Channel{grp.ID, grp.Name, grp.Topic.Value})
|
||||
}
|
||||
|
||||
// IM
|
||||
@ -97,7 +98,7 @@ func (s *SlackService) GetChannels() []Channel {
|
||||
// to the UserCache, so we skip it
|
||||
name, ok := s.UserCache[im.User]
|
||||
if ok {
|
||||
chans = append(chans, Channel{im.ID, name})
|
||||
chans = append(chans, Channel{im.ID, name, ""})
|
||||
s.SlackChannels = append(s.SlackChannels, im)
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func CreateChatView(svc *service.SlackService) *View {
|
||||
svc,
|
||||
input.Par.Height,
|
||||
svc.SlackChannels[channels.SelectedChannel],
|
||||
svc.Channels[channels.SelectedChannel].Name,
|
||||
svc.Channels[channels.SelectedChannel],
|
||||
)
|
||||
|
||||
mode := components.CreateMode()
|
||||
|
Loading…
Reference in New Issue
Block a user