fix(message_input): prevent resource leak in send() method (#662)
This commit is contained in:
parent
ffdd141f70
commit
f4a092bc24
1 changed files with 9 additions and 7 deletions
|
|
@ -156,6 +156,15 @@ func (mi *messageInput) send() {
|
|||
return
|
||||
}
|
||||
|
||||
// Close attached files on return
|
||||
defer func() {
|
||||
for _, file := range mi.sendMessageData.Files {
|
||||
if closer, ok := file.Reader.(io.Closer); ok {
|
||||
closer.Close()
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
text = processText(app.chatView.selectedChannel, []byte(text))
|
||||
|
||||
if mi.edit {
|
||||
|
|
@ -179,13 +188,6 @@ func (mi *messageInput) send() {
|
|||
}
|
||||
}
|
||||
|
||||
// Close the attached files after sending the message.
|
||||
for _, file := range mi.sendMessageData.Files {
|
||||
if closer, ok := file.Reader.(io.Closer); ok {
|
||||
closer.Close()
|
||||
}
|
||||
}
|
||||
|
||||
mi.reset()
|
||||
app.chatView.messagesList.Highlight()
|
||||
app.chatView.messagesList.ScrollToEnd()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue