From 9ad3a95ba6cf1375745186d14e17b365205dc587 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 30 Apr 2018 22:35:52 +0300 Subject: Re-render UI after printing message send error --- ui/view-main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/view-main.go b/ui/view-main.go index 8d6941f..c5f1304 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -122,7 +122,14 @@ func (view *MainView) sendTempMessage(roomView *RoomView, tempMessage ifc.Messag eventID, err := view.matrix.SendMarkdownMessage(roomView.Room.ID, tempMessage.Type(), text) if err != nil { tempMessage.SetState(ifc.MessageStateFailed) + if httpErr, ok := err.(gomatrix.HTTPError); ok { + if respErr, ok := httpErr.WrappedError.(gomatrix.RespError); ok { + // Show shorter version if available + err = respErr + } + } roomView.AddServiceMessage(fmt.Sprintf("Failed to send message: %v", err)) + view.parent.Render() } else { roomView.MessageView().UpdateMessageID(tempMessage, eventID) } -- cgit v1.2.3