From 76cfbecc09ce527e9868840b27ac1068b010f824 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Fri, 23 Mar 2018 17:45:58 +0200 Subject: Remove panic when sending message if GetSessionOwner() returns nil --- ui/widget/room-view.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'ui') diff --git a/ui/widget/room-view.go b/ui/widget/room-view.go index 69216fb..2e82a2d 100644 --- a/ui/widget/room-view.go +++ b/ui/widget/room-view.go @@ -251,7 +251,10 @@ func (view *RoomView) NewMessage(id, sender, msgtype, text string, timestamp tim func (view *RoomView) NewTempMessage(msgtype, text string) *types.Message { now := time.Now() id := strconv.FormatInt(now.UnixNano(), 10) - sender := view.Room.GetSessionOwner().DisplayName + sender := "" + if ownerMember := view.Room.GetSessionOwner(); ownerMember != nil { + sender = ownerMember.DisplayName + } message := view.NewMessage(id, sender, msgtype, text, now) message.State = types.MessageStateSending view.AddMessage(message, AppendMessage) -- cgit v1.2.3