mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
Added initial implementation of cancel of media uploading for editing.
This commit is contained in:
parent
741501d1d9
commit
653fd1bb63
4 changed files with 35 additions and 4 deletions
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/runtime_composer.h"
|
||||
#include "base/flags.h"
|
||||
#include "base/value_ordering.h"
|
||||
#include "data/data_media_types.h"
|
||||
|
||||
enum class UnreadMentionType;
|
||||
struct HistoryMessageReplyMarkup;
|
||||
|
@ -122,10 +123,16 @@ public:
|
|||
bool hasUnreadMediaFlag() const;
|
||||
void markMediaRead();
|
||||
|
||||
bool isEditingMedia() const {
|
||||
return _isEditingMedia;
|
||||
}
|
||||
void setIsEditingMedia(bool edit) {
|
||||
_isEditingMedia = edit;
|
||||
}
|
||||
|
||||
// For edit media in history_message.
|
||||
virtual void returnSavedMedia() {};
|
||||
|
||||
// Zero result means this message is not self-destructing right now.
|
||||
virtual crl::time getSelfDestructIn(crl::time now) {
|
||||
return 0;
|
||||
|
@ -315,6 +322,7 @@ protected:
|
|||
int _textHeight = 0;
|
||||
|
||||
bool _isEditingMedia = false;
|
||||
std::unique_ptr<Data::Media> _savedMedia;
|
||||
std::unique_ptr<Data::Media> _media;
|
||||
|
||||
private:
|
||||
|
|
|
@ -742,6 +742,7 @@ QString FormatViewsCount(int views) {
|
|||
|
||||
void HistoryMessage::refreshMedia(const MTPMessageMedia *media) {
|
||||
_media = nullptr;
|
||||
_savedMedia = nullptr;
|
||||
if (media) {
|
||||
setMedia(*media);
|
||||
}
|
||||
|
@ -757,6 +758,19 @@ void HistoryMessage::refreshSentMedia(const MTPMessageMedia *media) {
|
|||
}
|
||||
}
|
||||
|
||||
void HistoryMessage::returnSavedMedia() {
|
||||
if (!_savedMedia) {
|
||||
return;
|
||||
}
|
||||
const auto wasGrouped = history()->owner().groups().isGrouped(this);
|
||||
_media = std::move(_savedMedia);
|
||||
if (wasGrouped) {
|
||||
history()->owner().groups().refreshMessage(this);
|
||||
} else {
|
||||
history()->owner().requestItemViewRefresh(this);
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryMessage::setMedia(const MTPMessageMedia &media) {
|
||||
_media = CreateMedia(this, media);
|
||||
if (const auto invoice = _media ? _media->invoice() : nullptr) {
|
||||
|
@ -943,10 +957,13 @@ 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);
|
||||
}
|
||||
_isEditingMedia = false;
|
||||
// _isEditingMedia = false;
|
||||
}
|
||||
history()->owner().requestItemResize(this);
|
||||
}
|
||||
|
|
|
@ -89,6 +89,7 @@ public:
|
|||
|
||||
void refreshMedia(const MTPMessageMedia *media);
|
||||
void refreshSentMedia(const MTPMessageMedia *media);
|
||||
void returnSavedMedia() override;
|
||||
void setMedia(const MTPMessageMedia &media);
|
||||
static std::unique_ptr<Data::Media> CreateMedia(
|
||||
not_null<HistoryMessage*> item,
|
||||
|
|
|
@ -842,11 +842,16 @@ void MainWidget::cancelUploadLayer(not_null<HistoryItem*> item) {
|
|||
Ui::hideLayer();
|
||||
if (const auto item = App::histItemById(itemId)) {
|
||||
const auto history = item->history();
|
||||
//item->destroy();
|
||||
history->requestChatListMessage();
|
||||
if (!item->isEditingMedia()) {
|
||||
item->destroy();
|
||||
history->requestChatListMessage();
|
||||
} else {
|
||||
item->returnSavedMedia();
|
||||
session().uploader().cancel(item->fullId());
|
||||
}
|
||||
session().data().sendHistoryChangeNotifications();
|
||||
}
|
||||
//session().uploader().unpause();
|
||||
session().uploader().unpause();
|
||||
};
|
||||
const auto continueUpload = [=] {
|
||||
session().uploader().unpause();
|
||||
|
|
Loading…
Add table
Reference in a new issue