Fix edited message in threads
This commit is contained in:
parent
240deb0607
commit
3e7ef4859c
@ -16,6 +16,7 @@ func CreateDebugComponent(inputHeight int) *Debug {
|
||||
|
||||
debug.List.BorderLabel = "Debug"
|
||||
debug.List.Height = termui.TermHeight() - inputHeight
|
||||
debug.List.Overflow = "wrap"
|
||||
|
||||
return debug
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ func messageHandler(ctx *context.AppContext) {
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case msg := <-ctx.Service.RTM.IncomingEvents:
|
||||
switch ev := msg.Data.(type) {
|
||||
case rtmEvent := <-ctx.Service.RTM.IncomingEvents:
|
||||
switch ev := rtmEvent.Data.(type) {
|
||||
case *slack.MessageEvent:
|
||||
|
||||
// Construct message
|
||||
@ -132,11 +132,26 @@ func messageHandler(ctx *context.AppContext) {
|
||||
// Add message to the selected channel
|
||||
if ev.Channel == ctx.View.Channels.ChannelItems[ctx.View.Channels.SelectedChannel].ID {
|
||||
|
||||
// Get the thread timestamp of the event, we need to
|
||||
// check the previous message as well, because edited
|
||||
// message don't have the thread timestamp
|
||||
var threadTimestamp string
|
||||
if ev.ThreadTimestamp != "" {
|
||||
threadTimestamp = ev.ThreadTimestamp
|
||||
} else if ev.PreviousMessage.ThreadTimestamp != "" {
|
||||
threadTimestamp = ev.PreviousMessage.ThreadTimestamp
|
||||
} else {
|
||||
threadTimestamp = ""
|
||||
}
|
||||
|
||||
// When timestamp isn't set this is a thread reply,
|
||||
// handle as such
|
||||
if ev.ThreadTimestamp != "" {
|
||||
ctx.View.Chat.AddReply(ev.ThreadTimestamp, msg)
|
||||
} else if ev.ThreadTimestamp == "" && ctx.Focus == context.ChatFocus {
|
||||
if threadTimestamp != "" {
|
||||
ctx.View.Debug.Println(
|
||||
fmt.Sprint("here"),
|
||||
)
|
||||
ctx.View.Chat.AddReply(threadTimestamp, msg)
|
||||
} else if threadTimestamp == "" && ctx.Focus == context.ChatFocus {
|
||||
ctx.View.Chat.AddMessage(msg)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user