aboutsummaryrefslogtreecommitdiff
path: root/ui/widget
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-03-23 17:45:58 +0200
committerTulir Asokan <tulir@maunium.net>2018-03-23 17:45:58 +0200
commit76cfbecc09ce527e9868840b27ac1068b010f824 (patch)
tree65b8be55552ea60fef5c04794db00194c4a41bfe /ui/widget
parent7dc773c9907adac23540b8cb8c58cd68b60f9524 (diff)
Remove panic when sending message if GetSessionOwner() returns nil
Diffstat (limited to 'ui/widget')
-rw-r--r--ui/widget/room-view.go5
1 files changed, 4 insertions, 1 deletions
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)