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