mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved cancelUploadLayer from MainWidget to SessionController.
This commit is contained in:
parent
23c54896e5
commit
7c02d67665
8 changed files with 38 additions and 37 deletions
|
@ -618,7 +618,7 @@ void InnerWidget::elementOpenDocument(
|
||||||
|
|
||||||
void InnerWidget::elementCancelUpload(const FullMsgId &context) {
|
void InnerWidget::elementCancelUpload(const FullMsgId &context) {
|
||||||
if (const auto item = session().data().message(context)) {
|
if (const auto item = session().data().message(context)) {
|
||||||
_controller->content()->cancelUploadLayer(item);
|
_controller->cancelUploadLayer(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2583,7 +2583,7 @@ void HistoryInner::elementOpenDocument(
|
||||||
|
|
||||||
void HistoryInner::elementCancelUpload(const FullMsgId &context) {
|
void HistoryInner::elementCancelUpload(const FullMsgId &context) {
|
||||||
if (const auto item = session().data().message(context)) {
|
if (const auto item = session().data().message(context)) {
|
||||||
_controller->content()->cancelUploadLayer(item);
|
_controller->cancelUploadLayer(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3241,7 +3241,7 @@ void HistoryInner::deleteItem(FullMsgId itemId) {
|
||||||
void HistoryInner::deleteItem(not_null<HistoryItem*> item) {
|
void HistoryInner::deleteItem(not_null<HistoryItem*> item) {
|
||||||
if (auto message = item->toHistoryMessage()) {
|
if (auto message = item->toHistoryMessage()) {
|
||||||
if (message->uploading()) {
|
if (message->uploading()) {
|
||||||
_controller->content()->cancelUploadLayer(item);
|
_controller->cancelUploadLayer(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -728,7 +728,7 @@ bool AddDeleteMessageAction(
|
||||||
}
|
}
|
||||||
if (const auto message = item->toHistoryMessage()) {
|
if (const auto message = item->toHistoryMessage()) {
|
||||||
if (message->uploading()) {
|
if (message->uploading()) {
|
||||||
controller->content()->cancelUploadLayer(item);
|
controller->cancelUploadLayer(item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1316,7 +1316,7 @@ void ListWidget::elementOpenDocument(
|
||||||
|
|
||||||
void ListWidget::elementCancelUpload(const FullMsgId &context) {
|
void ListWidget::elementCancelUpload(const FullMsgId &context) {
|
||||||
if (const auto item = session().data().message(context)) {
|
if (const auto item = session().data().message(context)) {
|
||||||
_controller->content()->cancelUploadLayer(item);
|
_controller->cancelUploadLayer(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "lang/lang_cloud_manager.h"
|
#include "lang/lang_cloud_manager.h"
|
||||||
#include "boxes/add_contact_box.h"
|
#include "boxes/add_contact_box.h"
|
||||||
#include "storage/file_upload.h"
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "inline_bots/inline_bot_layout_item.h"
|
#include "inline_bots/inline_bot_layout_item.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
|
@ -750,36 +749,6 @@ void MainWidget::showSendPathsLayer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWidget::cancelUploadLayer(not_null<HistoryItem*> item) {
|
|
||||||
const auto itemId = item->fullId();
|
|
||||||
session().uploader().pause(itemId);
|
|
||||||
const auto stopUpload = [=] {
|
|
||||||
Ui::hideLayer();
|
|
||||||
auto &data = session().data();
|
|
||||||
if (const auto item = data.message(itemId)) {
|
|
||||||
if (!item->isEditingMedia()) {
|
|
||||||
const auto history = item->history();
|
|
||||||
item->destroy();
|
|
||||||
history->requestChatListMessage();
|
|
||||||
} else {
|
|
||||||
item->returnSavedMedia();
|
|
||||||
session().uploader().cancel(item->fullId());
|
|
||||||
}
|
|
||||||
data.sendHistoryChangeNotifications();
|
|
||||||
}
|
|
||||||
session().uploader().unpause();
|
|
||||||
};
|
|
||||||
const auto continueUpload = [=] {
|
|
||||||
session().uploader().unpause();
|
|
||||||
};
|
|
||||||
Ui::show(Box<ConfirmBox>(
|
|
||||||
tr::lng_selected_cancel_sure_this(tr::now),
|
|
||||||
tr::lng_selected_upload_stop(tr::now),
|
|
||||||
tr::lng_continue(tr::now),
|
|
||||||
stopUpload,
|
|
||||||
continueUpload));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWidget::deletePhotoLayer(PhotoData *photo) {
|
void MainWidget::deletePhotoLayer(PhotoData *photo) {
|
||||||
if (!photo) return;
|
if (!photo) return;
|
||||||
Ui::show(Box<ConfirmBox>(tr::lng_delete_photo_sure(tr::now), tr::lng_box_delete(tr::now), crl::guard(this, [=] {
|
Ui::show(Box<ConfirmBox>(tr::lng_delete_photo_sure(tr::now), tr::lng_box_delete(tr::now), crl::guard(this, [=] {
|
||||||
|
|
|
@ -160,7 +160,6 @@ public:
|
||||||
|
|
||||||
void showForwardLayer(MessageIdsList &&items);
|
void showForwardLayer(MessageIdsList &&items);
|
||||||
void showSendPathsLayer();
|
void showSendPathsLayer();
|
||||||
void cancelUploadLayer(not_null<HistoryItem*> item);
|
|
||||||
void shareUrlLayer(const QString &url, const QString &text);
|
void shareUrlLayer(const QString &url, const QString &text);
|
||||||
void inlineSwitchLayer(const QString &botAndQuery);
|
void inlineSwitchLayer(const QString &botAndQuery);
|
||||||
void hiderLayer(base::unique_qptr<Window::HistoryHider> h);
|
void hiderLayer(base::unique_qptr<Window::HistoryHider> h);
|
||||||
|
|
|
@ -57,6 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_chat_invite.h"
|
#include "api/api_chat_invite.h"
|
||||||
#include "api/api_global_privacy.h"
|
#include "api/api_global_privacy.h"
|
||||||
#include "support/support_helper.h"
|
#include "support/support_helper.h"
|
||||||
|
#include "storage/file_upload.h"
|
||||||
#include "facades.h"
|
#include "facades.h"
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
#include "styles/style_dialogs.h"
|
#include "styles/style_dialogs.h"
|
||||||
|
@ -1149,6 +1150,37 @@ void SessionController::showPeerHistoryAtItem(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionController::cancelUploadLayer(not_null<HistoryItem*> item) {
|
||||||
|
const auto itemId = item->fullId();
|
||||||
|
session().uploader().pause(itemId);
|
||||||
|
const auto stopUpload = [=] {
|
||||||
|
Ui::hideLayer();
|
||||||
|
auto &data = session().data();
|
||||||
|
if (const auto item = data.message(itemId)) {
|
||||||
|
if (!item->isEditingMedia()) {
|
||||||
|
const auto history = item->history();
|
||||||
|
item->destroy();
|
||||||
|
history->requestChatListMessage();
|
||||||
|
} else {
|
||||||
|
item->returnSavedMedia();
|
||||||
|
session().uploader().cancel(item->fullId());
|
||||||
|
}
|
||||||
|
data.sendHistoryChangeNotifications();
|
||||||
|
}
|
||||||
|
session().uploader().unpause();
|
||||||
|
};
|
||||||
|
const auto continueUpload = [=] {
|
||||||
|
session().uploader().unpause();
|
||||||
|
};
|
||||||
|
|
||||||
|
show(Box<ConfirmBox>(
|
||||||
|
tr::lng_selected_cancel_sure_this(tr::now),
|
||||||
|
tr::lng_selected_upload_stop(tr::now),
|
||||||
|
tr::lng_continue(tr::now),
|
||||||
|
stopUpload,
|
||||||
|
continueUpload));
|
||||||
|
}
|
||||||
|
|
||||||
void SessionController::showSection(
|
void SessionController::showSection(
|
||||||
std::shared_ptr<SectionMemento> memento,
|
std::shared_ptr<SectionMemento> memento,
|
||||||
const SectionShow ¶ms) {
|
const SectionShow ¶ms) {
|
||||||
|
|
|
@ -328,6 +328,7 @@ public:
|
||||||
MsgId msgId = ShowAtUnreadMsgId) override;
|
MsgId msgId = ShowAtUnreadMsgId) override;
|
||||||
|
|
||||||
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
|
||||||
|
void cancelUploadLayer(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
void showSpecialLayer(
|
void showSpecialLayer(
|
||||||
object_ptr<Ui::LayerWidget> &&layer,
|
object_ptr<Ui::LayerWidget> &&layer,
|
||||||
|
|
Loading…
Add table
Reference in a new issue