revert mentions for chat preview
This commit is contained in:
parent
c3ced09839
commit
d90fe86a61
|
@ -2,6 +2,7 @@ package protocol
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/rand"
|
||||
|
||||
|
@ -155,6 +156,9 @@ type ChatPreview struct {
|
|||
// SyncedFrom is the time from when it was synced with a mailserver
|
||||
SyncedFrom uint32 `json:"syncedFrom,omitempty"`
|
||||
|
||||
// ParsedText is the parsed markdown for displaying
|
||||
ParsedText json.RawMessage `json:"parsedText,omitempty"`
|
||||
|
||||
Text string `json:"text,omitempty"`
|
||||
|
||||
ContentType protobuf.ChatMessage_ContentType `json:"contentType,omitempty"`
|
||||
|
|
|
@ -8,6 +8,8 @@ import (
|
|||
"github.com/status-im/status-go/protocol/protobuf"
|
||||
"github.com/status-im/status-go/protocol/requests"
|
||||
"github.com/status-im/status-go/protocol/transport"
|
||||
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (m *Messenger) Chats() []*Chat {
|
||||
|
@ -52,10 +54,19 @@ func (m *Messenger) ChatsPreview() []*ChatPreview {
|
|||
if chat.LastMessage != nil {
|
||||
chatPreview.ContentType = chat.LastMessage.ContentType
|
||||
if chat.LastMessage.ContentType == protobuf.ChatMessage_TEXT_PLAIN {
|
||||
if len(chat.LastMessage.Text) > 200 {
|
||||
chatPreview.Text = chat.LastMessage.Text[:200]
|
||||
|
||||
simplifiedText, err := chat.LastMessage.GetSimplifiedText("", nil)
|
||||
|
||||
if err == nil {
|
||||
if len(simplifiedText) > 100 {
|
||||
chatPreview.Text = simplifiedText[:100]
|
||||
} else {
|
||||
chatPreview.Text = chat.LastMessage.Text
|
||||
chatPreview.Text = simplifiedText
|
||||
}
|
||||
if strings.Contains(chatPreview.Text, "0x") {
|
||||
//if there is a mention, we would like to send parsed text as well
|
||||
chatPreview.ParsedText = chat.LastMessage.ParsedText
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue