fix(edits): mark edits as Mentioned if the og message was not a mention
Marks Edit messages as Mentioned when the original message was not Mentioned and the Edit is, so that we increase the unviewed count only once
This commit is contained in:
parent
7c2b5a39b3
commit
4f013cc7af
|
@ -1469,6 +1469,8 @@ func (m *Messenger) HandleEditMessage(state *ReceivedMessageState, editMessage E
|
||||||
return m.persistence.SaveEdit(editMessage)
|
return m.persistence.SaveEdit(editMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
originalMessageMentioned := originalMessage.Mentioned
|
||||||
|
|
||||||
chat, ok := m.allChats.Load(originalMessage.LocalChatID)
|
chat, ok := m.allChats.Load(originalMessage.LocalChatID)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("chat not found")
|
return errors.New("chat not found")
|
||||||
|
@ -1507,6 +1509,14 @@ func (m *Messenger) HandleEditMessage(state *ReceivedMessageState, editMessage E
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editedMessageHasMentions := originalMessage.Mentioned
|
||||||
|
|
||||||
|
if editedMessageHasMentions && !originalMessageMentioned && !originalMessage.Seen {
|
||||||
|
// Increase unviewed count when the edited message has a mention and didn't have one before
|
||||||
|
m.updateUnviewedCounts(chat, originalMessage.Mentioned || originalMessage.Replied)
|
||||||
|
}
|
||||||
|
|
||||||
state.Response.AddMessage(originalMessage)
|
state.Response.AddMessage(originalMessage)
|
||||||
state.Response.AddChat(chat)
|
state.Response.AddChat(chat)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue