diff --git a/protocol/common/message.go b/protocol/common/message.go index 429bfcb3ad4..69e1ef35cbf 100644 --- a/protocol/common/message.go +++ b/protocol/common/message.go @@ -632,17 +632,6 @@ func (m *Message) PrepareContent(identity string) error { return m.parseAudio() } -func (m *Message) IsSystemMessage() bool { - return m.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_CONTENT_PRIVATE_GROUP || - m.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_GAP || - m.ContentType == protobuf.ChatMessage_CONTACT_REQUEST || - m.ContentType == protobuf.ChatMessage_IDENTITY_VERIFICATION || - m.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_PINNED_MESSAGE || - m.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_SENT || - m.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED || - m.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED -} - // GetSimplifiedText returns a the text stripped of all the markdown and with mentions // replaced by canonical names func (m *Message) GetSimplifiedText(identity string, canonicalNames map[string]string) (string, error) { diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 4127ededded..9b1267ba613 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -40,13 +40,6 @@ const ( requestAddressForTransactionDeclinedMessage = "Request address for transaction declined" ) -const ( - // IncreaseUnviewedMessagesCountTimeout - // this timeout indicates how long the time between received messages should be - // for a new message to increase the unviewed messages counter - IncreaseUnviewedMessagesCountTimeout = 1000 * 60 * 2 -) - var ( ErrMessageNotAllowed = errors.New("message from a non-contact") ErrMessageForWrongChatType = errors.New("message for the wrong chat type") @@ -420,7 +413,7 @@ func (m *Messenger) handleCommandMessage(state *ReceivedMessageState, message *c // Increase unviewed count if !common.IsPubKeyEqual(message.SigPubKey, &m.identity.PublicKey) { - m.updateUnviewedCounts(chat, message) + m.updateUnviewedCounts(chat, message.Mentioned || message.Replied) message.OutgoingStatus = "" } else { // Our own message, mark as sent @@ -2127,7 +2120,7 @@ func (m *Messenger) handleChatMessage(state *ReceivedMessageState, forceSeen boo } } if !skipUpdateUnviewedCountForAlbums { - m.updateUnviewedCounts(chat, receivedMessage) + m.updateUnviewedCounts(chat, receivedMessage.Mentioned || receivedMessage.Replied) } } @@ -3082,17 +3075,9 @@ func (m *Messenger) isMessageAllowedFrom(publicKey string, chat *Chat) (bool, er return contact.added(), nil } -func (m *Messenger) updateUnviewedCounts(chat *Chat, message *common.Message) { - if chat == nil { - return - } - if chat.LastMessage == nil || - chat.LastMessage.IsSystemMessage() || - !chat.LastMessage.New || - message.Timestamp > chat.LastMessage.Timestamp+IncreaseUnviewedMessagesCountTimeout { - chat.UnviewedMessagesCount++ - } - if message.Mentioned || message.Replied { +func (m *Messenger) updateUnviewedCounts(chat *Chat, mentionedOrReplied bool) { + chat.UnviewedMessagesCount++ + if mentionedOrReplied { chat.UnviewedMentionsCount++ } }