mirror of
https://github.com/status-im/status-go.git
synced 2025-02-18 01:37:22 +00:00
Add New
flag to a received message
This change allows to count unviewed messages properly on the client side when replied message is attached to reply before being passed.
This commit is contained in:
parent
f10e70ce96
commit
4026841dc1
@ -117,7 +117,9 @@ type Message struct {
|
|||||||
|
|
||||||
// Replace indicates that this is a replacement of a message
|
// Replace indicates that this is a replacement of a message
|
||||||
// that has been updated
|
// that has been updated
|
||||||
Replace string `json:"replace,omitempty"`
|
Replace string `json:"replace,omitempty"`
|
||||||
|
New bool `json:"new,omitempty"`
|
||||||
|
|
||||||
SigPubKey *ecdsa.PublicKey `json:"-"`
|
SigPubKey *ecdsa.PublicKey `json:"-"`
|
||||||
|
|
||||||
// Mentions is an array of mentions for a given message
|
// Mentions is an array of mentions for a given message
|
||||||
@ -150,6 +152,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
|
|||||||
Clock uint64 `json:"clock"`
|
Clock uint64 `json:"clock"`
|
||||||
Replace string `json:"replace"`
|
Replace string `json:"replace"`
|
||||||
ResponseTo string `json:"responseTo"`
|
ResponseTo string `json:"responseTo"`
|
||||||
|
New bool `json:"new,omitempty"`
|
||||||
EnsName string `json:"ensName"`
|
EnsName string `json:"ensName"`
|
||||||
Image string `json:"image,omitempty"`
|
Image string `json:"image,omitempty"`
|
||||||
Audio string `json:"audio,omitempty"`
|
Audio string `json:"audio,omitempty"`
|
||||||
@ -179,6 +182,7 @@ func (m *Message) MarshalJSON() ([]byte, error) {
|
|||||||
LocalChatID: m.LocalChatID,
|
LocalChatID: m.LocalChatID,
|
||||||
Clock: m.Clock,
|
Clock: m.Clock,
|
||||||
ResponseTo: m.ResponseTo,
|
ResponseTo: m.ResponseTo,
|
||||||
|
New: m.New,
|
||||||
EnsName: m.EnsName,
|
EnsName: m.EnsName,
|
||||||
Image: m.Base64Image,
|
Image: m.Base64Image,
|
||||||
Audio: m.Base64Audio,
|
Audio: m.Base64Audio,
|
||||||
|
@ -2534,12 +2534,23 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
newMessagesIds := map[string]struct{}{}
|
||||||
|
for _, message := range messageState.Response.Messages {
|
||||||
|
newMessagesIds[message.ID] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
messagesWithResponses, err := m.pullMessagesAndResponsesFromDB(messageState.Response.Messages)
|
messagesWithResponses, err := m.pullMessagesAndResponsesFromDB(messageState.Response.Messages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
messageState.Response.Messages = messagesWithResponses
|
messageState.Response.Messages = messagesWithResponses
|
||||||
|
|
||||||
|
for _, message := range messageState.Response.Messages {
|
||||||
|
if _, ok := newMessagesIds[message.ID]; ok {
|
||||||
|
message.New = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reset installations
|
// Reset installations
|
||||||
m.modifiedInstallations = make(map[string]bool)
|
m.modifiedInstallations = make(map[string]bool)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user