2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +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

@@ -94,7 +94,7 @@ DialogsInner::DialogsInner(QWidget *parent, gsl::not_null<Window::Controller*> c
_cancelSearchFromUser->setClickedCallback([this] { searchFromUserChanged.notify(nullptr); });
_cancelSearchFromUser->hide();
subscribe(AuthSession::CurrentDownloaderTaskFinished(), [this] { update(); });
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
itemRemoved(item);
});
@@ -219,7 +219,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion &region, bool paintingO
if (!paintingOther) {
p.setFont(st::noContactsFont);
p.setPen(st::noContactsColor);
p.drawText(QRect(0, 0, fullWidth, st::noContactsHeight - (AuthSession::Current().data().contactsLoaded().value() ? st::noContactsFont->height : 0)), lang(AuthSession::Current().data().contactsLoaded().value() ? lng_no_chats : lng_contacts_loading), style::al_center);
p.drawText(QRect(0, 0, fullWidth, st::noContactsHeight - (Auth().data().contactsLoaded().value() ? st::noContactsFont->height : 0)), lang(Auth().data().contactsLoaded().value() ? lng_no_chats : lng_contacts_loading), style::al_center);
}
}
} else if (_state == FilteredState || _state == SearchedState) {
@@ -1036,7 +1036,7 @@ void DialogsInner::removeDialog(History *history) {
if (_dialogsImportant) {
history->removeFromChatList(Dialogs::Mode::Important, _dialogsImportant.get());
}
AuthSession::Current().notifications().clearFromHistory(history);
Auth().notifications().clearFromHistory(history);
if (_contacts->contains(history->peer->id)) {
if (!_contactsNoDialogs->contains(history->peer->id)) {
_contactsNoDialogs->addByName(history);
@@ -1465,8 +1465,8 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
}
if (!channel->amCreator()) {
if (auto topMsg = App::histItemById(channel, d.vtop_message.v)) {
if (topMsg->date <= date(channel->date) && App::api()) {
App::api()->requestSelfParticipant(channel);
if (topMsg->date <= date(channel->date)) {
Auth().api().requestSelfParticipant(channel);
}
}
}
@@ -1576,7 +1576,7 @@ void DialogsInner::contactsReceived(const QVector<MTPContact> &result) {
if (contact.type() != mtpc_contact) continue;
auto userId = contact.c_contact().vuser_id.v;
if (userId == AuthSession::CurrentUserId() && App::self()) {
if (userId == Auth().userId() && App::self()) {
if (App::self()->contact < 1) {
App::self()->contact = 1;
Notify::userIsContactChanged(App::self());
@@ -1664,7 +1664,7 @@ void DialogsInner::refresh(bool toTop) {
if (_state == DefaultState) {
if (shownDialogs()->isEmpty()) {
h = st::noContactsHeight;
if (AuthSession::Current().data().contactsLoaded().value()) {
if (Auth().data().contactsLoaded().value()) {
if (_addContactLnk->isHidden()) _addContactLnk->show();
} else {
if (!_addContactLnk->isHidden()) _addContactLnk->hide();
@@ -1912,7 +1912,7 @@ void DialogsInner::loadPeerPhotos() {
auto yFrom = _visibleTop;
auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1);
AuthSession::Current().downloader().clearPriorities();
Auth().downloader().clearPriorities();
if (_state == DefaultState) {
auto otherStart = shownDialogs()->size() * st::dialogsRowHeight;
if (yFrom < otherStart) {

View File

@@ -77,7 +77,7 @@ void ChatSearchFromController::rebuildRows() {
auto now = unixtime();
QMultiMap<int32, UserData*> ordered;
if (_chat->noParticipantInfo()) {
AuthSession::Current().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();

View File

@@ -338,7 +338,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
} break;
}
if (!AuthSession::Current().data().contactsLoaded().value() && !_contactsRequestId) {
if (!Auth().data().contactsLoaded().value() && !_contactsRequestId) {
_contactsRequestId = MTP::send(MTPcontacts_GetContacts(MTP_int(0)), rpcDone(&DialogsWidget::contactsReceived), rpcFail(&DialogsWidget::contactsFailed));
}
@@ -395,9 +395,9 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
_dialogsRequestId = 0;
loadDialogs();
AuthSession::Current().data().moreChatsLoaded().notify();
Auth().data().moreChatsLoaded().notify();
if (_dialogsFull) {
AuthSession::Current().data().allChatsLoaded().set(true);
Auth().data().allChatsLoaded().set(true);
}
}
@@ -432,7 +432,7 @@ void DialogsWidget::pinnedDialogsReceived(const MTPmessages_PeerDialogs &dialogs
_pinnedDialogsRequestId = 0;
_pinnedDialogsReceived = true;
AuthSession::Current().data().moreChatsLoaded().notify();
Auth().data().moreChatsLoaded().notify();
}
bool DialogsWidget::dialogsFailed(const RPCError &error, mtpRequestId requestId) {
@@ -598,7 +598,7 @@ void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &result) {
App::feedUsers(d.vusers);
_inner->contactsReceived(d.vcontacts.v);
}
AuthSession::Current().data().contactsLoaded().set(true);
Auth().data().contactsLoaded().set(true);
}
bool DialogsWidget::contactsFailed(const RPCError &error) {