mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-30 22:25:12 +00:00
Moved cancelUploadLayer from MainWidget to SessionController.
This commit is contained in:
@@ -57,6 +57,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "api/api_chat_invite.h"
|
||||
#include "api/api_global_privacy.h"
|
||||
#include "support/support_helper.h"
|
||||
#include "storage/file_upload.h"
|
||||
#include "facades.h"
|
||||
#include "styles/style_window.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(
|
||||
std::shared_ptr<SectionMemento> memento,
|
||||
const SectionShow ¶ms) {
|
||||
|
Reference in New Issue
Block a user