mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Pass MTP::Instance to MTP::Sender.
This commit is contained in:
@@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "storage/localstorage.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
#include "apiwrap.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "history/view/history_view_cursor_state.h"
|
||||
#include "facades.h"
|
||||
@@ -130,6 +131,7 @@ GifsListWidget::GifsListWidget(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Inner(parent, controller)
|
||||
, _api(controller->session().api().instance())
|
||||
, _section(Section::Gifs)
|
||||
, _updateInlineItems([=] { updateInlineItems(); })
|
||||
, _previewTimer([=] { showPreview(); }) {
|
||||
@@ -217,7 +219,7 @@ GifsListWidget::~GifsListWidget() {
|
||||
void GifsListWidget::cancelGifsSearch() {
|
||||
_footer->setLoading(false);
|
||||
if (_inlineRequestId) {
|
||||
request(_inlineRequestId).cancel();
|
||||
_api.request(_inlineRequestId).cancel();
|
||||
_inlineRequestId = 0;
|
||||
}
|
||||
_inlineRequestTimer.stop();
|
||||
@@ -840,7 +842,7 @@ void GifsListWidget::searchForGifs(const QString &query) {
|
||||
if (_inlineQuery != query) {
|
||||
_footer->setLoading(false);
|
||||
if (_inlineRequestId) {
|
||||
request(_inlineRequestId).cancel();
|
||||
_api.request(_inlineRequestId).cancel();
|
||||
_inlineRequestId = 0;
|
||||
}
|
||||
if (_inlineCache.find(query) != _inlineCache.cend()) {
|
||||
@@ -855,7 +857,7 @@ void GifsListWidget::searchForGifs(const QString &query) {
|
||||
|
||||
if (!_searchBot && !_searchBotRequestId) {
|
||||
auto username = str_const_toString(kSearchBotUsername);
|
||||
_searchBotRequestId = request(MTPcontacts_ResolveUsername(
|
||||
_searchBotRequestId = _api.request(MTPcontacts_ResolveUsername(
|
||||
MTP_string(username)
|
||||
)).done([=](const MTPcontacts_ResolvedPeer &result) {
|
||||
Expects(result.type() == mtpc_contacts_resolvedPeer);
|
||||
@@ -905,7 +907,7 @@ void GifsListWidget::sendInlineRequest() {
|
||||
}
|
||||
|
||||
_footer->setLoading(true);
|
||||
_inlineRequestId = request(MTPmessages_GetInlineBotResults(
|
||||
_inlineRequestId = _api.request(MTPmessages_GetInlineBotResults(
|
||||
MTP_flags(0),
|
||||
_searchBot->inputUser,
|
||||
_inlineQueryPeer->input,
|
||||
|
@@ -34,8 +34,7 @@ namespace ChatHelpers {
|
||||
class GifsListWidget
|
||||
: public TabbedSelector::Inner
|
||||
, public InlineBots::Layout::Context
|
||||
, private base::Subscriber
|
||||
, private MTP::Sender {
|
||||
, private base::Subscriber {
|
||||
public:
|
||||
using InlineChosen = TabbedSelector::InlineChosen;
|
||||
|
||||
@@ -119,6 +118,8 @@ private:
|
||||
void updateInlineItems();
|
||||
void showPreview();
|
||||
|
||||
MTP::Sender _api;
|
||||
|
||||
Section _section = Section::Gifs;
|
||||
crl::time _lastScrolled = 0;
|
||||
base::Timer _updateInlineItems;
|
||||
|
@@ -828,6 +828,7 @@ StickersListWidget::StickersListWidget(
|
||||
QWidget *parent,
|
||||
not_null<Window::SessionController*> controller)
|
||||
: Inner(parent, controller)
|
||||
, _api(controller->session().api().instance())
|
||||
, _section(Section::Stickers)
|
||||
, _megagroupSetAbout(st::columnMinimalWidthThird - st::emojiScroll.width - st::emojiPanHeaderLeft)
|
||||
, _addText(tr::lng_stickers_featured_add(tr::now).toUpper())
|
||||
@@ -1069,7 +1070,7 @@ void StickersListWidget::sendSearchRequest() {
|
||||
|
||||
_footer->setLoading(true);
|
||||
const auto hash = int32(0);
|
||||
_searchRequestId = request(MTPmessages_SearchStickerSets(
|
||||
_searchRequestId = _api.request(MTPmessages_SearchStickerSets(
|
||||
MTP_flags(0),
|
||||
MTP_string(_searchQuery),
|
||||
MTP_int(hash)
|
||||
@@ -1092,7 +1093,7 @@ void StickersListWidget::searchForSets(const QString &query) {
|
||||
if (_searchQuery != cleaned) {
|
||||
_footer->setLoading(false);
|
||||
if (const auto requestId = base::take(_searchRequestId)) {
|
||||
request(requestId).cancel();
|
||||
_api.request(requestId).cancel();
|
||||
}
|
||||
if (_searchCache.find(cleaned) != _searchCache.cend()) {
|
||||
_searchRequestTimer.cancel();
|
||||
@@ -1108,7 +1109,7 @@ void StickersListWidget::searchForSets(const QString &query) {
|
||||
void StickersListWidget::cancelSetsSearch() {
|
||||
_footer->setLoading(false);
|
||||
if (const auto requestId = base::take(_searchRequestId)) {
|
||||
request(requestId).cancel();
|
||||
_api.request(requestId).cancel();
|
||||
}
|
||||
_searchRequestTimer.cancel();
|
||||
_searchQuery = _searchNextQuery = QString();
|
||||
@@ -2468,7 +2469,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
||||
return;
|
||||
}
|
||||
_megagroupSetIdRequested = set.vid().v;
|
||||
request(MTPmessages_GetStickerSet(
|
||||
_api.request(MTPmessages_GetStickerSet(
|
||||
_megagroupSet->mgInfo->stickerSet
|
||||
)).done([=](const MTPmessages_StickerSet &result) {
|
||||
if (const auto set = Stickers::FeedSetFull(result)) {
|
||||
@@ -2810,7 +2811,7 @@ void StickersListWidget::installSet(uint64 setId) {
|
||||
const auto input = Stickers::inputSetId(*it);
|
||||
if ((it->flags & MTPDstickerSet_ClientFlag::f_not_loaded)
|
||||
|| it->stickers.empty()) {
|
||||
request(MTPmessages_GetStickerSet(
|
||||
_api.request(MTPmessages_GetStickerSet(
|
||||
input
|
||||
)).done([=](const MTPmessages_StickerSet &result) {
|
||||
Stickers::FeedSetFull(result);
|
||||
@@ -2825,7 +2826,7 @@ void StickersListWidget::installSet(uint64 setId) {
|
||||
void StickersListWidget::sendInstallRequest(
|
||||
uint64 setId,
|
||||
const MTPInputStickerSet &input) {
|
||||
request(MTPmessages_InstallStickerSet(
|
||||
_api.request(MTPmessages_InstallStickerSet(
|
||||
input,
|
||||
MTP_bool(false)
|
||||
)).done([=](const MTPmessages_StickerSetInstallResult &result) {
|
||||
@@ -2876,9 +2877,9 @@ void StickersListWidget::removeSet(uint64 setId) {
|
||||
auto it = sets.find(_removingSetId);
|
||||
if (it != sets.cend()) {
|
||||
if (it->id && it->access) {
|
||||
request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)))).send();
|
||||
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access)))).send();
|
||||
} else if (!it->shortName.isEmpty()) {
|
||||
request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetShortName(MTP_string(it->shortName)))).send();
|
||||
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetShortName(MTP_string(it->shortName)))).send();
|
||||
}
|
||||
auto writeRecent = false;
|
||||
auto &recent = Stickers::GetRecentPack();
|
||||
|
@@ -38,8 +38,7 @@ struct StickerIcon;
|
||||
|
||||
class StickersListWidget
|
||||
: public TabbedSelector::Inner
|
||||
, private base::Subscriber
|
||||
, private MTP::Sender {
|
||||
, private base::Subscriber {
|
||||
public:
|
||||
StickersListWidget(
|
||||
QWidget *parent,
|
||||
@@ -300,6 +299,7 @@ private:
|
||||
|
||||
void showPreview();
|
||||
|
||||
MTP::Sender _api;
|
||||
ChannelData *_megagroupSet = nullptr;
|
||||
uint64 _megagroupSetIdRequested = 0;
|
||||
std::vector<Set> _mySets;
|
||||
|
Reference in New Issue
Block a user