2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Support topic on-the-fly creation.

This commit is contained in:
John Preston
2022-10-04 19:34:45 +04:00
parent 065d2e2ac9
commit 3722e55b67
32 changed files with 447 additions and 130 deletions

View File

@@ -71,10 +71,10 @@ void Polls::create(
history,
replyTo,
randomId,
MTPmessages_SendMedia(
Data::Histories::PrepareMessage<MTPmessages_SendMedia>(
MTP_flags(sendFlags),
peer->input,
MTP_int(replyTo),
Data::Histories::ReplyToPlaceholder(),
PollDataToInputMedia(&data),
MTP_string(),
MTP_long(randomId),

View File

@@ -148,10 +148,10 @@ void SendExistingMedia(
history,
replyTo,
randomId,
MTPmessages_SendMedia(
Data::Histories::PrepareMessage<MTPmessages_SendMedia>(
MTP_flags(sendFlags),
peer->input,
MTP_int(replyTo),
Data::Histories::ReplyToPlaceholder(),
inputMedia(),
MTP_string(captionText),
MTP_long(randomId),
@@ -314,10 +314,10 @@ bool SendDice(MessageToSend &message) {
history,
replyTo,
randomId,
MTPmessages_SendMedia(
Data::Histories::PrepareMessage<MTPmessages_SendMedia>(
MTP_flags(sendFlags),
peer->input,
MTP_int(replyTo),
Data::Histories::ReplyToPlaceholder(),
MTP_inputMediaDice(MTP_string(emoji)),
MTP_string(),
MTP_long(randomId),
@@ -347,9 +347,9 @@ void SendConfirmedFile(
&& (file->to.replaceMediaOf != 0);
const auto newId = FullMsgId(
file->to.peer,
isEditing
(isEditing
? file->to.replaceMediaOf
: session->data().nextLocalMessageId());
: session->data().nextLocalMessageId()));
const auto groupId = file->album ? file->album->groupId : uint64(0);
if (file->album) {
const auto proj = [](const SendingAlbum::Item &item) {
@@ -360,15 +360,21 @@ void SendConfirmedFile(
it->msgId = newId;
}
session->uploader().upload(newId, file);
const auto itemToEdit = isEditing
? session->data().message(newId)
: nullptr;
const auto history = session->data().history(file->to.peer);
const auto peer = history->peer;
if (!isEditing) {
file->to.replyTo = session->data().histories().convertTopicReplyTo(
history,
file->to.replyTo);
}
session->uploader().upload(newId, file);
auto action = SendAction(history, file->to.options);
action.clearDraft = false;
action.replyTo = file->to.replyTo;

View File

@@ -1534,7 +1534,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
const auto randomId = d.vrandom_id().v;
if (const auto id = session().data().messageIdByRandomId(randomId)) {
const auto newId = d.vid().v;
if (const auto local = session().data().message(id)) {
auto &owner = session().data();
if (const auto local = owner.message(id)) {
if (local->isScheduled()) {
session().data().scheduledMessages().apply(d, local);
} else {
@@ -1552,6 +1553,8 @@ void Updates::feedUpdate(const MTPUpdate &update) {
local->setRealId(d.vid().v);
}
}
} else {
owner.histories().checkTopicCreated(id, newId);
}
session().data().unregisterMessageRandomId(randomId);
}