Update handling thread replies in event handler
This commit is contained in:
parent
d7a3dc7a8c
commit
c1365afd4e
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user