Process unread reactions to unknown messages.

This commit is contained in:
John Preston 2022-01-28 17:11:38 +03:00
parent 51c805d77a
commit 4e9a52343f
4 changed files with 39 additions and 0 deletions

View file

@ -31,6 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_folder.h"
#include "data/data_scheduled_messages.h"
#include "data/data_send_action.h"
#include "data/data_message_reactions.h"
#include "chat_helpers/emoji_interactions.h"
#include "lang/lang_cloud_manager.h"
#include "history/history.h"
@ -1632,6 +1633,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
d.vmsg_id().v);
if (item) {
item->updateReactions(&d.vreactions());
} else if (Data::Reactions::HasUnread(d.vreactions())) {
history->owner().histories().requestDialogEntry(history);
}
}
} break;

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_app_config.h"
#include "data/data_user.h"
#include "data/data_session.h"
#include "data/data_histories.h"
#include "data/data_changes.h"
#include "data/data_document.h"
#include "data/data_document_media.h"
@ -472,6 +473,35 @@ bool Reactions::sending(not_null<HistoryItem*> item) const {
return _sentRequests.contains(item->fullId());
}
bool Reactions::HasUnread(const MTPMessageReactions &data) {
return data.match([&](const MTPDmessageReactions &data) {
if (const auto &recent = data.vrecent_reactions()) {
for (const auto &one : recent->v) {
if (one.match([&](const MTPDmessagePeerReaction &data) {
return data.is_unread();
})) {
return true;
}
}
}
return false;
});
}
void Reactions::CheckUnknownForUnread(
not_null<Session*> owner,
const MTPMessage &message) {
message.match([&](const MTPDmessage &data) {
if (data.vreactions() && HasUnread(*data.vreactions())) {
const auto peerId = peerFromMTP(data.vpeer_id());
if (const auto history = owner->historyLoaded(peerId)) {
owner->histories().requestDialogEntry(history);
}
}
}, [](const auto &) {
});
}
MessageReactions::MessageReactions(not_null<HistoryItem*> item)
: _item(item) {
}

View file

@ -68,6 +68,11 @@ public:
void updateAllInHistory(not_null<PeerData*> peer, bool enabled);
[[nodiscard]] static bool HasUnread(const MTPMessageReactions &data);
static void CheckUnknownForUnread(
not_null<Session*> owner,
const MTPMessage &message);
private:
struct ImageSet {
QImage bottomInfo;

View file

@ -1872,6 +1872,7 @@ void Session::updateEditedMessage(const MTPMessage &data) {
return message(peerFromMTP(data.vpeer_id()), data.vid().v);
});
if (!existing) {
Reactions::CheckUnknownForUnread(this, data);
return;
}
if (existing->isLocalUpdateMedia() && data.type() == mtpc_message) {