2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Remove App::app(), App::uploader(), App::api().

Also use Auth() instead of AuthSession::Current*().
This commit is contained in:
John Preston
2017-08-04 16:54:32 +02:00
parent 417f5684dc
commit ab35829358
72 changed files with 450 additions and 445 deletions

View File

@@ -193,7 +193,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
QMultiMap<int32, UserData*> ordered;
mrows.reserve(mrows.size() + (_chat->participants.isEmpty() ? _chat->lastAuthors.size() : _chat->participants.size()));
if (_chat->noParticipantInfo()) {
if (App::api()) App::api()->requestFullPeer(_chat);
Auth().api().requestFullPeer(_chat);
} else if (!_chat->participants.isEmpty()) {
for (auto i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
auto user = i.key();
@@ -221,7 +221,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
} else if (_channel && _channel->isMegagroup()) {
QMultiMap<int32, UserData*> ordered;
if (_channel->mgInfo->lastParticipants.isEmpty() || _channel->lastParticipantsCountOutdated()) {
if (App::api()) App::api()->requestLastParticipants(_channel);
Auth().api().requestLastParticipants(_channel);
} else {
mrows.reserve(mrows.size() + _channel->mgInfo->lastParticipants.size());
for_const (auto user, _channel->mgInfo->lastParticipants) {
@@ -249,28 +249,36 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
int32 cnt = 0;
if (_chat) {
if (_chat->noParticipantInfo()) {
if (App::api()) App::api()->requestFullPeer(_chat);
Auth().api().requestFullPeer(_chat);
} else if (!_chat->participants.isEmpty()) {
for (auto i = _chat->participants.cbegin(), e = _chat->participants.cend(); i != e; ++i) {
auto user = i.key();
if (!user->botInfo) continue;
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
if (!user->botInfo->inited) {
Auth().api().requestFullPeer(user);
}
if (user->botInfo->commands.isEmpty()) continue;
bots.insert(user, true);
cnt += user->botInfo->commands.size();
}
}
} else if (_user && _user->botInfo) {
if (!_user->botInfo->inited && App::api()) App::api()->requestFullPeer(_user);
if (!_user->botInfo->inited) {
Auth().api().requestFullPeer(_user);
}
cnt = _user->botInfo->commands.size();
bots.insert(_user, true);
} else if (_channel && _channel->isMegagroup()) {
if (_channel->mgInfo->bots.isEmpty()) {
if (!_channel->mgInfo->botStatus && App::api()) App::api()->requestBots(_channel);
if (!_channel->mgInfo->botStatus) {
Auth().api().requestBots(_channel);
}
} else {
for_const (auto user, _channel->mgInfo->bots) {
if (!user->botInfo) continue;
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
if (!user->botInfo->inited) {
Auth().api().requestFullPeer(user);
}
if (user->botInfo->commands.isEmpty()) continue;
bots.insert(user, true);
cnt += user->botInfo->commands.size();
@@ -285,7 +293,9 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
auto user = *i;
if (!user->botInfo) continue;
if (!bots.contains(user)) continue;
if (!user->botInfo->inited && App::api()) App::api()->requestFullPeer(user);
if (!user->botInfo->inited) {
Auth().api().requestFullPeer(user);
}
if (user->botInfo->commands.isEmpty()) continue;
bots.remove(user);
for (auto j = 0, l = user->botInfo->commands.size(); j != l; ++j) {
@@ -512,7 +522,7 @@ FieldAutocompleteInner::FieldAutocompleteInner(FieldAutocomplete *parent, Mentio
, _previewShown(false) {
_previewTimer.setSingleShot(true);
connect(&_previewTimer, SIGNAL(timeout()), this, SLOT(onPreview()));
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] { update(); });
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
}
void FieldAutocompleteInner::paintEvent(QPaintEvent *e) {

View File

@@ -136,10 +136,10 @@ GifsListWidget::GifsListWidget(QWidget *parent, gsl::not_null<Window::Controller
_inlineRequestTimer.setSingleShot(true);
connect(&_inlineRequestTimer, &QTimer::timeout, this, [this] { sendInlineRequest(); });
subscribe(AuthSession::Current().data().savedGifsUpdated(), [this] {
subscribe(Auth().data().savedGifsUpdated(), [this] {
refreshSavedGifs();
});
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
subscribe(Auth().downloaderTaskFinished(), [this] {
update();
});
subscribe(controller->gifPauseLevelChanged(), [this] {

View File

@@ -39,7 +39,7 @@ public:
QString tagFromMimeTag(const QString &mimeTag) override {
if (mimeTag.startsWith(qstr("mention://"))) {
auto match = QRegularExpression(":(\\d+)$").match(mimeTag);
if (!match.hasMatch() || match.capturedRef(1).toInt() != AuthSession::CurrentUserId()) {
if (!match.hasMatch() || match.capturedRef(1).toInt() != Auth().userId()) {
return QString();
}
return mimeTag.mid(0, mimeTag.size() - match.capturedLength());
@@ -53,7 +53,7 @@ public:
QString ConvertTagToMimeTag(const QString &tagId) {
if (tagId.startsWith(qstr("mention://"))) {
return tagId + ':' + QString::number(AuthSession::CurrentUserId());
return tagId + ':' + QString::number(Auth().userId());
}
return tagId;
}

View File

@@ -74,9 +74,9 @@ void ApplyArchivedResult(const MTPDmessages_stickerSetInstallResultArchive &d) {
}
if (!setsToRequest.isEmpty()) {
for (auto i = setsToRequest.cbegin(), e = setsToRequest.cend(); i != e; ++i) {
App::api()->scheduleStickerSetRequest(i.key(), i.value());
Auth().api().scheduleStickerSetRequest(i.key(), i.value());
}
App::api()->requestStickerSets();
Auth().api().requestStickerSets();
}
Local::writeInstalledStickers();
Local::writeArchivedStickers();
@@ -342,7 +342,7 @@ void SetsReceived(const QVector<MTPStickerSet> &data, int32 hash) {
}
if (!setsToRequest.isEmpty()) {
auto &api = AuthSession::Current().api();
auto &api = Auth().api();
for (auto i = setsToRequest.cbegin(), e = setsToRequest.cend(); i != e; ++i) {
api.scheduleStickerSetRequest(i.key(), i.value());
}
@@ -551,7 +551,7 @@ void FeaturedSetsReceived(const QVector<MTPStickerSetCovered> &data, const QVect
}
if (!setsToRequest.isEmpty()) {
auto &api = AuthSession::Current().api();
auto &api = Auth().api();
for (auto i = setsToRequest.cbegin(), e = setsToRequest.cend(); i != e; ++i) {
api.scheduleStickerSetRequest(i.key(), i.value());
}
@@ -583,7 +583,7 @@ void GifsReceived(const QVector<MTPDocument> &items, int32 hash) {
Local::writeSavedGifs();
AuthSession::Current().data().savedGifsUpdated().notify();
Auth().data().savedGifsUpdated().notify();
}
StickerPack GetListByEmoji(gsl::not_null<EmojiPtr> emoji) {
@@ -623,9 +623,9 @@ StickerPack GetListByEmoji(gsl::not_null<EmojiPtr> emoji) {
}
if (!setsToRequest.isEmpty()) {
for (auto i = setsToRequest.cbegin(), e = setsToRequest.cend(); i != e; ++i) {
AuthSession::Current().api().scheduleStickerSetRequest(i.key(), i.value());
Auth().api().scheduleStickerSetRequest(i.key(), i.value());
}
AuthSession::Current().api().requestStickerSets();
Auth().api().requestStickerSets();
}
return result;
}

View File

@@ -118,7 +118,7 @@ StickersListWidget::Footer::Footer(gsl::not_null<StickersListWidget*> parent) :
_iconsLeft = (st::emojiPanWidth - kVisibleIconsCount * st::emojiCategory.width) / 2;
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
subscribe(Auth().downloaderTaskFinished(), [this] {
update();
});
}
@@ -450,7 +450,7 @@ StickersListWidget::StickersListWidget(QWidget *parent, gsl::not_null<Window::Co
_previewTimer.setSingleShot(true);
connect(&_previewTimer, SIGNAL(timeout()), this, SLOT(onPreview()));
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] {
subscribe(Auth().downloaderTaskFinished(), [this] {
update();
readVisibleSets();
});

View File

@@ -295,7 +295,7 @@ TabbedSelector::TabbedSelector(QWidget *parent, gsl::not_null<Window::Controller
Tab { SelectorTab::Stickers, object_ptr<StickersListWidget>(this, controller) },
Tab { SelectorTab::Gifs, object_ptr<GifsListWidget>(this, controller) },
} }
, _currentTabType(AuthSession::Current().data().selectorTab()) {
, _currentTabType(Auth().data().selectorTab()) {
resize(st::emojiPanWidth, st::emojiPanMaxHeight);
for (auto &tab : _tabs) {
@@ -487,7 +487,7 @@ void TabbedSelector::hideFinished() {
}
void TabbedSelector::showStarted() {
AuthSession::Current().api().updateStickers();
Auth().api().updateStickers();
currentTab()->widget()->refreshRecent();
currentTab()->widget()->preloadImages();
_a_slide.finish();
@@ -665,8 +665,8 @@ void TabbedSelector::switchTab() {
_a_slide.start([this] { update(); }, 0., 1., st::emojiPanSlideDuration, anim::linear);
update();
AuthSession::Current().data().setSelectorTab(_currentTabType);
AuthSession::Current().saveDataDelayed(kSaveChosenTabTimeout);
Auth().data().setSelectorTab(_currentTabType);
Auth().saveDataDelayed(kSaveChosenTabTimeout);
}
gsl::not_null<EmojiListWidget*> TabbedSelector::emoji() const {