Update handling thread replies in event handler

This commit is contained in:
erroneousboat 2018-12-25 15:56:27 +01:00
parent d7a3dc7a8c
commit c1365afd4e
3 changed files with 10 additions and 2 deletions

View File

@ -182,6 +182,10 @@ func (c *Chat) AddMessage(message Message) {
c.Messages[message.ID] = message
}
func (c *Chat) AddReply(parentID string, message Message) {
c.Messages[parentID].Messages[message.ID] = message
}
// ClearMessages clear the c.Messages
func (c *Chat) ClearMessages() {
c.Messages = make(map[string]Message)

View File

@ -121,7 +121,12 @@ func messageHandler(ctx *context.AppContext) {
// Add message to the selected channel
if ev.Channel == ctx.View.Channels.ChannelItems[ctx.View.Channels.SelectedChannel].ID {
ctx.View.Chat.AddMessage(msg)
if ev.ThreadTimestamp != "" {
ctx.View.Chat.AddReply(ev.ThreadTimestamp, msg)
} else {
ctx.View.Chat.AddMessage(msg)
}
termui.Render(ctx.View.Chat)
// TODO: set Chat.Offset to 0, to automatically scroll

View File

@ -457,7 +457,6 @@ func (s *SlackService) CreateMessageFromMessageEvent(message *slack.MessageEvent
msg = slack.Message{Msg: *message.SubMessage}
msg.Text = fmt.Sprintf("%s (edited)", msg.Text)
case "message_replied":
// Ignore reply events
return components.Message{}, errors.New("ignoring reply events")
}