mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-02 02:07:54 +00:00
Remove some MainWindow::sessionController() calls.
This commit is contained in:
@@ -23,11 +23,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_photo.h" // requestAttachedStickerSets.
|
||||
#include "passport/passport_form_controller.h"
|
||||
#include "chat_helpers/tabbed_selector.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "boxes/calendar_box.h"
|
||||
#include "boxes/sticker_set_box.h" // requestAttachedStickerSets.
|
||||
#include "boxes/confirm_box.h" // requestAttachedStickerSets.
|
||||
#include "boxes/stickers_box.h" // requestAttachedStickerSets.
|
||||
#include "lang/lang_keys.h" // requestAttachedStickerSets.
|
||||
#include "mainwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "main/main_session.h"
|
||||
@@ -223,6 +228,36 @@ rpl::producer<> SessionController::filtersMenuChanged() const {
|
||||
return _filtersMenuChanged.events();
|
||||
}
|
||||
|
||||
void SessionController::requestAttachedStickerSets(
|
||||
not_null<PhotoData*> photo) {
|
||||
session().api().request(_attachedStickerSetsRequestId).cancel();
|
||||
_attachedStickerSetsRequestId = session().api().request(
|
||||
MTPmessages_GetAttachedStickers(
|
||||
MTP_inputStickeredMediaPhoto(photo->mtpInput())
|
||||
)).done([=](const MTPVector<MTPStickerSetCovered> &result) {
|
||||
if (result.v.isEmpty()) {
|
||||
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
||||
return;
|
||||
} else if (result.v.size() > 1) {
|
||||
Ui::show(Box<StickersBox>(this, result));
|
||||
return;
|
||||
}
|
||||
// Single attached sticker pack.
|
||||
const auto setData = result.v.front().match([&](const auto &data) {
|
||||
return data.vset().match([&](const MTPDstickerSet &data) {
|
||||
return &data;
|
||||
});
|
||||
});
|
||||
|
||||
const auto setId = (setData->vid().v && setData->vaccess_hash().v)
|
||||
? MTP_inputStickerSetID(setData->vid(), setData->vaccess_hash())
|
||||
: MTP_inputStickerSetShortName(setData->vshort_name());
|
||||
Ui::show(Box<StickerSetBox>(this, setId), Ui::LayerOption::KeepOther);
|
||||
}).fail([=](const RPCError &error) {
|
||||
Ui::show(Box<InformBox>(tr::lng_stickers_not_found(tr::now)));
|
||||
}).send();
|
||||
}
|
||||
|
||||
void SessionController::checkOpenedFilter() {
|
||||
if (const auto filterId = activeChatsFilterCurrent()) {
|
||||
const auto &list = session().data().chatsFilters().list();
|
||||
@@ -800,6 +835,8 @@ void SessionController::setActiveChatsFilter(FilterId id) {
|
||||
}
|
||||
}
|
||||
|
||||
SessionController::~SessionController() = default;
|
||||
SessionController::~SessionController() {
|
||||
session().api().request(_attachedStickerSetsRequestId).cancel();
|
||||
}
|
||||
|
||||
} // namespace Window
|
||||
|
||||
Reference in New Issue
Block a user