aboutsummaryrefslogtreecommitdiff
path: root/ui/messages
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2019-04-10 01:04:39 +0300
committerTulir Asokan <tulir@maunium.net>2019-04-10 01:04:39 +0300
commitbbde1219479bb257c7bc1f9546bd67e8a151198c (patch)
tree01ae23d19ed4ff44fa218633ae94511778c17ffa /ui/messages
parentdbee49476d47bb391dc6af0b774f9fd101b0c917 (diff)
It compiles. Ship it!
Diffstat (limited to 'ui/messages')
-rw-r--r--ui/messages/base.go15
-rw-r--r--ui/messages/message.go2
-rw-r--r--ui/messages/parser.go1
-rw-r--r--ui/messages/textmessage.go18
4 files changed, 22 insertions, 14 deletions
diff --git a/ui/messages/base.go b/ui/messages/base.go
index b8b1694..d9db866 100644
--- a/ui/messages/base.go
+++ b/ui/messages/base.go
@@ -192,6 +192,9 @@ func (msg *BaseMessage) FormatDate() string {
}
func (msg *BaseMessage) ID() string {
+ if len(msg.MsgID) == 0 {
+ return msg.MsgTxnID
+ }
return msg.MsgID
}
@@ -199,6 +202,10 @@ func (msg *BaseMessage) SetID(id string) {
msg.MsgID = id
}
+func (msg *BaseMessage) TxnID() string {
+ return msg.MsgTxnID
+}
+
func (msg *BaseMessage) Type() mautrix.MessageType {
return msg.MsgType
}
@@ -219,14 +226,6 @@ func (msg *BaseMessage) SetIsHighlight(isHighlight bool) {
msg.MsgIsHighlight = isHighlight
}
-func (msg *BaseMessage) IsService() bool {
- return msg.MsgIsService
-}
-
-func (msg *BaseMessage) SetIsService(isService bool) {
- msg.MsgIsService = isService
-}
-
func (msg *BaseMessage) Source() json.RawMessage {
return msg.MsgSource
}
diff --git a/ui/messages/message.go b/ui/messages/message.go
index 634bd11..bd78e5d 100644
--- a/ui/messages/message.go
+++ b/ui/messages/message.go
@@ -19,6 +19,7 @@ package messages
import (
"maunium.net/go/gomuks/config"
"maunium.net/go/gomuks/interface"
+ "maunium.net/go/mautrix"
"maunium.net/go/mauview"
"maunium.net/go/tcell"
)
@@ -27,6 +28,7 @@ import (
type UIMessage interface {
ifc.Message
+ Type() mautrix.MessageType
Sender() string
SenderColor() tcell.Color
TextColor() tcell.Color
diff --git a/ui/messages/parser.go b/ui/messages/parser.go
index f45eea2..7b76a69 100644
--- a/ui/messages/parser.go
+++ b/ui/messages/parser.go
@@ -29,7 +29,6 @@ import (
"maunium.net/go/gomuks/ui/messages/html"
"maunium.net/go/gomuks/ui/messages/tstring"
"maunium.net/go/gomuks/ui/widget"
- htmlp "maunium.net/go/gomuks/ui/messages/html"
)
func ParseEvent(matrix ifc.MatrixContainer, room *rooms.Room, evt *mautrix.Event) UIMessage {
diff --git a/ui/messages/textmessage.go b/ui/messages/textmessage.go
index f7c54ca..588dee4 100644
--- a/ui/messages/textmessage.go
+++ b/ui/messages/textmessage.go
@@ -18,6 +18,7 @@ package messages
import (
"fmt"
+ "time"
"maunium.net/go/mautrix"
@@ -39,6 +40,18 @@ func NewTextMessage(event *mautrix.Event, displayname string, text string) UIMes
}
}
+func NewServiceMessage(text string) UIMessage {
+ return &TextMessage{
+ BaseMessage: BaseMessage{
+ MsgSenderID: "*",
+ MsgSender: "*",
+ MsgTimestamp: time.Now(),
+ MsgIsService: true,
+ },
+ MsgText: text,
+ }
+}
+
func (msg *TextMessage) getCache() tstring.TString {
if msg.cache == nil {
switch msg.MsgType {
@@ -57,11 +70,6 @@ func (msg *TextMessage) SetIsHighlight(isHighlight bool) {
msg.cache = nil
}
-func (msg *TextMessage) SetIsService(isService bool) {
- msg.BaseMessage.SetIsService(isService)
- msg.cache = nil
-}
-
func (msg *TextMessage) NotificationContent() string {
return msg.MsgText
}