mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-19 06:26:55 +00:00
Refactored ApiWrap::editMedia.
- Slightly refactored checkEntitiesAndViewsUpdate. - Slightly refactored HistoryMessage.
This commit is contained in:
parent
0e4d85a5e5
commit
be2b2cbf7e
@ -4472,22 +4472,19 @@ void ApiWrap::editMedia(
|
||||
SendMediaType type,
|
||||
TextWithTags &&caption,
|
||||
const SendOptions &options) {
|
||||
LOG(("EDIT MEDIA WITH TEXT %1").arg(caption.text));
|
||||
if (list.files.empty()) return;
|
||||
|
||||
auto &file = list.files.front();
|
||||
const auto to = fileLoadTaskOptions(options);
|
||||
auto tasks = std::vector<std::unique_ptr<Task>>();
|
||||
tasks.reserve(list.files.size());
|
||||
for (auto &file : list.files) {
|
||||
tasks.push_back(std::make_unique<FileLoadTask>(
|
||||
file.path,
|
||||
file.content,
|
||||
std::move(file.information),
|
||||
type,
|
||||
to,
|
||||
caption,
|
||||
nullptr,
|
||||
true));
|
||||
}
|
||||
_fileLoader->addTasks(std::move(tasks));
|
||||
_fileLoader->addTask(std::make_unique<FileLoadTask>(
|
||||
file.path,
|
||||
file.content,
|
||||
std::move(file.information),
|
||||
type,
|
||||
to,
|
||||
caption,
|
||||
nullptr,
|
||||
true));
|
||||
}
|
||||
|
||||
void ApiWrap::sendFiles(
|
||||
|
@ -139,7 +139,6 @@ namespace App {
|
||||
auto entities = m.has_entities()
|
||||
? TextUtilities::EntitiesFromMTP(m.ventities.v)
|
||||
: EntitiesInText();
|
||||
const auto media = m.has_media() ? &m.vmedia : nullptr;
|
||||
existing->setText({ text, entities });
|
||||
existing->updateSentMedia(m.has_media() ? &m.vmedia : nullptr);
|
||||
existing->updateReplyMarkup(m.has_reply_markup()
|
||||
|
@ -132,7 +132,10 @@ public:
|
||||
|
||||
// For edit media in history_message.
|
||||
virtual void returnSavedMedia() {};
|
||||
virtual void clearSavedMedia() {};
|
||||
void clearSavedMedia() {
|
||||
_isEditingMedia = false;
|
||||
_savedMedia = nullptr;
|
||||
}
|
||||
|
||||
// Zero result means this message is not self-destructing right now.
|
||||
virtual crl::time getSelfDestructIn(crl::time now) {
|
||||
|
@ -955,14 +955,12 @@ void HistoryMessage::updateSentMedia(const MTPMessageMedia *media) {
|
||||
}
|
||||
_flags &= ~MTPDmessage_ClientFlag::f_from_inline_bot;
|
||||
} else {
|
||||
const auto shouldUpdate = _isEditingMedia ? true : !_media->updateSentMedia(*media);
|
||||
if (_isEditingMedia) {
|
||||
_savedMedia = _media->clone(this);
|
||||
}
|
||||
if (!media || !_media || shouldUpdate) {
|
||||
refreshSentMedia(media);
|
||||
} else if (!media || !_media || !_media->updateSentMedia(*media)) {
|
||||
refreshSentMedia(media);
|
||||
}
|
||||
// _isEditingMedia = false;
|
||||
}
|
||||
history()->owner().requestItemResize(this);
|
||||
}
|
||||
|
@ -90,9 +90,6 @@ public:
|
||||
void refreshMedia(const MTPMessageMedia *media);
|
||||
void refreshSentMedia(const MTPMessageMedia *media);
|
||||
void returnSavedMedia() override;
|
||||
void clearSavedMedia() {
|
||||
_savedMedia = nullptr;
|
||||
}
|
||||
void setMedia(const MTPMessageMedia &media);
|
||||
static std::unique_ptr<Data::Media> CreateMedia(
|
||||
not_null<HistoryMessage*> item,
|
||||
|
Loading…
Reference in New Issue
Block a user