mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Apply reactions from message edit updates.
This commit is contained in:
parent
0ffd827fc5
commit
aafc24008b
8 changed files with 18 additions and 6 deletions
|
@ -452,6 +452,7 @@ void SendConfirmedFile(
|
|||
edition.textWithEntities = caption;
|
||||
edition.useSameMarkup = true;
|
||||
edition.useSameReplies = true;
|
||||
edition.useSameReactions = true;
|
||||
itemToEdit->applyEdition(std::move(edition));
|
||||
} else {
|
||||
const auto viaBotId = UserId();
|
||||
|
|
|
@ -1625,7 +1625,7 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
|||
peer,
|
||||
d.vmsg_id().v);
|
||||
if (item) {
|
||||
item->updateReactions(d.vreactions());
|
||||
item->updateReactions(&d.vreactions());
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -772,8 +772,13 @@ void HistoryItem::toggleReaction(const QString &reaction) {
|
|||
history()->owner().notifyItemDataChange(this);
|
||||
}
|
||||
|
||||
void HistoryItem::updateReactions(const MTPMessageReactions &reactions) {
|
||||
reactions.match([&](const MTPDmessageReactions &data) {
|
||||
void HistoryItem::updateReactions(const MTPMessageReactions *reactions) {
|
||||
if (!reactions) {
|
||||
_flags &= ~MessageFlag::CanViewReactions;
|
||||
_reactions = nullptr;
|
||||
return;
|
||||
}
|
||||
reactions->match([&](const MTPDmessageReactions &data) {
|
||||
if (data.is_can_see_list()) {
|
||||
_flags |= MessageFlag::CanViewReactions;
|
||||
} else {
|
||||
|
|
|
@ -363,7 +363,7 @@ public:
|
|||
[[nodiscard]] bool canReact() const;
|
||||
void addReaction(const QString &reaction);
|
||||
void toggleReaction(const QString &reaction);
|
||||
void updateReactions(const MTPMessageReactions &reactions);
|
||||
void updateReactions(const MTPMessageReactions *reactions);
|
||||
[[nodiscard]] const base::flat_map<QString, int> &reactions() const;
|
||||
[[nodiscard]] bool canViewReactions() const;
|
||||
[[nodiscard]] QString chosenReaction() const;
|
||||
|
|
|
@ -23,6 +23,7 @@ HistoryMessageEdition::HistoryMessageEdition(
|
|||
};
|
||||
replyMarkup = HistoryMessageMarkupData(message.vreply_markup());
|
||||
mtpMedia = message.vmedia();
|
||||
mtpReactions = message.vreactions();
|
||||
views = message.vviews().value_or(-1);
|
||||
forwards = message.vforwards().value_or(-1);
|
||||
if (const auto mtpReplies = message.vreplies()) {
|
||||
|
|
|
@ -26,8 +26,10 @@ struct HistoryMessageEdition {
|
|||
int ttl = 0;
|
||||
bool useSameReplies = false;
|
||||
bool useSameMarkup = false;
|
||||
bool useSameReactions = false;
|
||||
TextWithEntities textWithEntities;
|
||||
HistoryMessageMarkupData replyMarkup;
|
||||
HistoryMessageRepliesData replies;
|
||||
const MTPMessageMedia *mtpMedia = nullptr;
|
||||
const MTPMessageReactions *mtpReactions = nullptr;
|
||||
};
|
||||
|
|
|
@ -511,7 +511,7 @@ HistoryMessage::HistoryMessage(
|
|||
MessageGroupId::FromRaw(history->peer->id, groupedId->v));
|
||||
}
|
||||
if (const auto reactions = data.vreactions()) {
|
||||
updateReactions(*reactions);
|
||||
updateReactions(reactions);
|
||||
}
|
||||
|
||||
applyTTL(data);
|
||||
|
@ -1414,6 +1414,9 @@ void HistoryMessage::applyEdition(HistoryMessageEdition &&edition) {
|
|||
if (!isLocalUpdateMedia()) {
|
||||
refreshMedia(edition.mtpMedia);
|
||||
}
|
||||
if (!edition.useSameReactions) {
|
||||
updateReactions(edition.mtpReactions);
|
||||
}
|
||||
changeViewsCount(edition.views);
|
||||
setForwardsCount(edition.forwards);
|
||||
setText(_media
|
||||
|
|
|
@ -1076,7 +1076,7 @@ void HistoryService::createFromMtp(const MTPDmessage &message) {
|
|||
}
|
||||
|
||||
if (const auto reactions = message.vreactions()) {
|
||||
updateReactions(*reactions);
|
||||
updateReactions(reactions);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue