It compiles. Ship it!

This commit is contained in:
Tulir Asokan
2019-04-10 01:04:39 +03:00
parent dbee49476d
commit bbde121947
11 changed files with 113 additions and 152 deletions

View File

@ -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
}

View File

@ -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

View File

@ -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 {

View File

@ -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
}