mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-22 09:07:05 +02:00
FullMsgId rely on PeerId instead of ChannelId.
This commit is contained in:
parent
a8f05a01ed
commit
5e7e7eaa83
61 changed files with 446 additions and 475 deletions
|
@ -118,7 +118,7 @@ void PeerPhoto::upload(not_null<PeerData*> peer, QImage &&image) {
|
||||||
std::move(image));
|
std::move(image));
|
||||||
|
|
||||||
const auto fakeId = FullMsgId(
|
const auto fakeId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peer->id,
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto already = ranges::find(
|
const auto already = ranges::find(
|
||||||
_uploads,
|
_uploads,
|
||||||
|
|
|
@ -74,7 +74,7 @@ void SendExistingMedia(
|
||||||
api->sendAction(message.action);
|
api->sendAction(message.action);
|
||||||
|
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peer->id,
|
||||||
session->data().nextLocalMessageId());
|
session->data().nextLocalMessageId());
|
||||||
const auto randomId = base::RandomValue<uint64>();
|
const auto randomId = base::RandomValue<uint64>();
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ bool SendDice(MessageToSend &message) {
|
||||||
api->sendAction(message.action);
|
api->sendAction(message.action);
|
||||||
|
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peer->id,
|
||||||
session->data().nextLocalMessageId());
|
session->data().nextLocalMessageId());
|
||||||
const auto randomId = base::RandomValue<uint64>();
|
const auto randomId = base::RandomValue<uint64>();
|
||||||
|
|
||||||
|
@ -346,10 +346,8 @@ void SendConfirmedFile(
|
||||||
const std::shared_ptr<FileLoadResult> &file) {
|
const std::shared_ptr<FileLoadResult> &file) {
|
||||||
const auto isEditing = (file->type != SendMediaType::Audio)
|
const auto isEditing = (file->type != SendMediaType::Audio)
|
||||||
&& (file->to.replaceMediaOf != 0);
|
&& (file->to.replaceMediaOf != 0);
|
||||||
const auto channelId = peerToChannel(file->to.peer);
|
|
||||||
|
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
channelId,
|
file->to.peer,
|
||||||
isEditing
|
isEditing
|
||||||
? file->to.replaceMediaOf
|
? file->to.replaceMediaOf
|
||||||
: session->data().nextLocalMessageId());
|
: session->data().nextLocalMessageId());
|
||||||
|
|
|
@ -87,7 +87,7 @@ std::optional<HistoryItem*> SingleMessageSearch::performLookupByChannel(
|
||||||
Expects(!_requestKey.empty());
|
Expects(!_requestKey.empty());
|
||||||
|
|
||||||
const auto postId = _requestKey.postId;
|
const auto postId = _requestKey.postId;
|
||||||
if (const auto item = _session->data().message(channel, postId)) {
|
if (const auto item = _session->data().message(channel->id, postId)) {
|
||||||
_cache.emplace(_requestKey, item->fullId());
|
_cache.emplace(_requestKey, item->fullId());
|
||||||
return item;
|
return item;
|
||||||
} else if (!ready) {
|
} else if (!ready) {
|
||||||
|
@ -112,7 +112,7 @@ std::optional<HistoryItem*> SingleMessageSearch::performLookupByChannel(
|
||||||
&& received.messageIds.front() == postId) {
|
&& received.messageIds.front() == postId) {
|
||||||
_cache.emplace(
|
_cache.emplace(
|
||||||
_requestKey,
|
_requestKey,
|
||||||
FullMsgId(peerToChannel(channel->id), postId));
|
FullMsgId(channel->id, postId));
|
||||||
ready();
|
ready();
|
||||||
} else {
|
} else {
|
||||||
fail();
|
fail();
|
||||||
|
|
|
@ -730,7 +730,7 @@ void Updates::addActiveChat(rpl::producer<PeerData*> chat) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Updates::requestChannelRangeDifference(not_null<History*> history) {
|
void Updates::requestChannelRangeDifference(not_null<History*> history) {
|
||||||
Expects(history->isChannel());
|
Expects(history->peer->isChannel());
|
||||||
|
|
||||||
const auto channel = history->peer->asChannel();
|
const auto channel = history->peer->asChannel();
|
||||||
if (const auto requestId = _rangeDifferenceRequests.take(channel)) {
|
if (const auto requestId = _rangeDifferenceRequests.take(channel)) {
|
||||||
|
@ -1181,7 +1181,7 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
|
||||||
const auto &d = update.c_updateReadMessagesContents();
|
const auto &d = update.c_updateReadMessagesContents();
|
||||||
auto possiblyReadMentions = base::flat_set<MsgId>();
|
auto possiblyReadMentions = base::flat_set<MsgId>();
|
||||||
for (const auto &msgId : d.vmessages().v) {
|
for (const auto &msgId : d.vmessages().v) {
|
||||||
if (const auto item = _session->data().message(NoChannel, msgId.v)) {
|
if (const auto item = _session->data().nonChannelMessage(msgId.v)) {
|
||||||
if (item->isUnreadMedia() || item->isUnreadMention()) {
|
if (item->isUnreadMedia() || item->isUnreadMention()) {
|
||||||
item->markMediaRead();
|
item->markMediaRead();
|
||||||
_session->data().requestItemRepaint(item);
|
_session->data().requestItemRepaint(item);
|
||||||
|
@ -1249,7 +1249,7 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
|
||||||
|
|
||||||
case mtpc_updateDeleteMessages: {
|
case mtpc_updateDeleteMessages: {
|
||||||
auto &d = update.c_updateDeleteMessages();
|
auto &d = update.c_updateDeleteMessages();
|
||||||
_session->data().processMessagesDeleted(NoChannel, d.vmessages().v);
|
_session->data().processNonChannelMessagesDeleted(d.vmessages().v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateNewChannelMessage: {
|
case mtpc_updateNewChannelMessage: {
|
||||||
|
@ -1278,9 +1278,9 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
|
||||||
|
|
||||||
case mtpc_updatePinnedChannelMessages: {
|
case mtpc_updatePinnedChannelMessages: {
|
||||||
const auto &d = update.c_updatePinnedChannelMessages();
|
const auto &d = update.c_updatePinnedChannelMessages();
|
||||||
const auto channelId = d.vchannel_id().v;
|
const auto peerId = peerFromChannel(d.vchannel_id());
|
||||||
for (const auto &msgId : d.vmessages().v) {
|
for (const auto &msgId : d.vmessages().v) {
|
||||||
const auto item = session().data().message(channelId, msgId.v);
|
const auto item = session().data().message(peerId, msgId.v);
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setIsPinned(d.is_pinned());
|
item->setIsPinned(d.is_pinned());
|
||||||
}
|
}
|
||||||
|
@ -1299,13 +1299,16 @@ void Updates::applyUpdateNoPtsCheck(const MTPUpdate &update) {
|
||||||
|
|
||||||
case mtpc_updateDeleteChannelMessages: {
|
case mtpc_updateDeleteChannelMessages: {
|
||||||
auto &d = update.c_updateDeleteChannelMessages();
|
auto &d = update.c_updateDeleteChannelMessages();
|
||||||
_session->data().processMessagesDeleted(d.vchannel_id().v, d.vmessages().v);
|
_session->data().processMessagesDeleted(
|
||||||
|
peerFromChannel(d.vchannel_id().v),
|
||||||
|
d.vmessages().v);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updatePinnedMessages: {
|
case mtpc_updatePinnedMessages: {
|
||||||
const auto &d = update.c_updatePinnedMessages();
|
const auto &d = update.c_updatePinnedMessages();
|
||||||
|
const auto peerId = peerFromMTP(d.vpeer());
|
||||||
for (const auto &msgId : d.vmessages().v) {
|
for (const auto &msgId : d.vmessages().v) {
|
||||||
const auto item = session().data().message(0, msgId.v);
|
const auto item = session().data().message(peerId, msgId.v);
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setIsPinned(d.is_pinned());
|
item->setIsPinned(d.is_pinned());
|
||||||
}
|
}
|
||||||
|
@ -1424,7 +1427,7 @@ void Updates::applyUpdates(
|
||||||
const auto sent = owner.messageSentData(randomId);
|
const auto sent = owner.messageSentData(randomId);
|
||||||
const auto lookupMessage = [&] {
|
const auto lookupMessage = [&] {
|
||||||
return sent.peerId
|
return sent.peerId
|
||||||
? owner.message(peerToChannel(sent.peerId), d.vid().v)
|
? owner.message(sent.peerId, d.vid().v)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
};
|
};
|
||||||
if (const auto id = owner.messageIdByRandomId(randomId)) {
|
if (const auto id = owner.messageIdByRandomId(randomId)) {
|
||||||
|
@ -1439,9 +1442,9 @@ void Updates::applyUpdates(
|
||||||
const auto list = d.ventities();
|
const auto list = d.ventities();
|
||||||
if (list && !MentionUsersLoaded(&session(), *list)) {
|
if (list && !MentionUsersLoaded(&session(), *list)) {
|
||||||
session().api().requestMessageData(
|
session().api().requestMessageData(
|
||||||
item->history()->peer->asChannel(),
|
item->history()->peer,
|
||||||
item->id,
|
item->id,
|
||||||
ApiWrap::RequestMessageDataCallback());
|
nullptr);
|
||||||
}
|
}
|
||||||
item->applySentMessage(sent.text, d, wasAlready);
|
item->applySentMessage(sent.text, d, wasAlready);
|
||||||
}
|
}
|
||||||
|
@ -1527,9 +1530,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
if (local->isScheduled()) {
|
if (local->isScheduled()) {
|
||||||
session().data().scheduledMessages().apply(d, local);
|
session().data().scheduledMessages().apply(d, local);
|
||||||
} else {
|
} else {
|
||||||
const auto channel = id.channel;
|
|
||||||
const auto existing = session().data().message(
|
const auto existing = session().data().message(
|
||||||
channel,
|
id.peer,
|
||||||
newId);
|
newId);
|
||||||
if (existing && !local->mainView()) {
|
if (existing && !local->mainView()) {
|
||||||
const auto history = local->history();
|
const auto history = local->history();
|
||||||
|
@ -1566,7 +1568,7 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
}
|
}
|
||||||
auto possiblyReadMentions = base::flat_set<MsgId>();
|
auto possiblyReadMentions = base::flat_set<MsgId>();
|
||||||
for (const auto &msgId : d.vmessages().v) {
|
for (const auto &msgId : d.vmessages().v) {
|
||||||
if (auto item = session().data().message(channel, msgId.v)) {
|
if (auto item = session().data().message(channel->id, msgId.v)) {
|
||||||
if (item->isUnreadMedia() || item->isUnreadMention()) {
|
if (item->isUnreadMedia() || item->isUnreadMention()) {
|
||||||
item->markMediaRead();
|
item->markMediaRead();
|
||||||
session().data().requestItemRepaint(item);
|
session().data().requestItemRepaint(item);
|
||||||
|
@ -2146,24 +2148,26 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
|
|
||||||
case mtpc_updateChannelMessageViews: {
|
case mtpc_updateChannelMessageViews: {
|
||||||
const auto &d = update.c_updateChannelMessageViews();
|
const auto &d = update.c_updateChannelMessageViews();
|
||||||
if (const auto item = session().data().message(d.vchannel_id().v, d.vid().v)) {
|
const auto peerId = peerFromChannel(d.vchannel_id());
|
||||||
|
if (const auto item = session().data().message(peerId, d.vid().v)) {
|
||||||
item->setViewsCount(d.vviews().v);
|
item->setViewsCount(d.vviews().v);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateChannelMessageForwards: {
|
case mtpc_updateChannelMessageForwards: {
|
||||||
const auto &d = update.c_updateChannelMessageForwards();
|
const auto &d = update.c_updateChannelMessageForwards();
|
||||||
if (const auto item = session().data().message(d.vchannel_id().v, d.vid().v)) {
|
const auto peerId = peerFromChannel(d.vchannel_id());
|
||||||
|
if (const auto item = session().data().message(peerId, d.vid().v)) {
|
||||||
item->setForwardsCount(d.vforwards().v);
|
item->setForwardsCount(d.vforwards().v);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case mtpc_updateReadChannelDiscussionInbox: {
|
case mtpc_updateReadChannelDiscussionInbox: {
|
||||||
const auto &d = update.c_updateReadChannelDiscussionInbox();
|
const auto &d = update.c_updateReadChannelDiscussionInbox();
|
||||||
const auto channelId = d.vchannel_id().v;
|
const auto peerId = peerFromChannel(d.vchannel_id());
|
||||||
const auto msgId = d.vtop_msg_id().v;
|
const auto msgId = d.vtop_msg_id().v;
|
||||||
const auto readTillId = d.vread_max_id().v;
|
const auto readTillId = d.vread_max_id().v;
|
||||||
const auto item = session().data().message(channelId, msgId);
|
const auto item = session().data().message(peerId, msgId);
|
||||||
const auto unreadCount = item
|
const auto unreadCount = item
|
||||||
? session().data().countUnreadRepliesLocally(item, readTillId)
|
? session().data().countUnreadRepliesLocally(item, readTillId)
|
||||||
: std::nullopt;
|
: std::nullopt;
|
||||||
|
@ -2175,7 +2179,7 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
}
|
}
|
||||||
if (const auto broadcastId = d.vbroadcast_id()) {
|
if (const auto broadcastId = d.vbroadcast_id()) {
|
||||||
if (const auto post = session().data().message(
|
if (const auto post = session().data().message(
|
||||||
broadcastId->v,
|
peerFromChannel(*broadcastId),
|
||||||
d.vbroadcast_post()->v)) {
|
d.vbroadcast_post()->v)) {
|
||||||
post->setRepliesInboxReadTill(readTillId, unreadCount);
|
post->setRepliesInboxReadTill(readTillId, unreadCount);
|
||||||
}
|
}
|
||||||
|
@ -2184,10 +2188,10 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
|
|
||||||
case mtpc_updateReadChannelDiscussionOutbox: {
|
case mtpc_updateReadChannelDiscussionOutbox: {
|
||||||
const auto &d = update.c_updateReadChannelDiscussionOutbox();
|
const auto &d = update.c_updateReadChannelDiscussionOutbox();
|
||||||
const auto channelId = d.vchannel_id().v;
|
const auto peerId = peerFromChannel(d.vchannel_id());
|
||||||
const auto msgId = d.vtop_msg_id().v;
|
const auto msgId = d.vtop_msg_id().v;
|
||||||
const auto readTillId = d.vread_max_id().v;
|
const auto readTillId = d.vread_max_id().v;
|
||||||
const auto item = session().data().message(channelId, msgId);
|
const auto item = session().data().message(peerId, msgId);
|
||||||
if (item) {
|
if (item) {
|
||||||
item->setRepliesOutboxReadTill(readTillId);
|
item->setRepliesOutboxReadTill(readTillId);
|
||||||
if (const auto post = item->lookupDiscussionPostOriginal()) {
|
if (const auto post = item->lookupDiscussionPostOriginal()) {
|
||||||
|
|
|
@ -95,9 +95,8 @@ void ViewsManager::done(
|
||||||
if (id != requestId) {
|
if (id != requestId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto channel = peerToChannel(peer->id);
|
|
||||||
for (auto j = 0, l = int(ids.size()); j < l; ++j) {
|
for (auto j = 0, l = int(ids.size()); j < l; ++j) {
|
||||||
if (const auto item = owner.message(channel, ids[j].v)) {
|
if (const auto item = owner.message(peer->id, ids[j].v)) {
|
||||||
v[j].match([&](const MTPDmessageViews &data) {
|
v[j].match([&](const MTPDmessageViews &data) {
|
||||||
if (const auto views = data.vviews()) {
|
if (const auto views = data.vviews()) {
|
||||||
item->setViewsCount(views->v);
|
item->setViewsCount(views->v);
|
||||||
|
|
|
@ -510,14 +510,14 @@ void ApiWrap::sendMessageFail(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::requestMessageData(
|
void ApiWrap::requestMessageData(
|
||||||
ChannelData *channel,
|
PeerData *peer,
|
||||||
MsgId msgId,
|
MsgId msgId,
|
||||||
RequestMessageDataCallback callback) {
|
Fn<void()> done) {
|
||||||
auto &requests = channel
|
auto &requests = (peer && peer->isChannel())
|
||||||
? _channelMessageDataRequests[channel][msgId]
|
? _channelMessageDataRequests[peer->asChannel()][msgId]
|
||||||
: _messageDataRequests[msgId];
|
: _messageDataRequests[msgId];
|
||||||
if (callback) {
|
if (done) {
|
||||||
requests.callbacks.push_back(callback);
|
requests.callbacks.push_back(std::move(done));
|
||||||
}
|
}
|
||||||
if (!requests.requestId) {
|
if (!requests.requestId) {
|
||||||
_messageDataResolveDelayed.call();
|
_messageDataResolveDelayed.call();
|
||||||
|
@ -539,19 +539,19 @@ QVector<MTPInputMessage> ApiWrap::collectMessageIds(
|
||||||
|
|
||||||
auto ApiWrap::messageDataRequests(ChannelData *channel, bool onlyExisting)
|
auto ApiWrap::messageDataRequests(ChannelData *channel, bool onlyExisting)
|
||||||
-> MessageDataRequests* {
|
-> MessageDataRequests* {
|
||||||
if (channel) {
|
if (!channel) {
|
||||||
auto i = _channelMessageDataRequests.find(channel);
|
return &_messageDataRequests;
|
||||||
if (i == end(_channelMessageDataRequests)) {
|
|
||||||
if (onlyExisting) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
i = _channelMessageDataRequests.emplace(
|
|
||||||
channel,
|
|
||||||
MessageDataRequests()).first;
|
|
||||||
}
|
|
||||||
return &i->second;
|
|
||||||
}
|
}
|
||||||
return &_messageDataRequests;
|
const auto i = _channelMessageDataRequests.find(channel);
|
||||||
|
if (i != end(_channelMessageDataRequests)) {
|
||||||
|
return &i->second;
|
||||||
|
} else if (onlyExisting) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return &_channelMessageDataRequests.emplace(
|
||||||
|
channel,
|
||||||
|
MessageDataRequests()
|
||||||
|
).first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiWrap::resolveMessageDatas() {
|
void ApiWrap::resolveMessageDatas() {
|
||||||
|
@ -614,20 +614,31 @@ void ApiWrap::finalizeMessageDataRequest(
|
||||||
ChannelData *channel,
|
ChannelData *channel,
|
||||||
mtpRequestId requestId) {
|
mtpRequestId requestId) {
|
||||||
auto requests = messageDataRequests(channel, true);
|
auto requests = messageDataRequests(channel, true);
|
||||||
if (requests) {
|
if (!requests) {
|
||||||
for (auto i = requests->begin(); i != requests->cend();) {
|
return;
|
||||||
if (i->second.requestId == requestId) {
|
}
|
||||||
for (const auto &callback : i->second.callbacks) {
|
auto callbacks = std::vector<Fn<void()>>();
|
||||||
callback(channel, i->first);
|
for (auto i = requests->begin(); i != requests->cend();) {
|
||||||
}
|
if (i->second.requestId == requestId) {
|
||||||
i = requests->erase(i);
|
auto &list = i->second.callbacks;
|
||||||
|
if (callbacks.empty()) {
|
||||||
|
callbacks = std::move(list);
|
||||||
} else {
|
} else {
|
||||||
++i;
|
callbacks.insert(
|
||||||
|
end(callbacks),
|
||||||
|
std::make_move_iterator(begin(list)),
|
||||||
|
std::make_move_iterator(end(list)));
|
||||||
}
|
}
|
||||||
|
i = requests->erase(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
}
|
}
|
||||||
if (channel && requests->empty()) {
|
}
|
||||||
_channelMessageDataRequests.remove(channel);
|
if (channel && requests->empty()) {
|
||||||
}
|
_channelMessageDataRequests.remove(channel);
|
||||||
|
}
|
||||||
|
for (const auto &callback : callbacks) {
|
||||||
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +657,7 @@ QString ApiWrap::exportDirectMessageLink(
|
||||||
if (inRepliesContext) {
|
if (inRepliesContext) {
|
||||||
if (const auto rootId = item->replyToTop()) {
|
if (const auto rootId = item->replyToTop()) {
|
||||||
const auto root = item->history()->owner().message(
|
const auto root = item->history()->owner().message(
|
||||||
peerToChannel(channel->id),
|
channel->id,
|
||||||
rootId);
|
rootId);
|
||||||
const auto sender = root
|
const auto sender = root
|
||||||
? root->discussionPostOriginalSender()
|
? root->discussionPostOriginalSender()
|
||||||
|
@ -1388,9 +1399,8 @@ void ApiWrap::deleteAllFromParticipant(
|
||||||
const auto ids = history
|
const auto ids = history
|
||||||
? history->collectMessagesFromParticipantToDelete(from)
|
? history->collectMessagesFromParticipantToDelete(from)
|
||||||
: std::vector<MsgId>();
|
: std::vector<MsgId>();
|
||||||
const auto channelId = peerToChannel(channel->id);
|
|
||||||
for (const auto &msgId : ids) {
|
for (const auto &msgId : ids) {
|
||||||
if (const auto item = _session->data().message(channelId, msgId)) {
|
if (const auto item = _session->data().message(channel->id, msgId)) {
|
||||||
item->destroy();
|
item->destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2225,11 +2235,7 @@ void ApiWrap::resolveWebPages() {
|
||||||
if (i.key()->pendingTill <= t) {
|
if (i.key()->pendingTill <= t) {
|
||||||
const auto item = _session->data().findWebPageItem(i.key());
|
const auto item = _session->data().findWebPageItem(i.key());
|
||||||
if (item) {
|
if (item) {
|
||||||
if (item->channelId() == NoChannel) {
|
if (const auto channel = item->history()->peer->asChannel()) {
|
||||||
ids.push_back(MTP_inputMessageID(MTP_int(item->id)));
|
|
||||||
i.value() = -1;
|
|
||||||
} else {
|
|
||||||
auto channel = item->history()->peer->asChannel();
|
|
||||||
auto channelMap = idsByChannel.find(channel);
|
auto channelMap = idsByChannel.find(channel);
|
||||||
if (channelMap == idsByChannel.cend()) {
|
if (channelMap == idsByChannel.cend()) {
|
||||||
channelMap = idsByChannel.emplace(
|
channelMap = idsByChannel.emplace(
|
||||||
|
@ -2244,6 +2250,9 @@ void ApiWrap::resolveWebPages() {
|
||||||
MTP_inputMessageID(MTP_int(item->id)));
|
MTP_inputMessageID(MTP_int(item->id)));
|
||||||
}
|
}
|
||||||
i.value() = -channelMap->second.first - 2;
|
i.value() = -channelMap->second.first - 2;
|
||||||
|
} else {
|
||||||
|
ids.push_back(MTP_inputMessageID(MTP_int(item->id)));
|
||||||
|
i.value() = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -2927,14 +2936,13 @@ void ApiWrap::preloadEnoughUnreadMentions(not_null<History*> history) {
|
||||||
void ApiWrap::checkForUnreadMentions(
|
void ApiWrap::checkForUnreadMentions(
|
||||||
const base::flat_set<MsgId> &possiblyReadMentions,
|
const base::flat_set<MsgId> &possiblyReadMentions,
|
||||||
ChannelData *channel) {
|
ChannelData *channel) {
|
||||||
for (auto msgId : possiblyReadMentions) {
|
for (const auto msgId : possiblyReadMentions) {
|
||||||
requestMessageData(channel, msgId, [=](
|
requestMessageData(channel, msgId, [=] {
|
||||||
ChannelData *channel,
|
const auto item = channel
|
||||||
MsgId msgId) {
|
? _session->data().message(channel->id, msgId)
|
||||||
if (const auto item = _session->data().message(channel, msgId)) {
|
: _session->data().nonChannelMessage(msgId);
|
||||||
if (item->mentionsMe()) {
|
if (item && item->mentionsMe()) {
|
||||||
item->markMediaRead();
|
item->markMediaRead();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -3206,7 +3214,7 @@ void ApiWrap::forwardMessages(
|
||||||
const auto randomId = base::RandomValue<uint64>();
|
const auto randomId = base::RandomValue<uint64>();
|
||||||
if (genClientSideMessage) {
|
if (genClientSideMessage) {
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peer->id,
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto self = _session->user();
|
const auto self = _session->user();
|
||||||
const auto messageFromId = sendAs
|
const auto messageFromId = sendAs
|
||||||
|
@ -3279,7 +3287,7 @@ void ApiWrap::sendSharedContact(
|
||||||
const auto peer = history->peer;
|
const auto peer = history->peer;
|
||||||
|
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
history->channelId(),
|
peer->id,
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto anonymousPost = peer->amAnonymous();
|
const auto anonymousPost = peer->amAnonymous();
|
||||||
|
|
||||||
|
@ -3505,7 +3513,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
|
||||||
|
|
||||||
while (TextUtilities::CutPart(sending, left, MaxMessageSize)) {
|
while (TextUtilities::CutPart(sending, left, MaxMessageSize)) {
|
||||||
auto newId = FullMsgId(
|
auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peer->id,
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
auto randomId = base::RandomValue<uint64>();
|
auto randomId = base::RandomValue<uint64>();
|
||||||
|
|
||||||
|
@ -3663,7 +3671,7 @@ void ApiWrap::sendInlineResult(
|
||||||
const auto history = action.history;
|
const auto history = action.history;
|
||||||
const auto peer = history->peer;
|
const auto peer = history->peer;
|
||||||
const auto newId = FullMsgId(
|
const auto newId = FullMsgId(
|
||||||
peerToChannel(peer->id),
|
peer->id,
|
||||||
_session->data().nextLocalMessageId());
|
_session->data().nextLocalMessageId());
|
||||||
const auto randomId = base::RandomValue<uint64>();
|
const auto randomId = base::RandomValue<uint64>();
|
||||||
|
|
||||||
|
|
|
@ -147,11 +147,7 @@ public:
|
||||||
bool archived,
|
bool archived,
|
||||||
Fn<void()> callback);
|
Fn<void()> callback);
|
||||||
|
|
||||||
using RequestMessageDataCallback = Fn<void(ChannelData*, MsgId)>;
|
void requestMessageData(PeerData *peer, MsgId msgId, Fn<void()> done);
|
||||||
void requestMessageData(
|
|
||||||
ChannelData *channel,
|
|
||||||
MsgId msgId,
|
|
||||||
RequestMessageDataCallback callback);
|
|
||||||
QString exportDirectMessageLink(
|
QString exportDirectMessageLink(
|
||||||
not_null<HistoryItem*> item,
|
not_null<HistoryItem*> item,
|
||||||
bool inRepliesContext);
|
bool inRepliesContext);
|
||||||
|
@ -365,7 +361,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MessageDataRequest {
|
struct MessageDataRequest {
|
||||||
using Callbacks = std::vector<RequestMessageDataCallback>;
|
using Callbacks = std::vector<Fn<void()>>;
|
||||||
|
|
||||||
mtpRequestId requestId = 0;
|
mtpRequestId requestId = 0;
|
||||||
Callbacks callbacks;
|
Callbacks callbacks;
|
||||||
|
@ -520,7 +516,7 @@ private:
|
||||||
|
|
||||||
MessageDataRequests _messageDataRequests;
|
MessageDataRequests _messageDataRequests;
|
||||||
base::flat_map<
|
base::flat_map<
|
||||||
ChannelData*,
|
not_null<ChannelData*>,
|
||||||
MessageDataRequests> _channelMessageDataRequests;
|
MessageDataRequests> _channelMessageDataRequests;
|
||||||
SingleQueuedInvokation _messageDataResolveDelayed;
|
SingleQueuedInvokation _messageDataResolveDelayed;
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ namespace {
|
||||||
if (!top) {
|
if (!top) {
|
||||||
return false;
|
return false;
|
||||||
} else if (peer == migrated) {
|
} else if (peer == migrated) {
|
||||||
return top.channel || (id < top.msg);
|
return peerIsChannel(top.peer) || (id < top.msg);
|
||||||
} else if (migrated) {
|
} else if (migrated) {
|
||||||
return top.channel && (id < top.msg);
|
return peerIsChannel(top.peer) && (id < top.msg);
|
||||||
} else {
|
} else {
|
||||||
return (id < top.msg);
|
return (id < top.msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1105,12 +1105,14 @@ QString AppendShareGameScoreUrl(
|
||||||
const FullMsgId &fullId) {
|
const FullMsgId &fullId) {
|
||||||
auto shareHashData = QByteArray(0x20, Qt::Uninitialized);
|
auto shareHashData = QByteArray(0x20, Qt::Uninitialized);
|
||||||
auto shareHashDataInts = reinterpret_cast<uint64*>(shareHashData.data());
|
auto shareHashDataInts = reinterpret_cast<uint64*>(shareHashData.data());
|
||||||
auto channel = fullId.channel
|
const auto peer = fullId.peer
|
||||||
? session->data().channelLoaded(fullId.channel)
|
? session->data().peerLoaded(fullId.peer)
|
||||||
: static_cast<ChannelData*>(nullptr);
|
: static_cast<PeerData*>(nullptr);
|
||||||
auto channelAccessHash = uint64(channel ? channel->access : 0);
|
const auto channelAccessHash = uint64((peer && peer->isChannel())
|
||||||
|
? peer->asChannel()->access
|
||||||
|
: 0);
|
||||||
shareHashDataInts[0] = session->userId().bare;
|
shareHashDataInts[0] = session->userId().bare;
|
||||||
shareHashDataInts[1] = fullId.channel.bare;
|
shareHashDataInts[1] = fullId.peer.value;
|
||||||
shareHashDataInts[2] = uint64(fullId.msg.bare);
|
shareHashDataInts[2] = uint64(fullId.msg.bare);
|
||||||
shareHashDataInts[3] = channelAccessHash;
|
shareHashDataInts[3] = channelAccessHash;
|
||||||
|
|
||||||
|
@ -1190,31 +1192,22 @@ void ShareGameScoreByHash(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check first 32 bits of channel access hash.
|
const auto peerId = PeerId(hashDataInts[1]);
|
||||||
auto channelAccessHash = hashDataInts[3];
|
const auto channelAccessHash = hashDataInts[3];
|
||||||
//auto channelAccessHashInts = reinterpret_cast<int32*>(&channelAccessHash);
|
if (!peerIsChannel(peerId) && channelAccessHash) {
|
||||||
//if (channelAccessHashInts[0] != hashDataInts[3]) {
|
|
||||||
// Ui::show(Box<Ui::InformBox>(tr::lng_share_wrong_user(tr::now)));
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (((hashDataInts[1] >> 40) != 0)
|
|
||||||
|| (!hashDataInts[1] && channelAccessHash)) {
|
|
||||||
// If there is no channel id, there should be no channel access_hash.
|
// If there is no channel id, there should be no channel access_hash.
|
||||||
Ui::show(Box<Ui::InformBox>(tr::lng_share_wrong_user(tr::now)));
|
Ui::show(Box<Ui::InformBox>(tr::lng_share_wrong_user(tr::now)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto channelId = ChannelId(hashDataInts[1]);
|
const auto msgId = MsgId(int64(hashDataInts[2]));
|
||||||
auto msgId = MsgId(int64(hashDataInts[2]));
|
if (const auto item = session->data().message(peerId, msgId)) {
|
||||||
if (const auto item = session->data().message(channelId, msgId)) {
|
|
||||||
FastShareMessage(item);
|
FastShareMessage(item);
|
||||||
} else {
|
} else {
|
||||||
auto resolveMessageAndShareScore = [=](ChannelData *channel) {
|
auto resolveMessageAndShareScore = [=](PeerData *peer) {
|
||||||
session->api().requestMessageData(channel, msgId, [=](
|
session->api().requestMessageData(peer, msgId, [=] {
|
||||||
ChannelData *channel,
|
const auto item = session->data().message(peerId, msgId);
|
||||||
MsgId msgId) {
|
if (item) {
|
||||||
if (const auto item = session->data().message(channel, msgId)) {
|
|
||||||
FastShareMessage(item);
|
FastShareMessage(item);
|
||||||
} else {
|
} else {
|
||||||
Ui::show(Box<Ui::InformBox>(
|
Ui::show(Box<Ui::InformBox>(
|
||||||
|
@ -1223,24 +1216,24 @@ void ShareGameScoreByHash(
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto channel = channelId
|
const auto peer = peerIsChannel(peerId)
|
||||||
? session->data().channelLoaded(channelId)
|
? session->data().peerLoaded(peerId)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (channel || !channelId) {
|
if (peer || !peerIsChannel(peerId)) {
|
||||||
resolveMessageAndShareScore(channel);
|
resolveMessageAndShareScore(peer);
|
||||||
} else {
|
} else {
|
||||||
session->api().request(MTPchannels_GetChannels(
|
session->api().request(MTPchannels_GetChannels(
|
||||||
MTP_vector<MTPInputChannel>(
|
MTP_vector<MTPInputChannel>(
|
||||||
1,
|
1,
|
||||||
MTP_inputChannel(
|
MTP_inputChannel(
|
||||||
MTP_long(channelId.bare),
|
MTP_long(peerToChannel(peerId).bare),
|
||||||
MTP_long(channelAccessHash)))
|
MTP_long(channelAccessHash)))
|
||||||
)).done([=](const MTPmessages_Chats &result) {
|
)).done([=](const MTPmessages_Chats &result) {
|
||||||
result.match([&](const auto &data) {
|
result.match([&](const auto &data) {
|
||||||
session->data().processChats(data.vchats());
|
session->data().processChats(data.vchats());
|
||||||
});
|
});
|
||||||
if (const auto channel = session->data().channelLoaded(channelId)) {
|
if (const auto peer = session->data().peerLoaded(peerId)) {
|
||||||
resolveMessageAndShareScore(channel);
|
resolveMessageAndShareScore(peer);
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,11 +245,12 @@ bool BotKeyboard::updateMarkup(HistoryItem *to, bool force) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_wasForMsgId == FullMsgId(to->channelId(), to->id) && !force) {
|
const auto peerId = to->history()->peer->id;
|
||||||
|
if (_wasForMsgId == FullMsgId(peerId, to->id) && !force) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_wasForMsgId = FullMsgId(to->channelId(), to->id);
|
_wasForMsgId = FullMsgId(peerId, to->id);
|
||||||
|
|
||||||
auto markupFlags = to->replyKeyboardFlags();
|
auto markupFlags = to->replyKeyboardFlags();
|
||||||
_forceReply = markupFlags & ReplyMarkupFlag::ForceReply;
|
_forceReply = markupFlags & ReplyMarkupFlag::ForceReply;
|
||||||
|
|
|
@ -164,7 +164,7 @@ void EmojiInteractions::startIncoming(
|
||||||
if (!peer->isUser() || bunch.interactions.empty()) {
|
if (!peer->isUser() || bunch.interactions.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto item = _session->data().message(nullptr, messageId);
|
const auto item = _session->data().message(peer->id, messageId);
|
||||||
if (!item || !item->isRegular()) {
|
if (!item || !item->isRegular()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -439,8 +439,8 @@ bool OpenMediaTimestamp(
|
||||||
const auto parts = base.mid(3).split('_');
|
const auto parts = base.mid(3).split('_');
|
||||||
const auto documentId = parts.value(0).toULongLong();
|
const auto documentId = parts.value(0).toULongLong();
|
||||||
const auto itemId = FullMsgId(
|
const auto itemId = FullMsgId(
|
||||||
parts.value(1).toInt(),
|
PeerId(parts.value(1).toULongLong()),
|
||||||
parts.value(2).toInt());
|
MsgId(parts.value(2).toLongLong()));
|
||||||
const auto session = &controller->session();
|
const auto session = &controller->session();
|
||||||
const auto document = session->data().document(documentId);
|
const auto document = session->data().document(documentId);
|
||||||
session->settings().setMediaLastPlaybackPosition(
|
session->settings().setMediaLastPlaybackPosition(
|
||||||
|
|
|
@ -300,9 +300,7 @@ void Folder::applyDialog(const MTPDdialogFolder &data) {
|
||||||
_chatsList.updateCloudUnread(data);
|
_chatsList.updateCloudUnread(data);
|
||||||
if (const auto peerId = peerFromMTP(data.vpeer())) {
|
if (const auto peerId = peerFromMTP(data.vpeer())) {
|
||||||
const auto history = owner().history(peerId);
|
const auto history = owner().history(peerId);
|
||||||
const auto fullId = FullMsgId(
|
const auto fullId = FullMsgId(peerId, data.vtop_message().v);
|
||||||
peerToChannel(peerId),
|
|
||||||
data.vtop_message().v);
|
|
||||||
history->setFolder(this, owner().message(fullId));
|
history->setFolder(this, owner().message(fullId));
|
||||||
} else {
|
} else {
|
||||||
_chatsList.clear();
|
_chatsList.clear();
|
||||||
|
|
|
@ -469,7 +469,7 @@ void Histories::requestGroupAround(not_null<HistoryItem*> item) {
|
||||||
result);
|
result);
|
||||||
_chatListGroupRequests.remove(history);
|
_chatListGroupRequests.remove(history);
|
||||||
history->migrateToOrMe()->applyChatListGroup(
|
history->migrateToOrMe()->applyChatListGroup(
|
||||||
history->channelId(),
|
history->peer->id,
|
||||||
result);
|
result);
|
||||||
finish();
|
finish();
|
||||||
}).fail([=] {
|
}).fail([=] {
|
||||||
|
|
|
@ -157,26 +157,6 @@ void MessagesList::removeOne(MessagePosition messageId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesList::removeAll(ChannelId channelId) {
|
|
||||||
auto removed = 0;
|
|
||||||
for (auto i = begin(_slices); i != end(_slices); ++i) {
|
|
||||||
_slices.modify(i, [&](Slice &slice) {
|
|
||||||
auto &messages = slice.messages;
|
|
||||||
for (auto j = begin(messages); j != end(messages);) {
|
|
||||||
if (j->fullId.channel == channelId) {
|
|
||||||
j = messages.erase(j);
|
|
||||||
++removed;
|
|
||||||
} else {
|
|
||||||
++j;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (removed && _count) {
|
|
||||||
*_count -= removed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MessagesList::removeLessThan(MessagePosition messageId) {
|
void MessagesList::removeLessThan(MessagePosition messageId) {
|
||||||
auto removed = 0;
|
auto removed = 0;
|
||||||
for (auto i = begin(_slices); i != end(_slices);) {
|
for (auto i = begin(_slices); i != end(_slices);) {
|
||||||
|
@ -390,22 +370,6 @@ bool MessagesSliceBuilder::removeAll() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MessagesSliceBuilder::removeFromChannel(ChannelId channelId) {
|
|
||||||
for (auto i = _ids.begin(); i != _ids.end();) {
|
|
||||||
if ((*i).fullId.channel == channelId) {
|
|
||||||
i = _ids.erase(i);
|
|
||||||
if (_fullCount) {
|
|
||||||
--*_fullCount;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_skippedBefore = _skippedAfter = std::nullopt;
|
|
||||||
checkInsufficient();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MessagesSliceBuilder::invalidated() {
|
bool MessagesSliceBuilder::invalidated() {
|
||||||
_fullCount = _skippedBefore = _skippedAfter = std::nullopt;
|
_fullCount = _skippedBefore = _skippedAfter = std::nullopt;
|
||||||
_ids.clear();
|
_ids.clear();
|
||||||
|
|
|
@ -65,11 +65,11 @@ struct MessagesRange {
|
||||||
constexpr auto MinDate = TimeId(0);
|
constexpr auto MinDate = TimeId(0);
|
||||||
constexpr auto MaxDate = std::numeric_limits<TimeId>::max();
|
constexpr auto MaxDate = std::numeric_limits<TimeId>::max();
|
||||||
constexpr auto MinMessagePosition = MessagePosition{
|
constexpr auto MinMessagePosition = MessagePosition{
|
||||||
.fullId = FullMsgId(NoChannel, 1),
|
.fullId = FullMsgId(PeerId(), 1),
|
||||||
.date = MinDate,
|
.date = MinDate,
|
||||||
};
|
};
|
||||||
constexpr auto MaxMessagePosition = MessagePosition{
|
constexpr auto MaxMessagePosition = MessagePosition{
|
||||||
.fullId = FullMsgId(NoChannel, ServerMaxMsgId - 1),
|
.fullId = FullMsgId(PeerId(), ServerMaxMsgId - 1),
|
||||||
.date = MaxDate,
|
.date = MaxDate,
|
||||||
};
|
};
|
||||||
constexpr auto FullMessagesRange = MessagesRange{
|
constexpr auto FullMessagesRange = MessagesRange{
|
||||||
|
@ -77,7 +77,7 @@ constexpr auto FullMessagesRange = MessagesRange{
|
||||||
.till = MaxMessagePosition,
|
.till = MaxMessagePosition,
|
||||||
};
|
};
|
||||||
constexpr auto UnreadMessagePosition = MessagePosition{
|
constexpr auto UnreadMessagePosition = MessagePosition{
|
||||||
.fullId = FullMsgId(NoChannel, ShowAtUnreadMsgId),
|
.fullId = FullMsgId(PeerId(), ShowAtUnreadMsgId),
|
||||||
.date = MinDate,
|
.date = MinDate,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -117,7 +117,6 @@ public:
|
||||||
MessagesRange noSkipRange,
|
MessagesRange noSkipRange,
|
||||||
std::optional<int> count);
|
std::optional<int> count);
|
||||||
void removeOne(MessagePosition messageId);
|
void removeOne(MessagePosition messageId);
|
||||||
void removeAll(ChannelId channelId);
|
|
||||||
void removeLessThan(MessagePosition messageId);
|
void removeLessThan(MessagePosition messageId);
|
||||||
void invalidate();
|
void invalidate();
|
||||||
void invalidateBottom();
|
void invalidateBottom();
|
||||||
|
@ -191,7 +190,6 @@ public:
|
||||||
bool applyInitial(const MessagesResult &result);
|
bool applyInitial(const MessagesResult &result);
|
||||||
bool applyUpdate(const MessagesSliceUpdate &update);
|
bool applyUpdate(const MessagesSliceUpdate &update);
|
||||||
bool removeOne(MessagePosition messageId);
|
bool removeOne(MessagePosition messageId);
|
||||||
bool removeFromChannel(ChannelId channelId);
|
|
||||||
bool removeAll();
|
bool removeAll();
|
||||||
bool invalidated();
|
bool invalidated();
|
||||||
bool bottomInvalidated();
|
bool bottomInvalidated();
|
||||||
|
|
|
@ -122,9 +122,10 @@ struct MsgRange {
|
||||||
|
|
||||||
struct FullMsgId {
|
struct FullMsgId {
|
||||||
constexpr FullMsgId() noexcept = default;
|
constexpr FullMsgId() noexcept = default;
|
||||||
constexpr FullMsgId(ChannelId channel, MsgId msg) noexcept
|
constexpr FullMsgId(PeerId peer, MsgId msg) noexcept
|
||||||
: channel(channel), msg(msg) {
|
: peer(peer), msg(msg) {
|
||||||
}
|
}
|
||||||
|
FullMsgId(ChannelId channelId, MsgId msgId) = delete;
|
||||||
|
|
||||||
constexpr explicit operator bool() const noexcept {
|
constexpr explicit operator bool() const noexcept {
|
||||||
return msg != 0;
|
return msg != 0;
|
||||||
|
@ -133,16 +134,16 @@ struct FullMsgId {
|
||||||
return msg == 0;
|
return msg == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelId channel = NoChannel;
|
PeerId peer = 0;
|
||||||
MsgId msg = 0;
|
MsgId msg = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] inline constexpr bool operator<(
|
[[nodiscard]] inline constexpr bool operator<(
|
||||||
const FullMsgId &a,
|
const FullMsgId &a,
|
||||||
const FullMsgId &b) noexcept {
|
const FullMsgId &b) noexcept {
|
||||||
if (a.channel < b.channel) {
|
if (a.peer < b.peer) {
|
||||||
return true;
|
return true;
|
||||||
} else if (a.channel > b.channel) {
|
} else if (a.peer > b.peer) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return a.msg < b.msg;
|
return a.msg < b.msg;
|
||||||
|
@ -169,7 +170,7 @@ struct FullMsgId {
|
||||||
[[nodiscard]] inline constexpr bool operator==(
|
[[nodiscard]] inline constexpr bool operator==(
|
||||||
const FullMsgId &a,
|
const FullMsgId &a,
|
||||||
const FullMsgId &b) noexcept {
|
const FullMsgId &b) noexcept {
|
||||||
return (a.channel == b.channel) && (a.msg == b.msg);
|
return (a.peer == b.peer) && (a.msg == b.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline constexpr bool operator!=(
|
[[nodiscard]] inline constexpr bool operator!=(
|
||||||
|
|
|
@ -1193,11 +1193,11 @@ FullMsgId ResolveTopPinnedId(
|
||||||
.skippedAfter = 0,
|
.skippedAfter = 0,
|
||||||
};
|
};
|
||||||
if (!slice.messageIds.empty()) {
|
if (!slice.messageIds.empty()) {
|
||||||
return FullMsgId(peerToChannel(peer->id), slice.messageIds.back());
|
return FullMsgId(peer->id, slice.messageIds.back());
|
||||||
} else if (!migrated || slice.count != 0 || old.messageIds.empty()) {
|
} else if (!migrated || slice.count != 0 || old.messageIds.empty()) {
|
||||||
return FullMsgId();
|
return FullMsgId();
|
||||||
} else {
|
} else {
|
||||||
return FullMsgId(0, old.messageIds.back());
|
return FullMsgId(migrated->id, old.messageIds.back());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,9 +1227,9 @@ FullMsgId ResolveMinPinnedId(
|
||||||
.skippedAfter = 0,
|
.skippedAfter = 0,
|
||||||
};
|
};
|
||||||
if (!old.messageIds.empty()) {
|
if (!old.messageIds.empty()) {
|
||||||
return FullMsgId(0, old.messageIds.front());
|
return FullMsgId(migrated->id, old.messageIds.front());
|
||||||
} else if (old.count == 0 && !slice.messageIds.empty()) {
|
} else if (old.count == 0 && !slice.messageIds.empty()) {
|
||||||
return FullMsgId(peerToChannel(peer->id), slice.messageIds.front());
|
return FullMsgId(peer->id, slice.messageIds.front());
|
||||||
} else {
|
} else {
|
||||||
return FullMsgId();
|
return FullMsgId();
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,8 +136,6 @@ using ChatId = ChatIdType<1>;
|
||||||
using ChannelId = ChatIdType<2>;
|
using ChannelId = ChatIdType<2>;
|
||||||
using FakeChatId = ChatIdType<0x7F>;
|
using FakeChatId = ChatIdType<0x7F>;
|
||||||
|
|
||||||
inline constexpr auto NoChannel = ChannelId(0);
|
|
||||||
|
|
||||||
struct PeerIdHelper {
|
struct PeerIdHelper {
|
||||||
BareId value = 0;
|
BareId value = 0;
|
||||||
constexpr PeerIdHelper(BareId value) noexcept : value(value) {
|
constexpr PeerIdHelper(BareId value) noexcept : value(value) {
|
||||||
|
|
|
@ -193,10 +193,10 @@ std::optional<int> RepliesList::fullUnreadCountAfter(
|
||||||
|| (fullLoaded && _list.empty());
|
|| (fullLoaded && _list.empty());
|
||||||
const auto countIncoming = [&](auto from, auto till) {
|
const auto countIncoming = [&](auto from, auto till) {
|
||||||
auto &owner = _history->owner();
|
auto &owner = _history->owner();
|
||||||
const auto channelId = _history->channelId();
|
const auto peerId = _history->peer->id;
|
||||||
auto count = 0;
|
auto count = 0;
|
||||||
for (auto i = from; i != till; ++i) {
|
for (auto i = from; i != till; ++i) {
|
||||||
if (!owner.message(channelId, *i)->out()) {
|
if (!owner.message(peerId, *i)->out()) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,7 +336,7 @@ bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
|
||||||
= (*_skippedAfter + (availableAfter - useAfter));
|
= (*_skippedAfter + (availableAfter - useAfter));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto channelId = _history->channelId();
|
const auto peerId = _history->peer->id;
|
||||||
slice->ids.clear();
|
slice->ids.clear();
|
||||||
auto nearestToAround = std::optional<MsgId>();
|
auto nearestToAround = std::optional<MsgId>();
|
||||||
slice->ids.reserve(useAfter + useBefore);
|
slice->ids.reserve(useAfter + useBefore);
|
||||||
|
@ -346,10 +346,10 @@ bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
|
||||||
? *j
|
? *j
|
||||||
: *(j - 1);
|
: *(j - 1);
|
||||||
}
|
}
|
||||||
slice->ids.emplace_back(channelId, *j);
|
slice->ids.emplace_back(peerId, *j);
|
||||||
}
|
}
|
||||||
slice->nearestToAround = FullMsgId(
|
slice->nearestToAround = FullMsgId(
|
||||||
channelId,
|
peerId,
|
||||||
nearestToAround.value_or(
|
nearestToAround.value_or(
|
||||||
slice->ids.empty() ? 0 : slice->ids.back().msg));
|
slice->ids.empty() ? 0 : slice->ids.back().msg));
|
||||||
slice->fullCount = _fullCount.current();
|
slice->fullCount = _fullCount.current();
|
||||||
|
@ -418,7 +418,7 @@ Histories &RepliesList::histories() {
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *RepliesList::lookupRoot() {
|
HistoryItem *RepliesList::lookupRoot() {
|
||||||
return _history->owner().message(_history->channelId(), _rootId);
|
return _history->owner().message(_history->peer->id, _rootId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesList::loadAround(MsgId id) {
|
void RepliesList::loadAround(MsgId id) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ HistoryItem *ScheduledMessages::lookupItem(PeerId peer, MsgId msg) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *ScheduledMessages::lookupItem(FullMsgId itemId) const {
|
HistoryItem *ScheduledMessages::lookupItem(FullMsgId itemId) const {
|
||||||
return lookupItem(peerFromChannel(itemId.channel), itemId.msg);
|
return lookupItem(itemId.peer, itemId.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScheduledMessages::count(not_null<History*> history) const {
|
int ScheduledMessages::count(not_null<History*> history) const {
|
||||||
|
|
|
@ -285,7 +285,7 @@ void Session::clear() {
|
||||||
_sponsoredMessages = nullptr;
|
_sponsoredMessages = nullptr;
|
||||||
_dependentMessages.clear();
|
_dependentMessages.clear();
|
||||||
base::take(_messages);
|
base::take(_messages);
|
||||||
base::take(_channelMessages);
|
base::take(_nonChannelMessages);
|
||||||
_messageByRandomId.clear();
|
_messageByRandomId.clear();
|
||||||
_sentMessagesData.clear();
|
_sentMessagesData.clear();
|
||||||
cSetRecentInlineBots(RecentInlineBots());
|
cSetRecentInlineBots(RecentInlineBots());
|
||||||
|
@ -1334,20 +1334,31 @@ rpl::producer<not_null<HistoryItem*>> Session::newItemAdded() const {
|
||||||
return _newItemAdded.events();
|
return _newItemAdded.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::changeMessageId(ChannelId channel, MsgId wasId, MsgId nowId) {
|
void Session::changeMessageId(PeerId peerId, MsgId wasId, MsgId nowId) {
|
||||||
const auto list = messagesListForInsert(channel);
|
const auto list = messagesListForInsert(peerId);
|
||||||
auto i = list->find(wasId);
|
auto i = list->find(wasId);
|
||||||
Assert(i != list->end());
|
Assert(i != list->end());
|
||||||
auto owned = std::move(i->second);
|
const auto item = i->second;
|
||||||
list->erase(i);
|
list->erase(i);
|
||||||
const auto [j, ok] = list->emplace(nowId, std::move(owned));
|
const auto [j, ok] = list->emplace(nowId, item);
|
||||||
|
|
||||||
|
if (!peerIsChannel(peerId)) {
|
||||||
|
if (IsServerMsgId(wasId)) {
|
||||||
|
const auto k = _nonChannelMessages.find(wasId);
|
||||||
|
Assert(k != end(_nonChannelMessages));
|
||||||
|
_nonChannelMessages.erase(k);
|
||||||
|
}
|
||||||
|
if (IsServerMsgId(nowId)) {
|
||||||
|
_nonChannelMessages.emplace(nowId, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ensures(ok);
|
Ensures(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::notifyItemIdChange(IdChange event) {
|
void Session::notifyItemIdChange(IdChange event) {
|
||||||
const auto item = event.item;
|
const auto item = event.item;
|
||||||
changeMessageId(item->history()->channelId(), event.oldId, item->id);
|
changeMessageId(item->history()->peer->id, event.oldId, item->id);
|
||||||
|
|
||||||
_itemIdChanges.fire_copy(event);
|
_itemIdChanges.fire_copy(event);
|
||||||
|
|
||||||
|
@ -1797,7 +1808,7 @@ void Session::reorderTwoPinnedChats(
|
||||||
|
|
||||||
bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
|
bool Session::checkEntitiesAndViewsUpdate(const MTPDmessage &data) {
|
||||||
const auto peer = peerFromMTP(data.vpeer_id());
|
const auto peer = peerFromMTP(data.vpeer_id());
|
||||||
const auto existing = message(peerToChannel(peer), data.vid().v);
|
const auto existing = message(peer, data.vid().v);
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1817,8 +1828,7 @@ void Session::updateEditedMessage(const MTPMessage &data) {
|
||||||
-> HistoryItem* {
|
-> HistoryItem* {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}, [&](const auto &data) {
|
}, [&](const auto &data) {
|
||||||
const auto peer = peerFromMTP(data.vpeer_id());
|
return message(peerFromMTP(data.vpeer_id()), data.vid().v);
|
||||||
return message(peerToChannel(peer), data.vid().v);
|
|
||||||
});
|
});
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
return;
|
return;
|
||||||
|
@ -1885,23 +1895,19 @@ void Session::processExistingMessages(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const Session::Messages *Session::messagesList(ChannelId channelId) const {
|
const Session::Messages *Session::messagesList(PeerId peerId) const {
|
||||||
if (channelId == NoChannel) {
|
const auto i = _messages.find(peerId);
|
||||||
return &_messages;
|
return (i != end(_messages)) ? &i->second : nullptr;
|
||||||
}
|
|
||||||
const auto i = _channelMessages.find(channelId);
|
|
||||||
return (i != end(_channelMessages)) ? &i->second : nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Session::messagesListForInsert(ChannelId channelId)
|
auto Session::messagesListForInsert(PeerId peerId)
|
||||||
-> not_null<Messages*> {
|
-> not_null<Messages*> {
|
||||||
return (channelId == NoChannel)
|
return &_messages[peerId];
|
||||||
? &_messages
|
|
||||||
: &_channelMessages[channelId];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::registerMessage(not_null<HistoryItem*> item) {
|
void Session::registerMessage(not_null<HistoryItem*> item) {
|
||||||
const auto list = messagesListForInsert(item->channelId());
|
const auto peerId = item->history()->peer->id;
|
||||||
|
const auto list = messagesListForInsert(peerId);
|
||||||
const auto itemId = item->id;
|
const auto itemId = item->id;
|
||||||
const auto i = list->find(itemId);
|
const auto i = list->find(itemId);
|
||||||
if (i != list->end()) {
|
if (i != list->end()) {
|
||||||
|
@ -1909,6 +1915,10 @@ void Session::registerMessage(not_null<HistoryItem*> item) {
|
||||||
i->second->destroy();
|
i->second->destroy();
|
||||||
}
|
}
|
||||||
list->emplace(itemId, item);
|
list->emplace(itemId, item);
|
||||||
|
|
||||||
|
if (!peerIsChannel(peerId) && IsServerMsgId(itemId)) {
|
||||||
|
_nonChannelMessages.emplace(itemId, item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::registerMessageTTL(TimeId when, not_null<HistoryItem*> item) {
|
void Session::registerMessageTTL(TimeId when, not_null<HistoryItem*> item) {
|
||||||
|
@ -1963,12 +1973,10 @@ void Session::checkTTLs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::processMessagesDeleted(
|
void Session::processMessagesDeleted(
|
||||||
ChannelId channelId,
|
PeerId peerId,
|
||||||
const QVector<MTPint> &data) {
|
const QVector<MTPint> &data) {
|
||||||
const auto list = messagesList(channelId);
|
const auto list = messagesList(peerId);
|
||||||
const auto affected = (channelId != NoChannel)
|
const auto affected = historyLoaded(peerId);
|
||||||
? historyLoaded(peerFromChannel(channelId))
|
|
||||||
: nullptr;
|
|
||||||
if (!list && !affected) {
|
if (!list && !affected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1991,6 +1999,22 @@ void Session::processMessagesDeleted(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Session::processNonChannelMessagesDeleted(const QVector<MTPint> &data) {
|
||||||
|
auto historiesToCheck = base::flat_set<not_null<History*>>();
|
||||||
|
for (const auto &messageId : data) {
|
||||||
|
if (const auto item = nonChannelMessage(messageId.v)) {
|
||||||
|
const auto history = item->history();
|
||||||
|
item->destroy();
|
||||||
|
if (!history->chatListMessageKnown()) {
|
||||||
|
historiesToCheck.emplace(history);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &history : historiesToCheck) {
|
||||||
|
history->requestChatListMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Session::removeDependencyMessage(not_null<HistoryItem*> item) {
|
void Session::removeDependencyMessage(not_null<HistoryItem*> item) {
|
||||||
const auto i = _dependentMessages.find(item);
|
const auto i = _dependentMessages.find(item);
|
||||||
if (i == end(_dependentMessages)) {
|
if (i == end(_dependentMessages)) {
|
||||||
|
@ -2006,13 +2030,18 @@ void Session::removeDependencyMessage(not_null<HistoryItem*> item) {
|
||||||
|
|
||||||
void Session::unregisterMessage(not_null<HistoryItem*> item) {
|
void Session::unregisterMessage(not_null<HistoryItem*> item) {
|
||||||
const auto peerId = item->history()->peer->id;
|
const auto peerId = item->history()->peer->id;
|
||||||
|
const auto itemId = item->id;
|
||||||
_itemRemoved.fire_copy(item);
|
_itemRemoved.fire_copy(item);
|
||||||
session().changes().messageUpdated(
|
session().changes().messageUpdated(
|
||||||
item,
|
item,
|
||||||
Data::MessageUpdate::Flag::Destroyed);
|
Data::MessageUpdate::Flag::Destroyed);
|
||||||
groups().unregisterMessage(item);
|
groups().unregisterMessage(item);
|
||||||
removeDependencyMessage(item);
|
removeDependencyMessage(item);
|
||||||
messagesListForInsert(peerToChannel(peerId))->erase(item->id);
|
messagesListForInsert(peerId)->erase(itemId);
|
||||||
|
|
||||||
|
if (!peerIsChannel(peerId) && IsServerMsgId(itemId)) {
|
||||||
|
_nonChannelMessages.erase(itemId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MsgId Session::nextLocalMessageId() {
|
MsgId Session::nextLocalMessageId() {
|
||||||
|
@ -2035,12 +2064,12 @@ bool Session::suggestToGigagroup(not_null<ChannelData*> group) const {
|
||||||
return _suggestToGigagroup.contains(group);
|
return _suggestToGigagroup.contains(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *Session::message(ChannelId channelId, MsgId itemId) const {
|
HistoryItem *Session::message(PeerId peerId, MsgId itemId) const {
|
||||||
if (!itemId) {
|
if (!itemId) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto data = messagesList(channelId);
|
const auto data = messagesList(peerId);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -2050,13 +2079,21 @@ HistoryItem *Session::message(ChannelId channelId, MsgId itemId) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *Session::message(
|
HistoryItem *Session::message(
|
||||||
const ChannelData *channel,
|
not_null<const PeerData*> peer,
|
||||||
MsgId itemId) const {
|
MsgId itemId) const {
|
||||||
return message(channel ? peerToChannel(channel->id) : 0, itemId);
|
return message(peer->id, itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *Session::message(FullMsgId itemId) const {
|
HistoryItem *Session::message(FullMsgId itemId) const {
|
||||||
return message(itemId.channel, itemId.msg);
|
return message(itemId.peer, itemId.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
HistoryItem *Session::nonChannelMessage(MsgId itemId) const {
|
||||||
|
if (!IsServerMsgId(itemId)) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
const auto i = _nonChannelMessages.find(itemId);
|
||||||
|
return (i != end(_nonChannelMessages)) ? i->second.get() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::updateDependentMessages(not_null<HistoryItem*> item) {
|
void Session::updateDependentMessages(not_null<HistoryItem*> item) {
|
||||||
|
|
|
@ -348,19 +348,22 @@ public:
|
||||||
void processExistingMessages(
|
void processExistingMessages(
|
||||||
ChannelData *channel,
|
ChannelData *channel,
|
||||||
const MTPmessages_Messages &data);
|
const MTPmessages_Messages &data);
|
||||||
|
void processNonChannelMessagesDeleted(const QVector<MTPint> &data);
|
||||||
void processMessagesDeleted(
|
void processMessagesDeleted(
|
||||||
ChannelId channelId,
|
PeerId peerId,
|
||||||
const QVector<MTPint> &data);
|
const QVector<MTPint> &data);
|
||||||
|
|
||||||
[[nodiscard]] MsgId nextLocalMessageId();
|
[[nodiscard]] MsgId nextLocalMessageId();
|
||||||
[[nodiscard]] HistoryItem *message(
|
[[nodiscard]] HistoryItem *message(
|
||||||
ChannelId channelId,
|
PeerId peerId,
|
||||||
MsgId itemId) const;
|
MsgId itemId) const;
|
||||||
[[nodiscard]] HistoryItem *message(
|
[[nodiscard]] HistoryItem *message(
|
||||||
const ChannelData *channel,
|
not_null<const PeerData*> peer,
|
||||||
MsgId itemId) const;
|
MsgId itemId) const;
|
||||||
[[nodiscard]] HistoryItem *message(FullMsgId itemId) const;
|
[[nodiscard]] HistoryItem *message(FullMsgId itemId) const;
|
||||||
|
|
||||||
|
[[nodiscard]] HistoryItem *nonChannelMessage(MsgId itemId) const;
|
||||||
|
|
||||||
void updateDependentMessages(not_null<HistoryItem*> item);
|
void updateDependentMessages(not_null<HistoryItem*> item);
|
||||||
void registerDependentMessage(
|
void registerDependentMessage(
|
||||||
not_null<HistoryItem*> dependent,
|
not_null<HistoryItem*> dependent,
|
||||||
|
@ -698,11 +701,11 @@ private:
|
||||||
Data::Folder *requestFolder,
|
Data::Folder *requestFolder,
|
||||||
const MTPDdialogFolder &data);
|
const MTPDdialogFolder &data);
|
||||||
|
|
||||||
const Messages *messagesList(ChannelId channelId) const;
|
const Messages *messagesList(PeerId peerId) const;
|
||||||
not_null<Messages*> messagesListForInsert(ChannelId channelId);
|
not_null<Messages*> messagesListForInsert(PeerId peerId);
|
||||||
not_null<HistoryItem*> registerMessage(
|
not_null<HistoryItem*> registerMessage(
|
||||||
std::unique_ptr<HistoryItem> item);
|
std::unique_ptr<HistoryItem> item);
|
||||||
void changeMessageId(ChannelId channel, MsgId wasId, MsgId nowId);
|
void changeMessageId(PeerId peerId, MsgId wasId, MsgId nowId);
|
||||||
void removeDependencyMessage(not_null<HistoryItem*> item);
|
void removeDependencyMessage(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
void photoApplyFields(
|
void photoApplyFields(
|
||||||
|
@ -848,14 +851,15 @@ private:
|
||||||
Dialogs::IndexedList _contactsNoChatsList;
|
Dialogs::IndexedList _contactsNoChatsList;
|
||||||
|
|
||||||
MsgId _localMessageIdCounter = StartClientMsgId;
|
MsgId _localMessageIdCounter = StartClientMsgId;
|
||||||
Messages _messages;
|
std::unordered_map<PeerId, Messages> _messages;
|
||||||
std::map<ChannelId, Messages> _channelMessages;
|
|
||||||
std::map<
|
std::map<
|
||||||
not_null<HistoryItem*>,
|
not_null<HistoryItem*>,
|
||||||
base::flat_set<not_null<HistoryItem*>>> _dependentMessages;
|
base::flat_set<not_null<HistoryItem*>>> _dependentMessages;
|
||||||
std::map<TimeId, base::flat_set<not_null<HistoryItem*>>> _ttlMessages;
|
std::map<TimeId, base::flat_set<not_null<HistoryItem*>>> _ttlMessages;
|
||||||
base::Timer _ttlCheckTimer;
|
base::Timer _ttlCheckTimer;
|
||||||
|
|
||||||
|
std::unordered_map<MsgId, not_null<HistoryItem*>> _nonChannelMessages;
|
||||||
|
|
||||||
base::flat_map<uint64, FullMsgId> _messageByRandomId;
|
base::flat_map<uint64, FullMsgId> _messageByRandomId;
|
||||||
base::flat_map<uint64, SentData> _sentMessagesData;
|
base::flat_map<uint64, SentData> _sentMessagesData;
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,7 @@ std::optional<int> SharedMediaWithLastSlice::indexOf(Value value) const {
|
||||||
? QString::number(*_ending->skippedAfter())
|
? QString::number(*_ending->skippedAfter())
|
||||||
: QString("-"));
|
: QString("-"));
|
||||||
if (const auto msgId = std::get_if<FullMsgId>(&value)) {
|
if (const auto msgId = std::get_if<FullMsgId>(&value)) {
|
||||||
info.push_back("value:" + QString::number(msgId->channel.bare));
|
info.push_back("value:" + QString::number(msgId->peer.value));
|
||||||
info.push_back(QString::number(msgId->msg.bare));
|
info.push_back(QString::number(msgId->msg.bare));
|
||||||
const auto index = _slice.indexOf(*std::get_if<FullMsgId>(&value));
|
const auto index = _slice.indexOf(*std::get_if<FullMsgId>(&value));
|
||||||
info.push_back("index:" + (index
|
info.push_back("index:" + (index
|
||||||
|
|
|
@ -164,7 +164,7 @@ private:
|
||||||
return (a && b) ? base::make_optional(*a + *b) : std::nullopt;
|
return (a && b) ? base::make_optional(*a + *b) : std::nullopt;
|
||||||
}
|
}
|
||||||
static Value ComputeId(PeerId peerId, MsgId msgId) {
|
static Value ComputeId(PeerId peerId, MsgId msgId) {
|
||||||
return FullMsgId(peerToChannel(peerId), msgId);
|
return FullMsgId(peerId, msgId);
|
||||||
}
|
}
|
||||||
static Value ComputeId(const Key &key) {
|
static Value ComputeId(const Key &key) {
|
||||||
if (const auto messageId = std::get_if<MessageId>(&key.universalId)) {
|
if (const auto messageId = std::get_if<MessageId>(&key.universalId)) {
|
||||||
|
|
|
@ -100,12 +100,10 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsFromSlice(PeerId peerId, FullMsgId fullId) {
|
static bool IsFromSlice(PeerId peerId, FullMsgId fullId) {
|
||||||
return peerIsChannel(peerId)
|
return (peerId == fullId.peer);
|
||||||
? (peerId == peerFromChannel(fullId.channel))
|
|
||||||
: !fullId.channel;
|
|
||||||
}
|
}
|
||||||
static FullMsgId ComputeId(PeerId peerId, MsgId msgId) {
|
static FullMsgId ComputeId(PeerId peerId, MsgId msgId) {
|
||||||
return FullMsgId(peerToChannel(peerId), msgId);
|
return FullMsgId(peerId, msgId);
|
||||||
}
|
}
|
||||||
static FullMsgId ComputeId(const Key &key) {
|
static FullMsgId ComputeId(const Key &key) {
|
||||||
return (key.universalId >= 0)
|
return (key.universalId >= 0)
|
||||||
|
|
|
@ -72,7 +72,7 @@ bool SponsoredMessages::append(not_null<History*> history) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto flags = MessageFlags(0)
|
const auto flags = MessageFlags(0)
|
||||||
| (history->isChannel() ? MessageFlag::Post : MessageFlags(0))
|
| (history->peer->isChannel() ? MessageFlag::Post : MessageFlags(0))
|
||||||
| MessageFlag::HasFromId
|
| MessageFlag::HasFromId
|
||||||
| MessageFlag::IsSponsored
|
| MessageFlag::IsSponsored
|
||||||
| MessageFlag::Local;
|
| MessageFlag::Local;
|
||||||
|
@ -93,7 +93,7 @@ bool SponsoredMessages::append(not_null<History*> history) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
|
bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
|
||||||
return history->isChannel();
|
return history->peer->isChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SponsoredMessages::request(not_null<History*> history) {
|
void SponsoredMessages::request(not_null<History*> history) {
|
||||||
|
@ -189,11 +189,10 @@ void SponsoredMessages::clearItems(not_null<History*> history) {
|
||||||
|
|
||||||
const SponsoredMessages::Entry *SponsoredMessages::find(
|
const SponsoredMessages::Entry *SponsoredMessages::find(
|
||||||
const FullMsgId &fullId) const {
|
const FullMsgId &fullId) const {
|
||||||
if (!fullId.channel) {
|
if (!peerIsChannel(fullId.peer)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
const auto history = _session->data().history(
|
const auto history = _session->data().history(fullId.peer);
|
||||||
peerFromChannel(fullId.channel));
|
|
||||||
const auto it = _data.find(history);
|
const auto it = _data.find(history);
|
||||||
if (it == end(_data)) {
|
if (it == end(_data)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -695,7 +695,7 @@ bool InnerWidget::isSearchResultActive(
|
||||||
const auto peer = item->history()->peer;
|
const auto peer = item->history()->peer;
|
||||||
return (item->fullId() == entry.fullId)
|
return (item->fullId() == entry.fullId)
|
||||||
|| (peer->migrateTo()
|
|| (peer->migrateTo()
|
||||||
&& (peerToChannel(peer->migrateTo()->id) == entry.fullId.channel)
|
&& (peer->migrateTo()->id == entry.fullId.peer)
|
||||||
&& (item->id == -entry.fullId.msg))
|
&& (item->id == -entry.fullId.msg))
|
||||||
|| (uniqueSearchResults() && peer == entry.key.peer());
|
|| (uniqueSearchResults() && peer == entry.key.peer());
|
||||||
}
|
}
|
||||||
|
@ -1552,7 +1552,7 @@ void InnerWidget::updateDialogRow(
|
||||||
if (const auto migrated = from->owner().historyLoaded(from)) {
|
if (const auto migrated = from->owner().historyLoaded(from)) {
|
||||||
row = RowDescriptor(
|
row = RowDescriptor(
|
||||||
migrated,
|
migrated,
|
||||||
FullMsgId(0, -row.fullId.msg));
|
FullMsgId(from->id, -row.fullId.msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2712,7 +2712,7 @@ RowDescriptor InnerWidget::chatListEntryBefore(
|
||||||
if (i != list->cbegin()) {
|
if (i != list->cbegin()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
(*(i - 1))->key(),
|
(*(i - 1))->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RowDescriptor();
|
return RowDescriptor();
|
||||||
|
@ -2738,11 +2738,11 @@ RowDescriptor InnerWidget::chatListEntryBefore(
|
||||||
}
|
}
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
_filterResults.back()->key(),
|
_filterResults.back()->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
session().data().history(_peerSearchResults.back()->peer),
|
session().data().history(_peerSearchResults.back()->peer),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_peerSearchResults.empty()
|
if (!_peerSearchResults.empty()
|
||||||
|
@ -2752,14 +2752,14 @@ RowDescriptor InnerWidget::chatListEntryBefore(
|
||||||
}
|
}
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
_filterResults.back()->key(),
|
_filterResults.back()->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
if (!_peerSearchResults.empty()) {
|
if (!_peerSearchResults.empty()) {
|
||||||
for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) {
|
for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) {
|
||||||
if ((*i)->peer == whichHistory->peer) {
|
if ((*i)->peer == whichHistory->peer) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
session().data().history((*(i - 1))->peer),
|
session().data().history((*(i - 1))->peer),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2771,7 +2771,7 @@ RowDescriptor InnerWidget::chatListEntryBefore(
|
||||||
if ((*i)->key() == which.key) {
|
if ((*i)->key() == which.key) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
(*(i - 1))->key(),
|
(*(i - 1))->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RowDescriptor();
|
return RowDescriptor();
|
||||||
|
@ -2789,7 +2789,7 @@ RowDescriptor InnerWidget::chatListEntryAfter(
|
||||||
if (i != list->cend()) {
|
if (i != list->cend()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
(*i)->key(),
|
(*i)->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RowDescriptor();
|
return RowDescriptor();
|
||||||
|
@ -2815,7 +2815,7 @@ RowDescriptor InnerWidget::chatListEntryAfter(
|
||||||
if (i != e) {
|
if (i != e) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
session().data().history((*i)->peer),
|
session().data().history((*i)->peer),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
} else if (!_searchResults.empty()) {
|
} else if (!_searchResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
_searchResults.front()->item()->history(),
|
_searchResults.front()->item()->history(),
|
||||||
|
@ -2830,11 +2830,11 @@ RowDescriptor InnerWidget::chatListEntryAfter(
|
||||||
if (i != e) {
|
if (i != e) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
(*i)->key(),
|
(*i)->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
} else if (!_peerSearchResults.empty()) {
|
} else if (!_peerSearchResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
session().data().history(_peerSearchResults.front()->peer),
|
session().data().history(_peerSearchResults.front()->peer),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
} else if (!_searchResults.empty()) {
|
} else if (!_searchResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
_searchResults.front()->item()->history(),
|
_searchResults.front()->item()->history(),
|
||||||
|
@ -2853,17 +2853,17 @@ RowDescriptor InnerWidget::chatListEntryFirst() const {
|
||||||
if (i != list->cend()) {
|
if (i != list->cend()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
(*i)->key(),
|
(*i)->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
return RowDescriptor();
|
return RowDescriptor();
|
||||||
} else if (!_filterResults.empty()) {
|
} else if (!_filterResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
_filterResults.front()->key(),
|
_filterResults.front()->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
} else if (!_peerSearchResults.empty()) {
|
} else if (!_peerSearchResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
session().data().history(_peerSearchResults.front()->peer),
|
session().data().history(_peerSearchResults.front()->peer),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
} else if (!_searchResults.empty()) {
|
} else if (!_searchResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
_searchResults.front()->item()->history(),
|
_searchResults.front()->item()->history(),
|
||||||
|
@ -2879,7 +2879,7 @@ RowDescriptor InnerWidget::chatListEntryLast() const {
|
||||||
if (i != list->cbegin()) {
|
if (i != list->cbegin()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
(*(i - 1))->key(),
|
(*(i - 1))->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
return RowDescriptor();
|
return RowDescriptor();
|
||||||
} else if (!_searchResults.empty()) {
|
} else if (!_searchResults.empty()) {
|
||||||
|
@ -2889,11 +2889,11 @@ RowDescriptor InnerWidget::chatListEntryLast() const {
|
||||||
} else if (!_peerSearchResults.empty()) {
|
} else if (!_peerSearchResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
session().data().history(_peerSearchResults.back()->peer),
|
session().data().history(_peerSearchResults.back()->peer),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
} else if (!_filterResults.empty()) {
|
} else if (!_filterResults.empty()) {
|
||||||
return RowDescriptor(
|
return RowDescriptor(
|
||||||
_filterResults.back()->key(),
|
_filterResults.back()->key(),
|
||||||
FullMsgId(NoChannel, ShowAtUnreadMsgId));
|
FullMsgId(PeerId(), ShowAtUnreadMsgId));
|
||||||
}
|
}
|
||||||
return RowDescriptor();
|
return RowDescriptor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,7 +358,7 @@ not_null<ChannelData*> Widget::channel() const {
|
||||||
Dialogs::RowDescriptor Widget::activeChat() const {
|
Dialogs::RowDescriptor Widget::activeChat() const {
|
||||||
return {
|
return {
|
||||||
channel()->owner().history(channel()),
|
channel()->owner().history(channel()),
|
||||||
FullMsgId(peerToChannel(channel()->id), ShowAtUnreadMsgId)
|
FullMsgId(channel()->id, ShowAtUnreadMsgId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -366,7 +366,7 @@ not_null<HistoryItem*> History::createItem(
|
||||||
const MTPMessage &message,
|
const MTPMessage &message,
|
||||||
MessageFlags localFlags,
|
MessageFlags localFlags,
|
||||||
bool detachExistingItem) {
|
bool detachExistingItem) {
|
||||||
if (const auto result = owner().message(channelId(), id)) {
|
if (const auto result = owner().message(peer, id)) {
|
||||||
if (detachExistingItem) {
|
if (detachExistingItem) {
|
||||||
result->removeMainView();
|
result->removeMainView();
|
||||||
}
|
}
|
||||||
|
@ -2174,7 +2174,7 @@ bool History::isReadyFor(MsgId msgId) {
|
||||||
}
|
}
|
||||||
return loadedAtBottom();
|
return loadedAtBottom();
|
||||||
}
|
}
|
||||||
const auto item = owner().message(channelId(), msgId);
|
const auto item = owner().message(peer, msgId);
|
||||||
return item && (item->history() == this) && item->mainView();
|
return item && (item->history() == this) && item->mainView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2446,15 +2446,15 @@ void History::setFakeChatListMessageFrom(const MTPmessages_Messages &data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void History::applyChatListGroup(
|
void History::applyChatListGroup(
|
||||||
ChannelId channelId,
|
PeerId dataPeerId,
|
||||||
const MTPmessages_Messages &data) {
|
const MTPmessages_Messages &data) {
|
||||||
if (!isEmpty()
|
if (!isEmpty()
|
||||||
|| !_chatListMessage
|
|| !_chatListMessage
|
||||||
|| !*_chatListMessage
|
|| !*_chatListMessage
|
||||||
|| (*_chatListMessage)->history()->channelId() != channelId
|
|
||||||
|| (*_chatListMessage)->history() != this
|
|| (*_chatListMessage)->history() != this
|
||||||
|| !_lastMessage
|
|| !_lastMessage
|
||||||
|| !*_lastMessage) {
|
|| !*_lastMessage
|
||||||
|
|| dataPeerId != peer->id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Apply loaded album as a last slice.
|
// Apply loaded album as a last slice.
|
||||||
|
@ -2463,7 +2463,7 @@ void History::applyChatListGroup(
|
||||||
items.reserve(messages.v.size());
|
items.reserve(messages.v.size());
|
||||||
for (const auto &message : messages.v) {
|
for (const auto &message : messages.v) {
|
||||||
const auto id = IdFromMessage(message);
|
const auto id = IdFromMessage(message);
|
||||||
if (const auto message = owner().message(channelId, id)) {
|
if (const auto message = owner().message(dataPeerId, id)) {
|
||||||
items.push_back(message);
|
items.push_back(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2584,7 +2584,7 @@ void History::applyDialog(
|
||||||
}
|
}
|
||||||
if (!channel->amCreator()) {
|
if (!channel->amCreator()) {
|
||||||
const auto topMessageId = FullMsgId(
|
const auto topMessageId = FullMsgId(
|
||||||
peerToChannel(channel->id),
|
channel->id,
|
||||||
data.vtop_message().v);
|
data.vtop_message().v);
|
||||||
if (const auto item = owner().message(topMessageId)) {
|
if (const auto item = owner().message(topMessageId)) {
|
||||||
if (item->date() <= channel->date) {
|
if (item->date() <= channel->date) {
|
||||||
|
@ -2719,9 +2719,7 @@ void History::applyDialogFields(
|
||||||
|
|
||||||
void History::applyDialogTopMessage(MsgId topMessageId) {
|
void History::applyDialogTopMessage(MsgId topMessageId) {
|
||||||
if (topMessageId) {
|
if (topMessageId) {
|
||||||
const auto itemId = FullMsgId(
|
const auto itemId = FullMsgId(peer->id, topMessageId);
|
||||||
channelId(),
|
|
||||||
topMessageId);
|
|
||||||
if (const auto item = owner().message(itemId)) {
|
if (const auto item = owner().message(itemId)) {
|
||||||
setLastServerMessage(item);
|
setLastServerMessage(item);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2826,18 +2824,6 @@ void History::forceFullResize() {
|
||||||
_flags |= Flag::f_has_pending_resized_items;
|
_flags |= Flag::f_has_pending_resized_items;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelId History::channelId() const {
|
|
||||||
return peerToChannel(peer->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool History::isChannel() const {
|
|
||||||
return peerIsChannel(peer->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool History::isMegagroup() const {
|
|
||||||
return peer->isMegagroup();
|
|
||||||
}
|
|
||||||
|
|
||||||
not_null<History*> History::migrateToOrMe() const {
|
not_null<History*> History::migrateToOrMe() const {
|
||||||
if (const auto to = peer->migrateTo()) {
|
if (const auto to = peer->migrateTo()) {
|
||||||
return owner().history(to);
|
return owner().history(to);
|
||||||
|
@ -2964,7 +2950,7 @@ void History::checkLocalMessages() {
|
||||||
insertMessageToBlocks(item);
|
insertMessageToBlocks(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isChannel()
|
if (peer->isChannel()
|
||||||
&& !_joinedMessage
|
&& !_joinedMessage
|
||||||
&& peer->asChannel()->inviter
|
&& peer->asChannel()->inviter
|
||||||
&& goodDate(peer->asChannel()->inviteDate)) {
|
&& goodDate(peer->asChannel()->inviteDate)) {
|
||||||
|
|
|
@ -83,16 +83,12 @@ public:
|
||||||
History &operator=(const History &) = delete;
|
History &operator=(const History &) = delete;
|
||||||
~History();
|
~History();
|
||||||
|
|
||||||
ChannelId channelId() const;
|
|
||||||
bool isChannel() const;
|
|
||||||
bool isMegagroup() const;
|
|
||||||
not_null<History*> migrateToOrMe() const;
|
not_null<History*> migrateToOrMe() const;
|
||||||
History *migrateFrom() const;
|
History *migrateFrom() const;
|
||||||
MsgRange rangeForDifferenceRequest() const;
|
MsgRange rangeForDifferenceRequest() const;
|
||||||
void checkLocalMessages();
|
void checkLocalMessages();
|
||||||
void removeJoinedMessage();
|
void removeJoinedMessage();
|
||||||
|
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
bool isDisplayedEmpty() const;
|
bool isDisplayedEmpty() const;
|
||||||
Element *findFirstNonEmpty() const;
|
Element *findFirstNonEmpty() const;
|
||||||
|
@ -411,7 +407,7 @@ public:
|
||||||
void checkChatListMessageRemoved(not_null<HistoryItem*> item);
|
void checkChatListMessageRemoved(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
void applyChatListGroup(
|
void applyChatListGroup(
|
||||||
ChannelId channelId,
|
PeerId dataPeerId,
|
||||||
const MTPmessages_Messages &data);
|
const MTPmessages_Messages &data);
|
||||||
|
|
||||||
void forgetScrollState() {
|
void forgetScrollState() {
|
||||||
|
|
|
@ -2892,7 +2892,9 @@ MessageIdsList HistoryInner::getSelectedItems() const {
|
||||||
}) | to_vector;
|
}) | to_vector;
|
||||||
|
|
||||||
result |= actions::sort(less{}, [](const FullMsgId &msgId) {
|
result |= actions::sort(less{}, [](const FullMsgId &msgId) {
|
||||||
return msgId.channel ? msgId.msg : (msgId.msg - ServerMaxMsgId);
|
return peerIsChannel(msgId.peer)
|
||||||
|
? msgId.msg
|
||||||
|
: (msgId.msg - ServerMaxMsgId);
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ HistoryItem *HistoryItem::lookupDiscussionPostOriginal() const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return _history->owner().message(
|
return _history->owner().message(
|
||||||
forwarded->savedFromPeer->asChannel(),
|
forwarded->savedFromPeer->id,
|
||||||
forwarded->savedFromMsgId);
|
forwarded->savedFromMsgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,8 +745,8 @@ bool HistoryItem::hasDirectLink() const {
|
||||||
return isRegular() && _history->peer->isChannel();
|
return isRegular() && _history->peer->isChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelId HistoryItem::channelId() const {
|
FullMsgId HistoryItem::fullId() const {
|
||||||
return _history->channelId();
|
return FullMsgId(_history->peer->id, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Data::MessagePosition HistoryItem::position() const {
|
Data::MessagePosition HistoryItem::position() const {
|
||||||
|
|
|
@ -391,10 +391,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool hasDirectLink() const;
|
[[nodiscard]] bool hasDirectLink() const;
|
||||||
|
|
||||||
[[nodiscard]] ChannelId channelId() const;
|
[[nodiscard]] FullMsgId fullId() const;
|
||||||
[[nodiscard]] FullMsgId fullId() const {
|
|
||||||
return FullMsgId(channelId(), id);
|
|
||||||
}
|
|
||||||
[[nodiscard]] Data::MessagePosition position() const;
|
[[nodiscard]] Data::MessagePosition position() const;
|
||||||
[[nodiscard]] TimeId date() const;
|
[[nodiscard]] TimeId date() const;
|
||||||
|
|
||||||
|
|
|
@ -236,8 +236,8 @@ bool HistoryMessageReply::updateData(
|
||||||
if (!replyToMsg) {
|
if (!replyToMsg) {
|
||||||
replyToMsg = holder->history()->owner().message(
|
replyToMsg = holder->history()->owner().message(
|
||||||
(replyToPeerId
|
(replyToPeerId
|
||||||
? peerToChannel(replyToPeerId)
|
? replyToPeerId
|
||||||
: holder->channelId()),
|
: holder->history()->peer->id),
|
||||||
replyToMsgId);
|
replyToMsgId);
|
||||||
if (replyToMsg) {
|
if (replyToMsg) {
|
||||||
if (replyToMsg->isEmpty()) {
|
if (replyToMsg->isEmpty()) {
|
||||||
|
|
|
@ -356,16 +356,15 @@ void RequestDependentMessageData(
|
||||||
const auto fullId = item->fullId();
|
const auto fullId = item->fullId();
|
||||||
const auto history = item->history();
|
const auto history = item->history();
|
||||||
const auto session = &history->session();
|
const auto session = &history->session();
|
||||||
|
const auto done = [=] {
|
||||||
|
if (const auto item = session->data().message(fullId)) {
|
||||||
|
item->updateDependencyItem();
|
||||||
|
}
|
||||||
|
};
|
||||||
history->session().api().requestMessageData(
|
history->session().api().requestMessageData(
|
||||||
(peerIsChannel(peerId)
|
(peerId ? history->owner().peer(peerId) : history->peer),
|
||||||
? history->owner().channel(peerToChannel(peerId)).get()
|
|
||||||
: history->peer->asChannel()),
|
|
||||||
msgId,
|
msgId,
|
||||||
[=](ChannelData *channel, MsgId msgId) {
|
done);
|
||||||
if (const auto item = session->data().message(fullId)) {
|
|
||||||
item->updateDependencyItem();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageFlags NewMessageFlags(not_null<PeerData*> peer) {
|
MessageFlags NewMessageFlags(not_null<PeerData*> peer) {
|
||||||
|
@ -384,7 +383,7 @@ bool ShouldSendSilent(
|
||||||
|
|
||||||
MsgId LookupReplyToTop(not_null<History*> history, MsgId replyToId) {
|
MsgId LookupReplyToTop(not_null<History*> history, MsgId replyToId) {
|
||||||
const auto &owner = history->owner();
|
const auto &owner = history->owner();
|
||||||
if (const auto item = owner.message(history->channelId(), replyToId)) {
|
if (const auto item = owner.message(history->peer, replyToId)) {
|
||||||
return item->replyToTop();
|
return item->replyToTop();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -977,25 +976,28 @@ bool HistoryMessage::areRepliesUnread() const {
|
||||||
|
|
||||||
FullMsgId HistoryMessage::commentsItemId() const {
|
FullMsgId HistoryMessage::commentsItemId() const {
|
||||||
if (const auto views = Get<HistoryMessageViews>()) {
|
if (const auto views = Get<HistoryMessageViews>()) {
|
||||||
return FullMsgId(views->commentsMegagroupId, views->commentsRootId);
|
return FullMsgId(
|
||||||
|
PeerId(views->commentsMegagroupId),
|
||||||
|
views->commentsRootId);
|
||||||
}
|
}
|
||||||
return FullMsgId();
|
return FullMsgId();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryMessage::setCommentsItemId(FullMsgId id) {
|
void HistoryMessage::setCommentsItemId(FullMsgId id) {
|
||||||
if (id.channel == _history->channelId()) {
|
if (id.peer == _history->peer->id) {
|
||||||
if (id.msg != this->id) {
|
if (id.msg != this->id) {
|
||||||
if (const auto reply = Get<HistoryMessageReply>()) {
|
if (const auto reply = Get<HistoryMessageReply>()) {
|
||||||
reply->replyToMsgTop = id.msg;
|
reply->replyToMsgTop = id.msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
} else if (const auto views = Get<HistoryMessageViews>()) {
|
} else if (const auto views = Get<HistoryMessageViews>()) {
|
||||||
if (views->commentsMegagroupId != id.channel) {
|
if (const auto channelId = peerToChannel(id.peer)) {
|
||||||
views->commentsMegagroupId = id.channel;
|
if (views->commentsMegagroupId != channelId) {
|
||||||
history()->owner().requestItemResize(this);
|
views->commentsMegagroupId = channelId;
|
||||||
|
history()->owner().requestItemResize(this);
|
||||||
|
}
|
||||||
|
views->commentsRootId = id.msg;
|
||||||
}
|
}
|
||||||
views->commentsRootId = id.msg;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1966,13 +1968,11 @@ void HistoryMessage::changeReplyToTopCounter(
|
||||||
if (!isRegular() || !reply->replyToTop()) {
|
if (!isRegular() || !reply->replyToTop()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto channelId = history()->channelId();
|
const auto peerId = _history->peer->id;
|
||||||
if (!channelId) {
|
if (!peerIsChannel(peerId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto top = history()->owner().message(
|
const auto top = _history->owner().message(peerId, reply->replyToTop());
|
||||||
channelId,
|
|
||||||
reply->replyToTop());
|
|
||||||
if (!top) {
|
if (!top) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -605,8 +605,8 @@ bool HistoryService::updateDependent(bool force) {
|
||||||
if (!dependent->msg) {
|
if (!dependent->msg) {
|
||||||
dependent->msg = history()->owner().message(
|
dependent->msg = history()->owner().message(
|
||||||
(dependent->peerId
|
(dependent->peerId
|
||||||
? peerToChannel(dependent->peerId)
|
? dependent->peerId
|
||||||
: channelId()),
|
: _history->peer->id),
|
||||||
dependent->msgId);
|
dependent->msgId);
|
||||||
if (dependent->msg) {
|
if (dependent->msg) {
|
||||||
if (dependent->msg->isEmpty()) {
|
if (dependent->msg->isEmpty()) {
|
||||||
|
@ -1245,14 +1245,14 @@ HistoryService::PreparedText GenerateJoinedText(
|
||||||
if (inviter->id != history->session().userPeerId()) {
|
if (inviter->id != history->session().userPeerId()) {
|
||||||
auto result = HistoryService::PreparedText{};
|
auto result = HistoryService::PreparedText{};
|
||||||
result.links.push_back(inviter->createOpenLink());
|
result.links.push_back(inviter->createOpenLink());
|
||||||
result.text = (history->isMegagroup()
|
result.text = (history->peer->isMegagroup()
|
||||||
? tr::lng_action_add_you_group
|
? tr::lng_action_add_you_group
|
||||||
: tr::lng_action_add_you)(
|
: tr::lng_action_add_you)(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_from,
|
lt_from,
|
||||||
textcmdLink(1, inviter->name));
|
textcmdLink(1, inviter->name));
|
||||||
return result;
|
return result;
|
||||||
} else if (history->isMegagroup()) {
|
} else if (history->peer->isMegagroup()) {
|
||||||
if (viaRequest) {
|
if (viaRequest) {
|
||||||
return { tr::lng_action_you_joined_by_request(tr::now) };
|
return { tr::lng_action_you_joined_by_request(tr::now) };
|
||||||
}
|
}
|
||||||
|
|
|
@ -777,7 +777,7 @@ HistoryWidget::HistoryWidget(
|
||||||
return (action.history == _history);
|
return (action.history == _history);
|
||||||
}) | rpl::start_with_next([=](const Api::SendAction &action) {
|
}) | rpl::start_with_next([=](const Api::SendAction &action) {
|
||||||
const auto lastKeyboardUsed = lastForceReplyReplied(FullMsgId(
|
const auto lastKeyboardUsed = lastForceReplyReplied(FullMsgId(
|
||||||
action.history->channelId(),
|
action.history->peer->id,
|
||||||
action.replyTo));
|
action.replyTo));
|
||||||
if (action.options.scheduled) {
|
if (action.options.scheduled) {
|
||||||
cancelReply(lastKeyboardUsed);
|
cancelReply(lastKeyboardUsed);
|
||||||
|
@ -1088,7 +1088,7 @@ void HistoryWidget::animatedScrollToItem(MsgId msgId) {
|
||||||
updateListSize();
|
updateListSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto to = session().data().message(_channel, msgId);
|
auto to = session().data().message(_history->peer, msgId);
|
||||||
if (_list->itemTop(to) < 0) {
|
if (_list->itemTop(to) < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1767,18 +1767,22 @@ void HistoryWidget::setReplyReturns(PeerId peer, const QList<MsgId> &replyReturn
|
||||||
if (_replyReturns.isEmpty()) {
|
if (_replyReturns.isEmpty()) {
|
||||||
_replyReturn = nullptr;
|
_replyReturn = nullptr;
|
||||||
} else if (_replyReturns.back() < 0 && -_replyReturns.back() < ServerMaxMsgId) {
|
} else if (_replyReturns.back() < 0 && -_replyReturns.back() < ServerMaxMsgId) {
|
||||||
_replyReturn = session().data().message(0, -_replyReturns.back());
|
_replyReturn = _migrated
|
||||||
|
? session().data().message(_migrated->peer, -_replyReturns.back())
|
||||||
|
: nullptr;
|
||||||
} else {
|
} else {
|
||||||
_replyReturn = session().data().message(_channel, _replyReturns.back());
|
_replyReturn = session().data().message(peer, _replyReturns.back());
|
||||||
}
|
}
|
||||||
while (!_replyReturns.isEmpty() && !_replyReturn) {
|
while (!_replyReturns.isEmpty() && !_replyReturn) {
|
||||||
_replyReturns.pop_back();
|
_replyReturns.pop_back();
|
||||||
if (_replyReturns.isEmpty()) {
|
if (_replyReturns.isEmpty()) {
|
||||||
_replyReturn = nullptr;
|
_replyReturn = nullptr;
|
||||||
} else if (_replyReturns.back() < 0 && -_replyReturns.back() < ServerMaxMsgId) {
|
} else if (_replyReturns.back() < 0 && -_replyReturns.back() < ServerMaxMsgId) {
|
||||||
_replyReturn = session().data().message(0, -_replyReturns.back());
|
_replyReturn = _migrated
|
||||||
|
? session().data().message(_migrated->peer, -_replyReturns.back())
|
||||||
|
: nullptr;
|
||||||
} else {
|
} else {
|
||||||
_replyReturn = session().data().message(_channel, _replyReturns.back());
|
_replyReturn = session().data().message(peer, _replyReturns.back());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1790,9 +1794,13 @@ void HistoryWidget::calcNextReplyReturn() {
|
||||||
if (_replyReturns.isEmpty()) {
|
if (_replyReturns.isEmpty()) {
|
||||||
_replyReturn = nullptr;
|
_replyReturn = nullptr;
|
||||||
} else if (_replyReturns.back() < 0 && -_replyReturns.back() < ServerMaxMsgId) {
|
} else if (_replyReturns.back() < 0 && -_replyReturns.back() < ServerMaxMsgId) {
|
||||||
_replyReturn = session().data().message(0, -_replyReturns.back());
|
_replyReturn = _migrated
|
||||||
|
? session().data().message(_migrated->peer, -_replyReturns.back())
|
||||||
|
: nullptr;
|
||||||
} else {
|
} else {
|
||||||
_replyReturn = session().data().message(_channel, _replyReturns.back());
|
_replyReturn = _peer
|
||||||
|
? session().data().message(_peer, _replyReturns.back())
|
||||||
|
: nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_replyReturn) {
|
if (!_replyReturn) {
|
||||||
|
@ -2026,7 +2034,6 @@ void HistoryWidget::showHistory(
|
||||||
setHistory(nullptr);
|
setHistory(nullptr);
|
||||||
_list = nullptr;
|
_list = nullptr;
|
||||||
_peer = nullptr;
|
_peer = nullptr;
|
||||||
_channel = NoChannel;
|
|
||||||
_canSendMessages = false;
|
_canSendMessages = false;
|
||||||
_silent.destroy();
|
_silent.destroy();
|
||||||
updateBotKeyboard();
|
updateBotKeyboard();
|
||||||
|
@ -2057,7 +2064,6 @@ void HistoryWidget::showHistory(
|
||||||
|
|
||||||
if (peerId) {
|
if (peerId) {
|
||||||
_peer = session().data().peer(peerId);
|
_peer = session().data().peer(peerId);
|
||||||
_channel = peerToChannel(_peer->id);
|
|
||||||
_canSendMessages = _peer->canWrite();
|
_canSendMessages = _peer->canWrite();
|
||||||
_contactStatus = std::make_unique<HistoryView::ContactStatus>(
|
_contactStatus = std::make_unique<HistoryView::ContactStatus>(
|
||||||
controller(),
|
controller(),
|
||||||
|
@ -2110,7 +2116,7 @@ void HistoryWidget::showHistory(
|
||||||
refreshTopBarActiveChat();
|
refreshTopBarActiveChat();
|
||||||
updateTopBarSelection();
|
updateTopBarSelection();
|
||||||
|
|
||||||
if (_channel) {
|
if (_peer->isChannel()) {
|
||||||
updateNotifyControls();
|
updateNotifyControls();
|
||||||
session().data().requestNotifySettings(_peer);
|
session().data().requestNotifySettings(_peer);
|
||||||
refreshSilentToggle();
|
refreshSilentToggle();
|
||||||
|
@ -2215,7 +2221,7 @@ void HistoryWidget::showHistory(
|
||||||
if (_history) {
|
if (_history) {
|
||||||
controller()->setActiveChatEntry({
|
controller()->setActiveChatEntry({
|
||||||
_history,
|
_history,
|
||||||
FullMsgId(_history->channelId(), _showAtMsgId) });
|
FullMsgId(_history->peer->id, _showAtMsgId) });
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
controller()->floatPlayerAreaUpdated();
|
controller()->floatPlayerAreaUpdated();
|
||||||
|
@ -2949,7 +2955,7 @@ void HistoryWidget::firstLoadMessages() {
|
||||||
_history->getReadyFor(_showAtMsgId);
|
_history->getReadyFor(_showAtMsgId);
|
||||||
offset = -loadCount / 2;
|
offset = -loadCount / 2;
|
||||||
offsetId = _showAtMsgId;
|
offsetId = _showAtMsgId;
|
||||||
} else if (_showAtMsgId < 0 && _history->isChannel()) {
|
} else if (_showAtMsgId < 0 && _history->peer->isChannel()) {
|
||||||
if (_showAtMsgId < 0 && -_showAtMsgId < ServerMaxMsgId && _migrated) {
|
if (_showAtMsgId < 0 && -_showAtMsgId < ServerMaxMsgId && _migrated) {
|
||||||
_history->getReadyFor(_showAtMsgId);
|
_history->getReadyFor(_showAtMsgId);
|
||||||
from = _migrated;
|
from = _migrated;
|
||||||
|
@ -3120,7 +3126,7 @@ void HistoryWidget::delayedShowAt(MsgId showAtMsgId) {
|
||||||
} else if (_delayedShowAtMsgId > 0) {
|
} else if (_delayedShowAtMsgId > 0) {
|
||||||
offset = -loadCount / 2;
|
offset = -loadCount / 2;
|
||||||
offsetId = _delayedShowAtMsgId;
|
offsetId = _delayedShowAtMsgId;
|
||||||
} else if (_delayedShowAtMsgId < 0 && _history->isChannel()) {
|
} else if (_delayedShowAtMsgId < 0 && _history->peer->isChannel()) {
|
||||||
if (_delayedShowAtMsgId < 0 && -_delayedShowAtMsgId < ServerMaxMsgId && _migrated) {
|
if (_delayedShowAtMsgId < 0 && -_delayedShowAtMsgId < ServerMaxMsgId && _migrated) {
|
||||||
from = _migrated;
|
from = _migrated;
|
||||||
offset = -loadCount / 2;
|
offset = -loadCount / 2;
|
||||||
|
@ -3307,7 +3313,7 @@ void HistoryWidget::showNextUnreadMention() {
|
||||||
// See https://github.com/telegramdesktop/tdesktop/issues/5623
|
// See https://github.com/telegramdesktop/tdesktop/issues/5623
|
||||||
if (msgId && already) {
|
if (msgId && already) {
|
||||||
const auto item = _history->owner().message(
|
const auto item = _history->owner().message(
|
||||||
_history->channelId(),
|
_history->peer->id,
|
||||||
msgId);
|
msgId);
|
||||||
if (const auto media = item ? item->media() : nullptr) {
|
if (const auto media = item ? item->media() : nullptr) {
|
||||||
if (const auto document = media->document()) {
|
if (const auto document = media->document()) {
|
||||||
|
@ -3329,7 +3335,7 @@ void HistoryWidget::saveEditMsg() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto item = session().data().message(_channel, _editMsgId);
|
const auto item = session().data().message(_history->peer, _editMsgId);
|
||||||
if (!item) {
|
if (!item) {
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
return;
|
return;
|
||||||
|
@ -3643,7 +3649,7 @@ void HistoryWidget::setMsgId(MsgId showAtMsgId) {
|
||||||
if (_history) {
|
if (_history) {
|
||||||
controller()->setActiveChatEntry({
|
controller()->setActiveChatEntry({
|
||||||
_history,
|
_history,
|
||||||
FullMsgId(_history->channelId(), _showAtMsgId) });
|
FullMsgId(_history->peer->id, _showAtMsgId) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3894,8 +3900,8 @@ void HistoryWidget::sendBotCommand(const Bot::SendCommandRequest &request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto lastKeyboardUsed = (_keyboard->forMsgId()
|
const auto lastKeyboardUsed = (_keyboard->forMsgId()
|
||||||
== FullMsgId(_channel, _history->lastKeyboardId))
|
== FullMsgId(_peer->id, _history->lastKeyboardId))
|
||||||
&& (_keyboard->forMsgId() == FullMsgId(_channel, request.replyTo));
|
&& (_keyboard->forMsgId() == FullMsgId(_peer->id, request.replyTo));
|
||||||
|
|
||||||
// 'bot' may be nullptr in case of sending from FieldAutocomplete.
|
// 'bot' may be nullptr in case of sending from FieldAutocomplete.
|
||||||
const auto toSend = (request.replyTo/* || !bot*/)
|
const auto toSend = (request.replyTo/* || !bot*/)
|
||||||
|
@ -3927,7 +3933,8 @@ void HistoryWidget::sendBotCommand(const Bot::SendCommandRequest &request) {
|
||||||
void HistoryWidget::hideSingleUseKeyboard(PeerData *peer, MsgId replyTo) {
|
void HistoryWidget::hideSingleUseKeyboard(PeerData *peer, MsgId replyTo) {
|
||||||
if (!_peer || _peer != peer) return;
|
if (!_peer || _peer != peer) return;
|
||||||
|
|
||||||
bool lastKeyboardUsed = (_keyboard->forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)) && (_keyboard->forMsgId() == FullMsgId(_channel, replyTo));
|
bool lastKeyboardUsed = (_keyboard->forMsgId() == FullMsgId(_peer->id, _history->lastKeyboardId))
|
||||||
|
&& (_keyboard->forMsgId() == FullMsgId(_peer->id, replyTo));
|
||||||
if (replyTo) {
|
if (replyTo) {
|
||||||
if (_replyToId == replyTo) {
|
if (_replyToId == replyTo) {
|
||||||
cancelReply();
|
cancelReply();
|
||||||
|
@ -4181,7 +4188,11 @@ bool HistoryWidget::updateCmdStartShown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::kbWasHidden() const {
|
bool HistoryWidget::kbWasHidden() const {
|
||||||
return _history && (_keyboard->forMsgId() == FullMsgId(_history->channelId(), _history->lastKeyboardHiddenId));
|
return _history
|
||||||
|
&& (_keyboard->forMsgId()
|
||||||
|
== FullMsgId(
|
||||||
|
_history->peer->id,
|
||||||
|
_history->lastKeyboardHiddenId));
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::toggleKeyboard(bool manual) {
|
void HistoryWidget::toggleKeyboard(bool manual) {
|
||||||
|
@ -5308,7 +5319,9 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
||||||
changed = _keyboard->updateMarkup(_replyEditMsg, force);
|
changed = _keyboard->updateMarkup(_replyEditMsg, force);
|
||||||
} else {
|
} else {
|
||||||
const auto keyboardItem = _history->lastKeyboardId
|
const auto keyboardItem = _history->lastKeyboardId
|
||||||
? session().data().message(_channel, _history->lastKeyboardId)
|
? session().data().message(
|
||||||
|
_history->peer,
|
||||||
|
_history->lastKeyboardId)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
changed = _keyboard->updateMarkup(keyboardItem, force);
|
changed = _keyboard->updateMarkup(keyboardItem, force);
|
||||||
}
|
}
|
||||||
|
@ -5319,7 +5332,11 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
||||||
|
|
||||||
bool hasMarkup = _keyboard->hasMarkup(), forceReply = _keyboard->forceReply() && (!_replyToId || !_replyEditMsg);
|
bool hasMarkup = _keyboard->hasMarkup(), forceReply = _keyboard->forceReply() && (!_replyToId || !_replyEditMsg);
|
||||||
if (hasMarkup || forceReply) {
|
if (hasMarkup || forceReply) {
|
||||||
if (_keyboard->singleUse() && _keyboard->hasMarkup() && _keyboard->forMsgId() == FullMsgId(_channel, _history->lastKeyboardId) && _history->lastKeyboardUsed) {
|
if (_keyboard->singleUse()
|
||||||
|
&& _keyboard->hasMarkup()
|
||||||
|
&& (_keyboard->forMsgId()
|
||||||
|
== FullMsgId(_history->peer->id, _history->lastKeyboardId))
|
||||||
|
&& _history->lastKeyboardUsed) {
|
||||||
_history->lastKeyboardHiddenId = _history->lastKeyboardId;
|
_history->lastKeyboardHiddenId = _history->lastKeyboardId;
|
||||||
}
|
}
|
||||||
if (!isBotStart() && !isBlocked() && _canSendMessages && (wasVisible || (_replyToId && _replyEditMsg) || (!HasSendText(_field) && !kbWasHidden()))) {
|
if (!isBotStart() && !isBlocked() && _canSendMessages && (wasVisible || (_replyToId && _replyEditMsg) || (!HasSendText(_field) && !kbWasHidden()))) {
|
||||||
|
@ -5391,8 +5408,8 @@ void HistoryWidget::botCallbackSent(not_null<HistoryItem*> item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto keyId = _keyboard->forMsgId();
|
const auto keyId = _keyboard->forMsgId();
|
||||||
const auto lastKeyboardUsed = (keyId == FullMsgId(_channel, item->id))
|
const auto lastKeyboardUsed = (keyId == FullMsgId(_peer->id, item->id))
|
||||||
&& (keyId == FullMsgId(_channel, _history->lastKeyboardId));
|
&& (keyId == FullMsgId(_peer->id, _history->lastKeyboardId));
|
||||||
|
|
||||||
session().data().requestItemRepaint(item);
|
session().data().requestItemRepaint(item);
|
||||||
|
|
||||||
|
@ -5706,9 +5723,7 @@ bool HistoryWidget::replyToPreviousMessage() {
|
||||||
if (!_history || _editMsgId) {
|
if (!_history || _editMsgId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto fullId = FullMsgId(
|
const auto fullId = FullMsgId(_history->peer->id, _replyToId);
|
||||||
_history->channelId(),
|
|
||||||
_replyToId);
|
|
||||||
if (const auto item = session().data().message(fullId)) {
|
if (const auto item = session().data().message(fullId)) {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
if (const auto previousView = view->previousDisplayedInBlocks()) {
|
if (const auto previousView = view->previousDisplayedInBlocks()) {
|
||||||
|
@ -5731,9 +5746,7 @@ bool HistoryWidget::replyToNextMessage() {
|
||||||
if (!_history || _editMsgId) {
|
if (!_history || _editMsgId) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto fullId = FullMsgId(
|
const auto fullId = FullMsgId(_history->peer->id, _replyToId);
|
||||||
_history->channelId(),
|
|
||||||
_replyToId);
|
|
||||||
if (const auto item = session().data().message(fullId)) {
|
if (const auto item = session().data().message(fullId)) {
|
||||||
if (const auto view = item->mainView()) {
|
if (const auto view = item->mainView()) {
|
||||||
if (const auto nextView = view->nextDisplayedInBlocks()) {
|
if (const auto nextView = view->nextDisplayedInBlocks()) {
|
||||||
|
@ -5841,7 +5854,7 @@ void HistoryWidget::updatePinnedViewer() {
|
||||||
: (view->data()->id + (offset > 0 ? 1 : 0));
|
: (view->data()->id + (offset > 0 ? 1 : 0));
|
||||||
const auto lastClickedId = !_pinnedClickedId
|
const auto lastClickedId = !_pinnedClickedId
|
||||||
? (ServerMaxMsgId - 1)
|
? (ServerMaxMsgId - 1)
|
||||||
: (!_migrated || _pinnedClickedId.channel)
|
: (!_migrated || peerIsChannel(_pinnedClickedId.peer))
|
||||||
? _pinnedClickedId.msg
|
? _pinnedClickedId.msg
|
||||||
: (_pinnedClickedId.msg - ServerMaxMsgId);
|
: (_pinnedClickedId.msg - ServerMaxMsgId);
|
||||||
if (_pinnedClickedId
|
if (_pinnedClickedId
|
||||||
|
@ -5899,7 +5912,7 @@ void HistoryWidget::checkPinnedBarState() {
|
||||||
_migrated ? _migrated->peer.get() : nullptr);
|
_migrated ? _migrated->peer.get() : nullptr);
|
||||||
const auto universalPinnedId = !currentPinnedId
|
const auto universalPinnedId = !currentPinnedId
|
||||||
? int32(0)
|
? int32(0)
|
||||||
: (_migrated && !currentPinnedId.channel)
|
: (_migrated && !peerIsChannel(currentPinnedId.peer))
|
||||||
? (currentPinnedId.msg - ServerMaxMsgId)
|
? (currentPinnedId.msg - ServerMaxMsgId)
|
||||||
: currentPinnedId.msg;
|
: currentPinnedId.msg;
|
||||||
if (universalPinnedId == hiddenId) {
|
if (universalPinnedId == hiddenId) {
|
||||||
|
@ -6046,7 +6059,7 @@ void HistoryWidget::refreshPinnedBarButton(bool many) {
|
||||||
controller()->showSection(
|
controller()->showSection(
|
||||||
std::make_shared<HistoryView::PinnedMemento>(
|
std::make_shared<HistoryView::PinnedMemento>(
|
||||||
_history,
|
_history,
|
||||||
((!_migrated || id.message.channel)
|
((!_migrated || peerIsChannel(id.message.peer))
|
||||||
? id.message.msg
|
? id.message.msg
|
||||||
: (id.message.msg - ServerMaxMsgId))));
|
: (id.message.msg - ServerMaxMsgId))));
|
||||||
}
|
}
|
||||||
|
@ -6154,13 +6167,14 @@ void HistoryWidget::setupRequestsBar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::requestMessageData(MsgId msgId) {
|
void HistoryWidget::requestMessageData(MsgId msgId) {
|
||||||
const auto callback = [=](ChannelData *channel, MsgId msgId) {
|
if (!_peer) {
|
||||||
messageDataReceived(channel, msgId);
|
return;
|
||||||
};
|
}
|
||||||
session().api().requestMessageData(
|
const auto peer = _peer;
|
||||||
_peer->asChannel(),
|
const auto callback = crl::guard(this, [=] {
|
||||||
msgId,
|
messageDataReceived(peer, msgId);
|
||||||
crl::guard(this, callback));
|
});
|
||||||
|
session().api().requestMessageData(_peer, msgId, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::sendExistingDocument(
|
bool HistoryWidget::sendExistingDocument(
|
||||||
|
@ -6437,17 +6451,17 @@ void HistoryWidget::hidePinnedMessage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::lastForceReplyReplied(const FullMsgId &replyTo) const {
|
bool HistoryWidget::lastForceReplyReplied(const FullMsgId &replyTo) const {
|
||||||
if (replyTo.channel != _channel) {
|
return _peer
|
||||||
return false;
|
&& (replyTo.peer == _peer->id)
|
||||||
}
|
&& _keyboard->forceReply()
|
||||||
return _keyboard->forceReply()
|
&& _keyboard->forMsgId() == FullMsgId(_peer->id, _history->lastKeyboardId)
|
||||||
&& _keyboard->forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)
|
|
||||||
&& _keyboard->forMsgId().msg == replyTo.msg;
|
&& _keyboard->forMsgId().msg == replyTo.msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::lastForceReplyReplied() const {
|
bool HistoryWidget::lastForceReplyReplied() const {
|
||||||
return _keyboard->forceReply()
|
return _peer
|
||||||
&& _keyboard->forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)
|
&& _keyboard->forceReply()
|
||||||
|
&& _keyboard->forMsgId() == FullMsgId(_peer->id, _history->lastKeyboardId)
|
||||||
&& _keyboard->forMsgId().msg == replyToId();
|
&& _keyboard->forMsgId().msg == replyToId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6840,10 +6854,11 @@ void HistoryWidget::clearSelected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *HistoryWidget::getItemFromHistoryOrMigrated(MsgId genericMsgId) const {
|
HistoryItem *HistoryWidget::getItemFromHistoryOrMigrated(MsgId genericMsgId) const {
|
||||||
if (genericMsgId < 0 && -genericMsgId < ServerMaxMsgId && _migrated) {
|
return (genericMsgId < 0 && -genericMsgId < ServerMaxMsgId && _migrated)
|
||||||
return session().data().message(_migrated->channelId(), -genericMsgId);
|
? session().data().message(_migrated->peer, -genericMsgId)
|
||||||
}
|
: _peer
|
||||||
return session().data().message(_channel, genericMsgId);
|
? session().data().message(_peer, genericMsgId)
|
||||||
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageIdsList HistoryWidget::getSelectedItems() const {
|
MessageIdsList HistoryWidget::getSelectedItems() const {
|
||||||
|
@ -6906,11 +6921,12 @@ void HistoryWidget::updateTopBarSelection() {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::messageDataReceived(ChannelData *channel, MsgId msgId) {
|
void HistoryWidget::messageDataReceived(
|
||||||
if (!_peer || _peer->asChannel() != channel || !msgId) {
|
not_null<PeerData*> peer,
|
||||||
|
MsgId msgId) {
|
||||||
|
if (!_peer || _peer != peer || !msgId) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (_editMsgId == msgId || _replyToId == msgId) {
|
||||||
if (_editMsgId == msgId || _replyToId == msgId) {
|
|
||||||
updateReplyEditTexts(true);
|
updateReplyEditTexts(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6932,8 +6948,10 @@ void HistoryWidget::updateReplyEditTexts(bool force) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!_replyEditMsg) {
|
if (!_replyEditMsg && _peer) {
|
||||||
_replyEditMsg = session().data().message(_channel, _editMsgId ? _editMsgId : _replyToId);
|
_replyEditMsg = session().data().message(
|
||||||
|
_peer->id,
|
||||||
|
_editMsgId ? _editMsgId : _replyToId);
|
||||||
}
|
}
|
||||||
if (_replyEditMsg) {
|
if (_replyEditMsg) {
|
||||||
updateReplyEditText(_replyEditMsg);
|
updateReplyEditText(_replyEditMsg);
|
||||||
|
|
|
@ -369,7 +369,7 @@ private:
|
||||||
void refreshTopBarActiveChat();
|
void refreshTopBarActiveChat();
|
||||||
|
|
||||||
void requestMessageData(MsgId msgId);
|
void requestMessageData(MsgId msgId);
|
||||||
void messageDataReceived(ChannelData *channel, MsgId msgId);
|
void messageDataReceived(not_null<PeerData*> peer, MsgId msgId);
|
||||||
|
|
||||||
[[nodiscard]] Api::SendAction prepareSendAction(
|
[[nodiscard]] Api::SendAction prepareSendAction(
|
||||||
Api::SendOptions options) const;
|
Api::SendOptions options) const;
|
||||||
|
@ -666,7 +666,6 @@ private:
|
||||||
|
|
||||||
PeerData *_peer = nullptr;
|
PeerData *_peer = nullptr;
|
||||||
|
|
||||||
ChannelId _channel = NoChannel;
|
|
||||||
bool _canSendMessages = false;
|
bool _canSendMessages = false;
|
||||||
MsgId _showAtMsgId = ShowAtUnreadMsgId;
|
MsgId _showAtMsgId = ShowAtUnreadMsgId;
|
||||||
|
|
||||||
|
|
|
@ -368,15 +368,14 @@ void FieldHeader::resolveMessageData() {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto channel = id.channel
|
const auto peer = _data->peer(id.peer);
|
||||||
? _data->channel(id.channel).get()
|
const auto itemId = id.msg;
|
||||||
: nullptr;
|
const auto callback = crl::guard(this, [=] {
|
||||||
const auto callback = [=](ChannelData *channel, MsgId msgId) {
|
|
||||||
const auto now = (isEditingMessage()
|
const auto now = (isEditingMessage()
|
||||||
? _editMsgId
|
? _editMsgId
|
||||||
: _replyToId).current();
|
: _replyToId).current();
|
||||||
if (now == id && !_shownMessage) {
|
if (now == id && !_shownMessage) {
|
||||||
if (const auto message = _data->message(channel, msgId)) {
|
if (const auto message = _data->message(peer, itemId)) {
|
||||||
setShownMessage(message);
|
setShownMessage(message);
|
||||||
} else if (isEditingMessage()) {
|
} else if (isEditingMessage()) {
|
||||||
_editCancelled.fire({});
|
_editCancelled.fire({});
|
||||||
|
@ -384,11 +383,8 @@ void FieldHeader::resolveMessageData() {
|
||||||
_replyCancelled.fire({});
|
_replyCancelled.fire({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
_data->session().api().requestMessageData(
|
_data->session().api().requestMessageData(peer, itemId, callback);
|
||||||
channel,
|
|
||||||
id.msg,
|
|
||||||
crl::guard(this, callback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FieldHeader::previewRequested(
|
void FieldHeader::previewRequested(
|
||||||
|
@ -1537,10 +1533,10 @@ void ComposeControls::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
||||||
_previewSetState(draft->previewState);
|
_previewSetState(draft->previewState);
|
||||||
|
|
||||||
if (draft == editDraft) {
|
if (draft == editDraft) {
|
||||||
_header->editMessage({ _history->channelId(), draft->msgId });
|
_header->editMessage({ _history->peer->id, draft->msgId });
|
||||||
_header->replyToMessage({});
|
_header->replyToMessage({});
|
||||||
} else {
|
} else {
|
||||||
_header->replyToMessage({ _history->channelId(), draft->msgId });
|
_header->replyToMessage({ _history->peer->id, draft->msgId });
|
||||||
_header->editMessage({});
|
_header->editMessage({});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -986,7 +986,7 @@ void CopyPostLink(
|
||||||
Assert(channel != nullptr);
|
Assert(channel != nullptr);
|
||||||
if (const auto rootId = item->replyToTop()) {
|
if (const auto rootId = item->replyToTop()) {
|
||||||
const auto root = item->history()->owner().message(
|
const auto root = item->history()->owner().message(
|
||||||
peerToChannel(channel->id),
|
channel->id,
|
||||||
rootId);
|
rootId);
|
||||||
const auto sender = root
|
const auto sender = root
|
||||||
? root->discussionPostOriginalSender()
|
? root->discussionPostOriginalSender()
|
||||||
|
|
|
@ -2318,7 +2318,9 @@ ClickHandlerPtr Message::rightActionLink() const {
|
||||||
const auto owner = &data()->history()->owner();
|
const auto owner = &data()->history()->owner();
|
||||||
const auto itemId = data()->fullId();
|
const auto itemId = data()->fullId();
|
||||||
const auto forwarded = data()->Get<HistoryMessageForwarded>();
|
const auto forwarded = data()->Get<HistoryMessageForwarded>();
|
||||||
const auto savedFromPeer = forwarded ? forwarded->savedFromPeer : nullptr;
|
const auto savedFromPeer = forwarded
|
||||||
|
? forwarded->savedFromPeer
|
||||||
|
: nullptr;
|
||||||
const auto savedFromMsgId = forwarded ? forwarded->savedFromMsgId : 0;
|
const auto savedFromMsgId = forwarded ? forwarded->savedFromMsgId : 0;
|
||||||
|
|
||||||
using Callback = FnMut<void(not_null<Window::SessionController*>)>;
|
using Callback = FnMut<void(not_null<Window::SessionController*>)>;
|
||||||
|
@ -2328,7 +2330,7 @@ ClickHandlerPtr Message::rightActionLink() const {
|
||||||
*showByThread = [=, requested = 0](
|
*showByThread = [=, requested = 0](
|
||||||
not_null<Window::SessionController*> controller) mutable {
|
not_null<Window::SessionController*> controller) mutable {
|
||||||
const auto original = savedFromPeer->owner().message(
|
const auto original = savedFromPeer->owner().message(
|
||||||
savedFromPeer->asChannel(),
|
savedFromPeer,
|
||||||
savedFromMsgId);
|
savedFromMsgId);
|
||||||
if (original && original->replyToTop()) {
|
if (original && original->replyToTop()) {
|
||||||
controller->showRepliesForMessage(
|
controller->showRepliesForMessage(
|
||||||
|
@ -2337,14 +2339,12 @@ ClickHandlerPtr Message::rightActionLink() const {
|
||||||
original->id,
|
original->id,
|
||||||
Window::SectionShow::Way::Forward);
|
Window::SectionShow::Way::Forward);
|
||||||
} else if (!requested) {
|
} else if (!requested) {
|
||||||
const auto channel = savedFromPeer->asChannel();
|
|
||||||
const auto prequested = &requested;
|
const auto prequested = &requested;
|
||||||
requested = 1;
|
requested = 1;
|
||||||
channel->session().api().requestMessageData(
|
savedFromPeer->session().api().requestMessageData(
|
||||||
channel,
|
savedFromPeer,
|
||||||
savedFromMsgId,
|
savedFromMsgId,
|
||||||
[=, weak = base::make_weak(controller.get())](
|
[=, weak = base::make_weak(controller.get())] {
|
||||||
ChannelData *gotChannel, MsgId gotId) {
|
|
||||||
if (const auto strong = showByThreadWeak.lock()) {
|
if (const auto strong = showByThreadWeak.lock()) {
|
||||||
if (const auto strongController = weak.get()) {
|
if (const auto strongController = weak.get()) {
|
||||||
*prequested = 2;
|
*prequested = 2;
|
||||||
|
|
|
@ -101,13 +101,9 @@ namespace {
|
||||||
consumer.put_next(Ui::MessageBarContent{
|
consumer.put_next(Ui::MessageBarContent{
|
||||||
.text = { tr::lng_contacts_loading(tr::now) },
|
.text = { tr::lng_contacts_loading(tr::now) },
|
||||||
});
|
});
|
||||||
const auto channel = id.channel
|
const auto peer = session->data().peer(id.peer);
|
||||||
? session->data().channel(id.channel).get()
|
const auto callback = [=] { consumer.put_done(); };
|
||||||
: nullptr;
|
session->api().requestMessageData(peer, id.msg, callback);
|
||||||
const auto callback = [=](ChannelData *channel, MsgId id) {
|
|
||||||
consumer.put_done();
|
|
||||||
};
|
|
||||||
session->api().requestMessageData(channel, id.msg, callback);
|
|
||||||
return rpl::lifetime();
|
return rpl::lifetime();
|
||||||
});
|
});
|
||||||
return std::move(
|
return std::move(
|
||||||
|
|
|
@ -64,9 +64,7 @@ PinnedMemento::PinnedMemento(
|
||||||
: _history(history)
|
: _history(history)
|
||||||
, _highlightId(highlightId) {
|
, _highlightId(highlightId) {
|
||||||
_list.setAroundPosition({
|
_list.setAroundPosition({
|
||||||
.fullId = FullMsgId(
|
.fullId = FullMsgId(history->peer->id, highlightId),
|
||||||
history->channelId(),
|
|
||||||
highlightId),
|
|
||||||
.date = TimeId(0),
|
.date = TimeId(0),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -332,7 +330,7 @@ not_null<History*> PinnedWidget::history() const {
|
||||||
Dialogs::RowDescriptor PinnedWidget::activeChat() const {
|
Dialogs::RowDescriptor PinnedWidget::activeChat() const {
|
||||||
return {
|
return {
|
||||||
_history,
|
_history,
|
||||||
FullMsgId(_history->channelId(), ShowAtUnreadMsgId)
|
FullMsgId(_history->peer->id, ShowAtUnreadMsgId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,8 +389,8 @@ void PinnedWidget::restoreState(not_null<PinnedMemento*> memento) {
|
||||||
if (const auto highlight = memento->getHighlightId()) {
|
if (const auto highlight = memento->getHighlightId()) {
|
||||||
const auto position = Data::MessagePosition{
|
const auto position = Data::MessagePosition{
|
||||||
.fullId = ((highlight > 0 || !_migratedPeer)
|
.fullId = ((highlight > 0 || !_migratedPeer)
|
||||||
? FullMsgId(_history->channelId(), highlight)
|
? FullMsgId(_history->peer->id, highlight)
|
||||||
: FullMsgId(0, -highlight)),
|
: FullMsgId(_migratedPeer->id, -highlight)),
|
||||||
.date = TimeId(0),
|
.date = TimeId(0),
|
||||||
};
|
};
|
||||||
_inner->showAroundPosition(position, [=] {
|
_inner->showAroundPosition(position, [=] {
|
||||||
|
|
|
@ -110,7 +110,7 @@ void PinnedTracker::refreshViewer() {
|
||||||
|
|
||||||
void PinnedTracker::refreshCurrentFromSlice() {
|
void PinnedTracker::refreshCurrentFromSlice() {
|
||||||
const auto proj1 = [](FullMsgId id) {
|
const auto proj1 = [](FullMsgId id) {
|
||||||
return id.channel ? id.msg : (id.msg - ServerMaxMsgId);
|
return peerIsChannel(id.peer) ? id.msg : (id.msg - ServerMaxMsgId);
|
||||||
};
|
};
|
||||||
const auto proj2 = [](FullMsgId id) {
|
const auto proj2 = [](FullMsgId id) {
|
||||||
return id.msg;
|
return id.msg;
|
||||||
|
|
|
@ -90,11 +90,9 @@ rpl::producer<Ui::MessageBarContent> RootViewContent(
|
||||||
MsgId rootId) {
|
MsgId rootId) {
|
||||||
return MessageBarContentByItemId(
|
return MessageBarContentByItemId(
|
||||||
&history->session(),
|
&history->session(),
|
||||||
FullMsgId{ history->channelId(), rootId }
|
FullMsgId(history->peer->id, rootId)
|
||||||
) | rpl::map([=](Ui::MessageBarContent &&content) {
|
) | rpl::map([=](Ui::MessageBarContent &&content) {
|
||||||
const auto item = history->owner().message(
|
const auto item = history->owner().message(history->peer, rootId);
|
||||||
history->channelId(),
|
|
||||||
rootId);
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
content.text = Ui::Text::Link(tr::lng_deleted_message(tr::now));
|
content.text = Ui::Text::Link(tr::lng_deleted_message(tr::now));
|
||||||
}
|
}
|
||||||
|
@ -115,7 +113,7 @@ RepliesMemento::RepliesMemento(
|
||||||
if (commentId) {
|
if (commentId) {
|
||||||
_list.setAroundPosition({
|
_list.setAroundPosition({
|
||||||
.fullId = FullMsgId(
|
.fullId = FullMsgId(
|
||||||
commentsItem->history()->channelId(),
|
commentsItem->history()->peer->id,
|
||||||
commentId),
|
commentId),
|
||||||
.date = TimeId(0),
|
.date = TimeId(0),
|
||||||
});
|
});
|
||||||
|
@ -361,8 +359,7 @@ void RepliesWidget::sendReadTillRequest() {
|
||||||
|
|
||||||
void RepliesWidget::setupRoot() {
|
void RepliesWidget::setupRoot() {
|
||||||
if (!_root) {
|
if (!_root) {
|
||||||
const auto channel = _history->peer->asChannel();
|
const auto done = crl::guard(this, [=] {
|
||||||
const auto done = crl::guard(this, [=](ChannelData*, MsgId) {
|
|
||||||
_root = lookupRoot();
|
_root = lookupRoot();
|
||||||
if (_root) {
|
if (_root) {
|
||||||
_areComments = computeAreComments();
|
_areComments = computeAreComments();
|
||||||
|
@ -374,7 +371,10 @@ void RepliesWidget::setupRoot() {
|
||||||
}
|
}
|
||||||
updatePinnedVisibility();
|
updatePinnedVisibility();
|
||||||
});
|
});
|
||||||
_history->session().api().requestMessageData(channel, _rootId, done);
|
_history->session().api().requestMessageData(
|
||||||
|
_history->peer,
|
||||||
|
_rootId,
|
||||||
|
done);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ void RepliesWidget::setupRootView() {
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *RepliesWidget::lookupRoot() const {
|
HistoryItem *RepliesWidget::lookupRoot() const {
|
||||||
return _history->owner().message(_history->channelId(), _rootId);
|
return _history->owner().message(_history->peer, _rootId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RepliesWidget::computeAreComments() const {
|
bool RepliesWidget::computeAreComments() const {
|
||||||
|
@ -831,9 +831,7 @@ void RepliesWidget::restoreReplyReturns(const std::vector<MsgId> &list) {
|
||||||
void RepliesWidget::computeCurrentReplyReturn() {
|
void RepliesWidget::computeCurrentReplyReturn() {
|
||||||
_replyReturn = _replyReturns.empty()
|
_replyReturn = _replyReturns.empty()
|
||||||
? nullptr
|
? nullptr
|
||||||
: _history->owner().message(
|
: _history->owner().message(_history->peer, _replyReturns.back());
|
||||||
_history->channelId(),
|
|
||||||
_replyReturns.back());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::calculateNextReplyReturn() {
|
void RepliesWidget::calculateNextReplyReturn() {
|
||||||
|
@ -1408,7 +1406,7 @@ not_null<History*> RepliesWidget::history() const {
|
||||||
Dialogs::RowDescriptor RepliesWidget::activeChat() const {
|
Dialogs::RowDescriptor RepliesWidget::activeChat() const {
|
||||||
return {
|
return {
|
||||||
_history,
|
_history,
|
||||||
FullMsgId(_history->channelId(), ShowAtUnreadMsgId)
|
FullMsgId(_history->peer->id, ShowAtUnreadMsgId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1478,10 +1476,7 @@ bool RepliesWidget::showMessage(
|
||||||
if (peerId != _history->peer->id) {
|
if (peerId != _history->peer->id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto id = FullMsgId{
|
const auto id = FullMsgId(_history->peer->id, messageId);
|
||||||
_history->channelId(),
|
|
||||||
messageId
|
|
||||||
};
|
|
||||||
const auto message = _history->owner().message(id);
|
const auto message = _history->owner().message(id);
|
||||||
if (!message || message->replyToTop() != _rootId) {
|
if (!message || message->replyToTop() != _rootId) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1558,7 +1553,7 @@ void RepliesWidget::restoreState(not_null<RepliesMemento*> memento) {
|
||||||
_inner->restoreState(memento->list());
|
_inner->restoreState(memento->list());
|
||||||
if (const auto highlight = memento->getHighlightId()) {
|
if (const auto highlight = memento->getHighlightId()) {
|
||||||
const auto position = Data::MessagePosition{
|
const auto position = Data::MessagePosition{
|
||||||
.fullId = FullMsgId(_history->channelId(), highlight),
|
.fullId = FullMsgId(_history->peer->id, highlight),
|
||||||
.date = TimeId(0),
|
.date = TimeId(0),
|
||||||
};
|
};
|
||||||
_inner->showAroundPosition(position, [=] {
|
_inner->showAroundPosition(position, [=] {
|
||||||
|
|
|
@ -905,7 +905,7 @@ not_null<History*> ScheduledWidget::history() const {
|
||||||
Dialogs::RowDescriptor ScheduledWidget::activeChat() const {
|
Dialogs::RowDescriptor ScheduledWidget::activeChat() const {
|
||||||
return {
|
return {
|
||||||
_history,
|
_history,
|
||||||
FullMsgId(_history->channelId(), ShowAtUnreadMsgId)
|
FullMsgId(_history->peer->id, ShowAtUnreadMsgId)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ QString TimestampLinkBase(
|
||||||
FullMsgId context) {
|
FullMsgId context) {
|
||||||
return QString(
|
return QString(
|
||||||
"media_timestamp?base=doc%1_%2_%3&t="
|
"media_timestamp?base=doc%1_%2_%3&t="
|
||||||
).arg(document->id).arg(context.channel.bare).arg(context.msg.bare);
|
).arg(document->id).arg(context.peer.value).arg(context.msg.bare);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeId DurationForTimestampLinks(not_null<WebPageData*> webpage) {
|
TimeId DurationForTimestampLinks(not_null<WebPageData*> webpage) {
|
||||||
|
|
|
@ -71,8 +71,8 @@ rpl::producer<SparseIdsMergedSlice> AbstractController::mediaSource(
|
||||||
Expects(peer() != nullptr);
|
Expects(peer() != nullptr);
|
||||||
|
|
||||||
const auto isScheduled = [&] {
|
const auto isScheduled = [&] {
|
||||||
const auto channelId = peerToChannel(peer()->id);
|
const auto peerId = peer()->id;
|
||||||
if (const auto item = session().data().message(channelId, aroundId)) {
|
if (const auto item = session().data().message(peerId, aroundId)) {
|
||||||
return item->isScheduled();
|
return item->isScheduled();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -61,7 +61,7 @@ constexpr auto kPreloadedScreensCountFull
|
||||||
constexpr auto kMediaCountForSearch = 10;
|
constexpr auto kMediaCountForSearch = 10;
|
||||||
|
|
||||||
UniversalMsgId GetUniversalId(FullMsgId itemId) {
|
UniversalMsgId GetUniversalId(FullMsgId itemId) {
|
||||||
return (itemId.channel != 0)
|
return peerIsChannel(itemId.peer)
|
||||||
? UniversalMsgId(itemId.msg)
|
? UniversalMsgId(itemId.msg)
|
||||||
: UniversalMsgId(itemId.msg - ServerMaxMsgId);
|
: UniversalMsgId(itemId.msg - ServerMaxMsgId);
|
||||||
}
|
}
|
||||||
|
@ -853,10 +853,11 @@ void ListWidget::itemRemoved(not_null<const HistoryItem*> item) {
|
||||||
FullMsgId ListWidget::computeFullId(
|
FullMsgId ListWidget::computeFullId(
|
||||||
UniversalMsgId universalId) const {
|
UniversalMsgId universalId) const {
|
||||||
Expects(universalId != 0);
|
Expects(universalId != 0);
|
||||||
|
Expects(universalId > 0 || _migrated != nullptr);
|
||||||
|
|
||||||
return (universalId > 0)
|
return (universalId > 0)
|
||||||
? FullMsgId(peerToChannel(_peer->id), universalId)
|
? FullMsgId(_peer->id, universalId)
|
||||||
: FullMsgId(NoChannel, ServerMaxMsgId + universalId);
|
: FullMsgId(_migrated->id, ServerMaxMsgId + universalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ListWidget::collectSelectedItems() const -> SelectedItems {
|
auto ListWidget::collectSelectedItems() const -> SelectedItems {
|
||||||
|
@ -964,9 +965,8 @@ bool ListWidget::isMyItem(not_null<const HistoryItem*> item) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListWidget::isPossiblyMyId(FullMsgId fullId) const {
|
bool ListWidget::isPossiblyMyId(FullMsgId fullId) const {
|
||||||
return fullId.channel
|
return (fullId.peer == _peer->id)
|
||||||
? (_peer->isChannel() && peerToChannel(_peer->id) == fullId.channel)
|
|| (_migrated && fullId.peer == _migrated->id);
|
||||||
: (!_peer->isChannel() || _migrated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ListWidget::isItemLayout(
|
bool ListWidget::isItemLayout(
|
||||||
|
|
|
@ -1429,7 +1429,7 @@ void MainWidget::ui_showPeerHistory(
|
||||||
if (const auto history = _history->history()) {
|
if (const auto history = _history->history()) {
|
||||||
_dialogs->scrollToEntry(Dialogs::RowDescriptor(
|
_dialogs->scrollToEntry(Dialogs::RowDescriptor(
|
||||||
history,
|
history,
|
||||||
FullMsgId(history->channelId(), showAtMsgId)));
|
FullMsgId(history->peer->id, showAtMsgId)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_dialogs->update();
|
_dialogs->update();
|
||||||
|
|
|
@ -386,7 +386,7 @@ auto Instance::playlistKey(not_null<const Data*> data) const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto universalId = (contextId.channel == history->channelId())
|
const auto universalId = (contextId.peer == history->peer->id)
|
||||||
? contextId.msg
|
? contextId.msg
|
||||||
: (contextId.msg - ServerMaxMsgId);
|
: (contextId.msg - ServerMaxMsgId);
|
||||||
return SliceKey(
|
return SliceKey(
|
||||||
|
@ -506,9 +506,9 @@ bool Instance::moveInPlaylist(
|
||||||
}
|
}
|
||||||
const auto universal = computeCurrentUniversalId(data);
|
const auto universal = computeCurrentUniversalId(data);
|
||||||
const auto byUniversal = [&](ShuffleData::UniversalMsgId id) {
|
const auto byUniversal = [&](ShuffleData::UniversalMsgId id) {
|
||||||
return (id < 0)
|
return (id < 0 && raw->migrated)
|
||||||
? jumpById({ ChannelId(), id + ServerMaxMsgId })
|
? jumpById({ raw->migrated->peer->id, id + ServerMaxMsgId })
|
||||||
: jumpById({ raw->history->channelId(), id });
|
: jumpById({ raw->history->peer->id, id });
|
||||||
};
|
};
|
||||||
if (universal && raw->indexInPlayedIds == raw->playedIds.size()) {
|
if (universal && raw->indexInPlayedIds == raw->playedIds.size()) {
|
||||||
raw->playedIds.push_back(universal);
|
raw->playedIds.push_back(universal);
|
||||||
|
@ -906,12 +906,12 @@ void Instance::validateShuffleData(not_null<Data*> data) {
|
||||||
raw->nextSliceLifetime.destroy();
|
raw->nextSliceLifetime.destroy();
|
||||||
|
|
||||||
const auto size = update.size();
|
const auto size = update.size();
|
||||||
const auto channel = raw->history->channelId();
|
const auto peer = raw->history->peer->id;
|
||||||
raw->playlist.reserve(raw->playlist.size() + size);
|
raw->playlist.reserve(raw->playlist.size() + size);
|
||||||
raw->nonPlayedIds.reserve(raw->nonPlayedIds.size() + size);
|
raw->nonPlayedIds.reserve(raw->nonPlayedIds.size() + size);
|
||||||
for (auto i = size; i != 0;) {
|
for (auto i = size; i != 0;) {
|
||||||
const auto fullId = update[--i];
|
const auto fullId = update[--i];
|
||||||
const auto universal = (fullId.channel == channel)
|
const auto universal = (fullId.peer == peer)
|
||||||
? fullId.msg
|
? fullId.msg
|
||||||
: (fullId.msg - ServerMaxMsgId);
|
: (fullId.msg - ServerMaxMsgId);
|
||||||
if (raw->playlist.empty() || raw->playlist.back() > universal) {
|
if (raw->playlist.empty() || raw->playlist.back() > universal) {
|
||||||
|
|
|
@ -4742,7 +4742,7 @@ void OverlayWidget::updateHeader() {
|
||||||
_headerText = tr::lng_mediaview_single_photo(tr::now);
|
_headerText = tr::lng_mediaview_single_photo(tr::now);
|
||||||
} else if (_user) {
|
} else if (_user) {
|
||||||
_headerText = tr::lng_mediaview_profile_photo(tr::now);
|
_headerText = tr::lng_mediaview_profile_photo(tr::now);
|
||||||
} else if ((_history && _history->channelId() && !_history->isMegagroup())
|
} else if ((_history && _history->peer->isBroadcast())
|
||||||
|| (_peer && _peer->isChannel() && !_peer->isMegagroup())) {
|
|| (_peer && _peer->isChannel() && !_peer->isMegagroup())) {
|
||||||
_headerText = tr::lng_mediaview_channel_photo(tr::now);
|
_headerText = tr::lng_mediaview_channel_photo(tr::now);
|
||||||
} else if (_peer) {
|
} else if (_peer) {
|
||||||
|
|
|
@ -1592,7 +1592,7 @@ void FormController::uploadEncryptedFile(
|
||||||
prepared->filemd5 = file.uploadData->md5checksum;
|
prepared->filemd5 = file.uploadData->md5checksum;
|
||||||
|
|
||||||
file.uploadData->fullId = FullMsgId(
|
file.uploadData->fullId = FullMsgId(
|
||||||
0,
|
session().userPeerId(),
|
||||||
session().data().nextLocalMessageId());
|
session().data().nextLocalMessageId());
|
||||||
file.uploadData->status.set(LoadStatus::Status::InProgress, 0);
|
file.uploadData->status.set(LoadStatus::Status::InProgress, 0);
|
||||||
session().uploader().upload(
|
session().uploader().upload(
|
||||||
|
|
|
@ -69,7 +69,7 @@ void CheckoutProcess::Start(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto id = (invoice && invoice->receiptMsgId)
|
const auto id = (invoice && invoice->receiptMsgId)
|
||||||
? FullMsgId(item->history()->channelId(), invoice->receiptMsgId)
|
? FullMsgId(item->history()->peer->id, invoice->receiptMsgId)
|
||||||
: item->fullId();
|
: item->fullId();
|
||||||
if (invoice) {
|
if (invoice) {
|
||||||
mode = invoice->receiptMsgId ? Mode::Receipt : Mode::Payment;
|
mode = invoice->receiptMsgId ? Mode::Receipt : Mode::Payment;
|
||||||
|
|
|
@ -147,7 +147,7 @@ Form::Form(not_null<PeerData*> peer, MsgId itemId, bool receipt)
|
||||||
Form::~Form() = default;
|
Form::~Form() = default;
|
||||||
|
|
||||||
void Form::fillInvoiceFromMessage() {
|
void Form::fillInvoiceFromMessage() {
|
||||||
const auto id = FullMsgId(peerToChannel(_peer->id), _msgId);
|
const auto id = FullMsgId(_peer->id, _msgId);
|
||||||
if (const auto item = _session->data().message(id)) {
|
if (const auto item = _session->data().message(id)) {
|
||||||
const auto media = [&] {
|
const auto media = [&] {
|
||||||
if (const auto payment = item->Get<HistoryServicePayment>()) {
|
if (const auto payment = item->Get<HistoryServicePayment>()) {
|
||||||
|
@ -194,9 +194,7 @@ void Form::loadThumbnail(not_null<PhotoData*> photo) {
|
||||||
_invoice.cover.thumbnail = prepareEmptyThumbnail();
|
_invoice.cover.thumbnail = prepareEmptyThumbnail();
|
||||||
}
|
}
|
||||||
_thumbnailLoadProcess->view = std::move(view);
|
_thumbnailLoadProcess->view = std::move(view);
|
||||||
photo->load(
|
photo->load(Data::PhotoSize::Thumbnail, FullMsgId(_peer->id, _msgId));
|
||||||
Data::PhotoSize::Thumbnail,
|
|
||||||
FullMsgId(peerToChannel(_peer->id), _msgId));
|
|
||||||
_session->downloaderTaskFinished(
|
_session->downloaderTaskFinished(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
const auto &view = _thumbnailLoadProcess->view;
|
const auto &view = _thumbnailLoadProcess->view;
|
||||||
|
|
|
@ -296,9 +296,7 @@ void System::checkDelayed() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
const auto fullId = FullMsgId(
|
const auto fullId = FullMsgId(history->peer->id, i->second.msg);
|
||||||
history->channelId(),
|
|
||||||
i->second.msg);
|
|
||||||
if (const auto item = peer->owner().message(fullId)) {
|
if (const auto item = peer->owner().message(fullId)) {
|
||||||
if (!item->notificationReady()) {
|
if (!item->notificationReady()) {
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
@ -677,9 +675,7 @@ void Manager::openNotificationMessage(
|
||||||
if (history->peer->isUser() || history->peer->isChannel()) {
|
if (history->peer->isUser() || history->peer->isChannel()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const auto item = history->owner().message(
|
const auto item = history->owner().message(history->peer, messageId);
|
||||||
history->channelId(),
|
|
||||||
messageId);
|
|
||||||
if (!item || !item->isRegular() || !item->mentionsMe()) {
|
if (!item || !item->isRegular() || !item->mentionsMe()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -714,9 +710,7 @@ void Manager::notificationReplied(
|
||||||
message.action.clearDraft = false;
|
message.action.clearDraft = false;
|
||||||
history->session().api().sendMessage(std::move(message));
|
history->session().api().sendMessage(std::move(message));
|
||||||
|
|
||||||
const auto item = history->owner().message(
|
const auto item = history->owner().message(history->peer, id.msgId);
|
||||||
history->channelId(),
|
|
||||||
id.msgId);
|
|
||||||
if (item && item->isUnreadMention() && !item->isUnreadMedia()) {
|
if (item && item->isUnreadMention() && !item->isUnreadMedia()) {
|
||||||
history->session().api().markMediaRead(item);
|
history->session().api().markMediaRead(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -602,7 +602,9 @@ void ChatBackground::checkUploadWallPaper() {
|
||||||
|
|
||||||
const auto ready = PrepareWallPaper(_session->mainDcId(), _original);
|
const auto ready = PrepareWallPaper(_session->mainDcId(), _original);
|
||||||
const auto documentId = ready.id;
|
const auto documentId = ready.id;
|
||||||
_wallPaperUploadId = FullMsgId(0, _session->data().nextLocalMessageId());
|
_wallPaperUploadId = FullMsgId(
|
||||||
|
_session->userPeerId(),
|
||||||
|
_session->data().nextLocalMessageId());
|
||||||
_session->uploader().uploadMedia(_wallPaperUploadId, ready);
|
_session->uploader().uploadMedia(_wallPaperUploadId, ready);
|
||||||
if (_wallPaperUploadLifetime) {
|
if (_wallPaperUploadLifetime) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -479,7 +479,7 @@ Fn<void()> SavePreparedTheme(
|
||||||
const auto api = &session->api();
|
const auto api = &session->api();
|
||||||
const auto state = std::make_shared<State>();
|
const auto state = std::make_shared<State>();
|
||||||
state->id = FullMsgId(
|
state->id = FullMsgId(
|
||||||
0,
|
session->userPeerId(),
|
||||||
session->data().nextLocalMessageId());
|
session->data().nextLocalMessageId());
|
||||||
|
|
||||||
const auto creating = !fields.id
|
const auto creating = !fields.id
|
||||||
|
|
|
@ -1153,8 +1153,8 @@ void HidePinnedBar(
|
||||||
const auto migrated = peer->migrateFrom();
|
const auto migrated = peer->migrateFrom();
|
||||||
const auto top = Data::ResolveTopPinnedId(peer, migrated);
|
const auto top = Data::ResolveTopPinnedId(peer, migrated);
|
||||||
const auto universal = !top
|
const auto universal = !top
|
||||||
? int32(0)
|
? MsgId(0)
|
||||||
: (migrated && !top.channel)
|
: (migrated && !peerIsChannel(top.peer))
|
||||||
? (top.msg - ServerMaxMsgId)
|
? (top.msg - ServerMaxMsgId)
|
||||||
: top.msg;
|
: top.msg;
|
||||||
if (universal) {
|
if (universal) {
|
||||||
|
|
|
@ -376,8 +376,8 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
}
|
}
|
||||||
_session->api().request(base::take(_showingRepliesRequestId)).cancel();
|
_session->api().request(base::take(_showingRepliesRequestId)).cancel();
|
||||||
|
|
||||||
const auto channelId = history->channelId();
|
const auto postPeer = history->peer;
|
||||||
//const auto item = _session->data().message(channelId, rootId);
|
//const auto item = _session->data().message(postPeer, rootId);
|
||||||
//if (!commentId && (!item || !item->repliesAreComments())) {
|
//if (!commentId && (!item || !item->repliesAreComments())) {
|
||||||
// showSection(std::make_shared<HistoryView::RepliesMemento>(history, rootId));
|
// showSection(std::make_shared<HistoryView::RepliesMemento>(history, rootId));
|
||||||
// return;
|
// return;
|
||||||
|
@ -411,9 +411,7 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
if (!peer || !id) {
|
if (!peer || !id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto item = _session->data().message(
|
auto item = _session->data().message(peer, id);
|
||||||
peerToChannel(peer),
|
|
||||||
id);
|
|
||||||
if (const auto group = _session->data().groups().find(item)) {
|
if (const auto group = _session->data().groups().find(item)) {
|
||||||
item = group->items.front();
|
item = group->items.front();
|
||||||
}
|
}
|
||||||
|
@ -426,8 +424,8 @@ void SessionNavigation::showRepliesForMessage(
|
||||||
data.vunread_count().v);
|
data.vunread_count().v);
|
||||||
item->setRepliesOutboxReadTill(
|
item->setRepliesOutboxReadTill(
|
||||||
data.vread_outbox_max_id().value_or_empty());
|
data.vread_outbox_max_id().value_or_empty());
|
||||||
const auto post = _session->data().message(channelId, rootId);
|
const auto post = _session->data().message(postPeer, rootId);
|
||||||
if (post && item->history()->channelId() != channelId) {
|
if (post && item->history()->peer != postPeer) {
|
||||||
post->setCommentsItemId(item->fullId());
|
post->setCommentsItemId(item->fullId());
|
||||||
if (const auto maxId = data.vmax_id()) {
|
if (const auto maxId = data.vmax_id()) {
|
||||||
post->setRepliesMaxId(maxId->v);
|
post->setRepliesMaxId(maxId->v);
|
||||||
|
|
Loading…
Add table
Reference in a new issue