mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Add a RequestDependentMessageData method.
This commit is contained in:
parent
213d7875ba
commit
6eaeb306d6
3 changed files with 29 additions and 25 deletions
|
@ -347,15 +347,23 @@ void FastShareMessage(not_null<HistoryItem*> item) {
|
|||
.navigation = App::wnd()->sessionController() }));
|
||||
}
|
||||
|
||||
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||
not_null<HistoryItem*> item) {
|
||||
const auto session = &item->history()->session();
|
||||
const auto dependent = item->fullId();
|
||||
return [=](ChannelData *channel, MsgId msgId) {
|
||||
if (const auto item = session->data().message(dependent)) {
|
||||
item->updateDependencyItem();
|
||||
}
|
||||
};
|
||||
void RequestDependentMessageData(
|
||||
not_null<HistoryItem*> item,
|
||||
PeerId peerId,
|
||||
MsgId msgId) {
|
||||
const auto fullId = item->fullId();
|
||||
const auto history = item->history();
|
||||
const auto session = &history->session();
|
||||
history->session().api().requestMessageData(
|
||||
(peerIsChannel(peerId)
|
||||
? history->owner().channel(peerToChannel(peerId)).get()
|
||||
: history->peer->asChannel()),
|
||||
msgId,
|
||||
[=](ChannelData *channel, MsgId msgId) {
|
||||
if (const auto item = session->data().message(fullId)) {
|
||||
item->updateDependencyItem();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
MessageFlags NewMessageFlags(not_null<PeerData*> peer) {
|
||||
|
@ -1094,13 +1102,10 @@ void HistoryMessage::createComponents(CreateConfig &&config) {
|
|||
reply->replyToMsgId = config.replyTo;
|
||||
reply->replyToMsgTop = isScheduled() ? 0 : config.replyToTop;
|
||||
if (!reply->updateData(this)) {
|
||||
history()->session().api().requestMessageData(
|
||||
(peerIsChannel(reply->replyToPeerId)
|
||||
? history()->owner().channel(
|
||||
peerToChannel(reply->replyToPeerId)).get()
|
||||
: history()->peer->asChannel()),
|
||||
reply->replyToMsgId,
|
||||
HistoryDependentItemCallback(this));
|
||||
RequestDependentMessageData(
|
||||
this,
|
||||
reply->replyToPeerId,
|
||||
reply->replyToMsgId);
|
||||
}
|
||||
}
|
||||
if (const auto via = Get<HistoryMessageVia>()) {
|
||||
|
|
|
@ -23,8 +23,10 @@ struct HistoryMessageReply;
|
|||
struct HistoryMessageViews;
|
||||
struct HistoryMessageMarkupData;
|
||||
|
||||
[[nodiscard]] Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
|
||||
not_null<HistoryItem*> item);
|
||||
void RequestDependentMessageData(
|
||||
not_null<HistoryItem*> item,
|
||||
PeerId peerId,
|
||||
MsgId msgId);
|
||||
[[nodiscard]] MessageFlags NewMessageFlags(not_null<PeerData*> peer);
|
||||
[[nodiscard]] bool ShouldSendSilent(
|
||||
not_null<PeerData*> peer,
|
||||
|
|
|
@ -1153,13 +1153,10 @@ void HistoryService::createFromMtp(const MTPDmessageService &message) {
|
|||
: 0;
|
||||
dependent->msgId = data.vreply_to_msg_id().v;
|
||||
if (!updateDependent()) {
|
||||
history()->session().api().requestMessageData(
|
||||
(peerIsChannel(dependent->peerId)
|
||||
? history()->owner().channel(
|
||||
peerToChannel(dependent->peerId)).get()
|
||||
: history()->peer->asChannel()),
|
||||
dependent->msgId,
|
||||
HistoryDependentItemCallback(this));
|
||||
RequestDependentMessageData(
|
||||
this,
|
||||
dependent->peerId,
|
||||
dependent->msgId);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue