Use refs in AuthSession part getters.

Also use only AuthSession data for Contacts/Dialogs loaded state.
This commit is contained in:
John Preston 2017-03-15 19:24:06 +03:00
parent 1027bd431a
commit d91a2403b0
24 changed files with 54 additions and 73 deletions

View File

@ -1015,7 +1015,7 @@ PeerData *ApiWrap::notifySettingReceived(MTPInputNotifyPeer notifyPeer, const MT
} }
} break; } break;
} }
AuthSession::Current().notifications()->checkDelayed(); AuthSession::Current().notifications().checkDelayed();
return requestedPeer; return requestedPeer;
} }

View File

@ -2012,7 +2012,7 @@ namespace {
dependent->dependencyItemRemoved(item); dependent->dependencyItemRemoved(item);
} }
} }
AuthSession::Current().notifications()->clearFromItem(item); AuthSession::Current().notifications().clearFromItem(item);
if (Global::started() && !App::quitting()) { if (Global::started() && !App::quitting()) {
Global::RefItemRemoved().notify(item, true); Global::RefItemRemoved().notify(item, true);
} }
@ -2321,7 +2321,7 @@ namespace {
if (AuthSession::Exists()) { if (AuthSession::Exists()) {
// Clear notifications to prevent any showNotification() calls while destroying items. // Clear notifications to prevent any showNotification() calls while destroying items.
AuthSession::Current().notifications()->clearAllFast(); AuthSession::Current().notifications().clearAllFast();
} }
histories().clear(); histories().clear();

View File

@ -46,7 +46,7 @@ UserData *AuthSession::CurrentUser() {
} }
base::Observable<void> &AuthSession::CurrentDownloaderTaskFinished() { base::Observable<void> &AuthSession::CurrentDownloaderTaskFinished() {
return Current().downloader()->taskFinished(); return Current().downloader().taskFinished();
} }
bool AuthSession::validateSelf(const MTPUser &user) { bool AuthSession::validateSelf(const MTPUser &user) {

View File

@ -53,14 +53,14 @@ public:
} }
bool validateSelf(const MTPUser &user); bool validateSelf(const MTPUser &user);
Storage::Downloader *downloader() { Storage::Downloader &downloader() {
return _downloader.get(); return *_downloader;
} }
static base::Observable<void> &CurrentDownloaderTaskFinished(); static base::Observable<void> &CurrentDownloaderTaskFinished();
Window::Notifications::System *notifications() { Window::Notifications::System &notifications() {
return _notifications.get(); return *_notifications;
} }
class Data { class Data {

View File

@ -844,7 +844,7 @@ void ContactsBox::Inner::loadProfilePhotos() {
auto yFrom = _visibleTop - _rowsTop; auto yFrom = _visibleTop - _rowsTop;
auto yTo = yFrom + (_visibleBottom - _visibleTop) * 5; auto yTo = yFrom + (_visibleBottom - _visibleTop) * 5;
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
if (yTo < 0) return; if (yTo < 0) return;
if (yFrom < 0) yFrom = 0; if (yFrom < 0) yFrom = 0;
@ -1097,7 +1097,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) {
QString text; QString text;
skip = 0; skip = 0;
if (bot()) { if (bot()) {
text = lang((cDialogsReceived() && !_searching) ? (sharingBotGame() ? lng_bot_no_chats : lng_bot_no_groups) : lng_contacts_loading); text = lang((AuthSession::Current().data().allChatsLoaded().value() && !_searching) ? (sharingBotGame() ? lng_bot_no_chats : lng_bot_no_groups) : lng_contacts_loading);
} else if (_chat && _membersFilter == MembersFilter::Admins) { } else if (_chat && _membersFilter == MembersFilter::Admins) {
text = lang(lng_contacts_loading); text = lang(lng_contacts_loading);
p.fillRect(0, 0, width(), _aboutHeight - st::contactsPadding.bottom() - st::lineWidth, st::contactsAboutBg); p.fillRect(0, 0, width(), _aboutHeight - st::contactsPadding.bottom() - st::lineWidth, st::contactsAboutBg);
@ -1106,7 +1106,7 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) {
int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right(); int aboutw = width() - st::contactsPadding.left() - st::contactsPadding.right();
(_allAdmins->checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsAboutTop, aboutw); (_allAdmins->checked() ? _aboutAllAdmins : _aboutAdmins).draw(p, st::contactsPadding.left(), st::contactsAboutTop, aboutw);
p.translate(0, _aboutHeight); p.translate(0, _aboutHeight);
} else if (cContactsReceived() && !_searching) { } else if (AuthSession::Current().data().contactsLoaded().value() && !_searching) {
text = lang(lng_no_contacts); text = lang(lng_no_contacts);
skip = st::noContactsFont->height; skip = st::noContactsFont->height;
} else { } else {
@ -1122,11 +1122,11 @@ void ContactsBox::Inner::paintEvent(QPaintEvent *e) {
p.setPen(st::noContactsColor); p.setPen(st::noContactsColor);
QString text; QString text;
if (bot()) { if (bot()) {
text = lang((cDialogsReceived() && !_searching) ? (sharingBotGame() ? lng_bot_chats_not_found : lng_bot_groups_not_found) : lng_contacts_loading); text = lang((AuthSession::Current().data().allChatsLoaded().value() && !_searching) ? (sharingBotGame() ? lng_bot_chats_not_found : lng_bot_groups_not_found) : lng_contacts_loading);
} else if (_chat && _membersFilter == MembersFilter::Admins) { } else if (_chat && _membersFilter == MembersFilter::Admins) {
text = lang(_chat->participants.isEmpty() ? lng_contacts_loading : lng_contacts_not_found); text = lang(_chat->participants.isEmpty() ? lng_contacts_loading : lng_contacts_not_found);
} else { } else {
text = lang((cContactsReceived() && !_searching) ? lng_contacts_not_found : lng_contacts_loading); text = lang((AuthSession::Current().data().contactsLoaded().value() && !_searching) ? lng_contacts_not_found : lng_contacts_loading);
} }
p.drawText(QRect(0, 0, width(), st::noContactsHeight), text, style::al_center); p.drawText(QRect(0, 0, width(), st::noContactsHeight), text, style::al_center);
} else { } else {
@ -1769,7 +1769,7 @@ void ContactsBox::Inner::refresh() {
if (!_addContactLnk->isHidden()) _addContactLnk->hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();
resize(width(), _rowsTop + _aboutHeight + st::noContactsHeight + st::contactsMarginBottom); resize(width(), _rowsTop + _aboutHeight + st::noContactsHeight + st::contactsMarginBottom);
} else { } else {
if (cContactsReceived() && !bot()) { if (AuthSession::Current().data().contactsLoaded().value() && !bot()) {
if (_addContactLnk->isHidden()) _addContactLnk->show(); if (_addContactLnk->isHidden()) _addContactLnk->show();
} else { } else {
if (!_addContactLnk->isHidden()) _addContactLnk->hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();

View File

@ -344,7 +344,7 @@ void MembersBox::Inner::loadProfilePhotos() {
auto yFrom = _visibleTop; auto yFrom = _visibleTop;
auto yTo = yFrom + (_visibleBottom - _visibleTop) * 5; auto yTo = yFrom + (_visibleBottom - _visibleTop) * 5;
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
if (yTo < 0) return; if (yTo < 0) return;
if (yFrom < 0) yFrom = 0; if (yFrom < 0) yFrom = 0;

View File

@ -194,7 +194,7 @@ void NotificationsBox::countChanged() {
if (currentCount() != Global::NotificationsCount()) { if (currentCount() != Global::NotificationsCount()) {
Global::SetNotificationsCount(currentCount()); Global::SetNotificationsCount(currentCount());
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::MaxCount); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::MaxCount);
Local::writeUserSettings(); Local::writeUserSettings();
} }
} }
@ -351,7 +351,7 @@ void NotificationsBox::setOverCorner(Notify::ScreenCorner corner) {
_isOverCorner = true; _isOverCorner = true;
setCursor(style::cur_pointer); setCursor(style::cur_pointer);
Global::SetNotificationsDemoIsShown(true); Global::SetNotificationsDemoIsShown(true);
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::DemoIsShown); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::DemoIsShown);
} }
_overCorner = corner; _overCorner = corner;
@ -386,7 +386,7 @@ void NotificationsBox::clearOverCorner() {
_isOverCorner = false; _isOverCorner = false;
setCursor(style::cur_default); setCursor(style::cur_default);
Global::SetNotificationsDemoIsShown(false); Global::SetNotificationsDemoIsShown(false);
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::DemoIsShown); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::DemoIsShown);
for_const (auto &samples, _cornerSamples) { for_const (auto &samples, _cornerSamples) {
for_const (auto widget, samples) { for_const (auto widget, samples) {
@ -413,7 +413,7 @@ void NotificationsBox::mouseReleaseEvent(QMouseEvent *e) {
if (_chosenCorner != Global::NotificationsCorner()) { if (_chosenCorner != Global::NotificationsCorner()) {
Global::SetNotificationsCorner(_chosenCorner); Global::SetNotificationsCorner(_chosenCorner);
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::Corner); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::Corner);
Local::writeUserSettings(); Local::writeUserSettings();
} }
} }

View File

@ -716,7 +716,7 @@ void PeerListBox::Inner::loadProfilePhotos() {
auto yFrom = _visibleTop; auto yFrom = _visibleTop;
auto yTo = _visibleBottom + (_visibleBottom - _visibleTop) * PreloadHeightsCount; auto yTo = _visibleBottom + (_visibleBottom - _visibleTop) * PreloadHeightsCount;
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
if (yTo < 0) return; if (yTo < 0) return;
if (yFrom < 0) yFrom = 0; if (yFrom < 0) yFrom = 0;

View File

@ -435,7 +435,7 @@ void ShareBox::Inner::loadProfilePhotos(int yFrom) {
yFrom *= _columnCount; yFrom *= _columnCount;
yTo *= _columnCount; yTo *= _columnCount;
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
if (_filter.isEmpty()) { if (_filter.isEmpty()) {
if (!_chatsIndexed->isEmpty()) { if (!_chatsIndexed->isEmpty()) {
auto i = _chatsIndexed->cfind(yFrom, _rowHeight); auto i = _chatsIndexed->cfind(yFrom, _rowHeight);

View File

@ -212,7 +212,7 @@ void DialogsInner::paintRegion(Painter &p, const QRegion &region, bool paintingO
if (!paintingOther) { if (!paintingOther) {
p.setFont(st::noContactsFont); p.setFont(st::noContactsFont);
p.setPen(st::noContactsColor); p.setPen(st::noContactsColor);
p.drawText(QRect(0, 0, fullWidth, st::noContactsHeight - (cContactsReceived() ? st::noContactsFont->height : 0)), lang(cContactsReceived() ? lng_no_chats : lng_contacts_loading), style::al_center); 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);
} }
} }
} else if (_state == FilteredState || _state == SearchedState) { } else if (_state == FilteredState || _state == SearchedState) {
@ -1001,7 +1001,7 @@ void DialogsInner::removeDialog(History *history) {
if (_dialogsImportant) { if (_dialogsImportant) {
history->removeFromChatList(Dialogs::Mode::Important, _dialogsImportant.get()); history->removeFromChatList(Dialogs::Mode::Important, _dialogsImportant.get());
} }
AuthSession::Current().notifications()->clearFromHistory(history); AuthSession::Current().notifications().clearFromHistory(history);
if (_contacts->contains(history->peer->id)) { if (_contacts->contains(history->peer->id)) {
if (!_contactsNoDialogs->contains(history->peer->id)) { if (!_contactsNoDialogs->contains(history->peer->id)) {
_contactsNoDialogs->addByName(history); _contactsNoDialogs->addByName(history);
@ -1650,7 +1650,7 @@ void DialogsInner::refresh(bool toTop) {
if (_state == DefaultState) { if (_state == DefaultState) {
if (shownDialogs()->isEmpty()) { if (shownDialogs()->isEmpty()) {
h = st::noContactsHeight; h = st::noContactsHeight;
if (cContactsReceived()) { if (AuthSession::Current().data().contactsLoaded().value()) {
if (_addContactLnk->isHidden()) _addContactLnk->show(); if (_addContactLnk->isHidden()) _addContactLnk->show();
} else { } else {
if (!_addContactLnk->isHidden()) _addContactLnk->hide(); if (!_addContactLnk->isHidden()) _addContactLnk->hide();
@ -1891,7 +1891,7 @@ void DialogsInner::loadPeerPhotos() {
auto yFrom = _visibleTop; auto yFrom = _visibleTop;
auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1); auto yTo = _visibleTop + (_visibleBottom - _visibleTop) * (PreloadHeightsCount + 1);
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
if (_state == DefaultState) { if (_state == DefaultState) {
auto otherStart = shownDialogs()->size() * st::dialogsRowHeight; auto otherStart = shownDialogs()->size() * st::dialogsRowHeight;
if (yFrom < otherStart) { if (yFrom < otherStart) {
@ -2494,7 +2494,7 @@ void DialogsWidget::dialogsReceived(const MTPmessages_Dialogs &dialogs, mtpReque
} break; } break;
} }
if (!cContactsReceived() && !_contactsRequestId) { if (!AuthSession::Current().data().contactsLoaded().value() && !_contactsRequestId) {
_contactsRequestId = MTP::send(MTPcontacts_GetContacts(MTP_string("")), rpcDone(&DialogsWidget::contactsReceived), rpcFail(&DialogsWidget::contactsFailed)); _contactsRequestId = MTP::send(MTPcontacts_GetContacts(MTP_string("")), rpcDone(&DialogsWidget::contactsReceived), rpcFail(&DialogsWidget::contactsFailed));
} }
@ -2726,7 +2726,6 @@ void DialogsWidget::loadDialogs() {
if (_dialogsRequestId) return; if (_dialogsRequestId) return;
if (_dialogsFull) { if (_dialogsFull) {
_inner->addAllSavedPeers(); _inner->addAllSavedPeers();
cSetDialogsReceived(true);
return; return;
} }
@ -2748,14 +2747,11 @@ void DialogsWidget::loadPinnedDialogs() {
void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &result) { void DialogsWidget::contactsReceived(const MTPcontacts_Contacts &result) {
_contactsRequestId = 0; _contactsRequestId = 0;
cSetContactsReceived(true);
if (result.type() == mtpc_contacts_contacts) { if (result.type() == mtpc_contacts_contacts) {
auto &d = result.c_contacts_contacts(); auto &d = result.c_contacts_contacts();
App::feedUsers(d.vusers); App::feedUsers(d.vusers);
_inner->contactsReceived(d.vcontacts.v); _inner->contactsReceived(d.vcontacts.v);
} }
if (App::main()) App::main()->contactsReceived();
AuthSession::Current().data().contactsLoaded().set(true); AuthSession::Current().data().contactsLoaded().set(true);
} }

View File

@ -1505,7 +1505,7 @@ MsgId History::inboxRead(MsgId upTo) {
} }
showFrom = nullptr; showFrom = nullptr;
AuthSession::Current().notifications()->clearFromHistory(this); AuthSession::Current().notifications().clearFromHistory(this);
return upTo; return upTo;
} }

View File

@ -2034,7 +2034,7 @@ bool HistoryService::updateDependent(bool force) {
updateDependentText(); updateDependentText();
} }
if (force && gotDependencyItem) { if (force && gotDependencyItem) {
AuthSession::Current().notifications()->checkDelayed(); AuthSession::Current().notifications().checkDelayed();
} }
return (dependent->msg || !dependent->msgId); return (dependent->msg || !dependent->msgId);
} }

View File

@ -3342,6 +3342,12 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) { subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
itemRemoved(item); itemRemoved(item);
}); });
subscribe(AuthSession::Current().data().contactsLoaded(), [this](bool) {
if (_peer) {
updateReportSpamStatus();
updateControlsVisibility();
}
});
} }
void HistoryWidget::start() { void HistoryWidget::start() {
@ -4430,7 +4436,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
if (_peer) { if (_peer) {
App::forgetMedia(); App::forgetMedia();
_serviceImageCacheSize = imageCacheSize(); _serviceImageCacheSize = imageCacheSize();
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
_history = App::history(_peer->id); _history = App::history(_peer->id);
_migrated = _peer->migrateFrom() ? App::history(_peer->migrateFrom()->id) : 0; _migrated = _peer->migrateFrom() ? App::history(_peer->migrateFrom()->id) : 0;
@ -4520,12 +4526,6 @@ void HistoryWidget::clearAllLoadRequests() {
_preloadRequest = _preloadDownRequest = _firstLoadRequest = 0; _preloadRequest = _preloadDownRequest = _firstLoadRequest = 0;
} }
void HistoryWidget::contactsReceived() {
if (!_peer) return;
updateReportSpamStatus();
updateControlsVisibility();
}
void HistoryWidget::updateAfterDrag() { void HistoryWidget::updateAfterDrag() {
if (_list) _list->dragActionUpdate(QCursor::pos()); if (_list) _list->dragActionUpdate(QCursor::pos());
} }
@ -4607,7 +4607,7 @@ void HistoryWidget::updateReportSpamStatus() {
} }
} }
} }
if (!cContactsReceived() || _firstLoadRequest) { if (!AuthSession::Current().data().contactsLoaded().value() || _firstLoadRequest) {
_reportSpamStatus = dbiprsUnknown; _reportSpamStatus = dbiprsUnknown;
} else if (_peer->isUser() && _peer->asUser()->contact > 0) { } else if (_peer->isUser() && _peer->asUser()->contact > 0) {
_reportSpamStatus = dbiprsHidden; _reportSpamStatus = dbiprsHidden;
@ -4886,7 +4886,7 @@ void HistoryWidget::newUnreadMsg(History *history, HistoryItem *item) {
return; return;
} }
} }
AuthSession::Current().notifications()->schedule(history, item); AuthSession::Current().notifications().schedule(history, item);
history->setUnreadCount(history->unreadCount() + 1); history->setUnreadCount(history->unreadCount() + 1);
} }

View File

@ -675,7 +675,6 @@ public:
void applyCloudDraft(History *history); void applyCloudDraft(History *history);
void contactsReceived();
void updateHistoryDownPosition(); void updateHistoryDownPosition();
void updateHistoryDownVisibility(); void updateHistoryDownVisibility();

View File

@ -2182,10 +2182,6 @@ void MainWidget::clearBotStartToken(PeerData *peer) {
} }
} }
void MainWidget::contactsReceived() {
_history->contactsReceived();
}
void MainWidget::updateAfterDrag() { void MainWidget::updateAfterDrag() {
if (_overview) { if (_overview) {
_overview->updateAfterDrag(); _overview->updateAfterDrag();
@ -4187,7 +4183,7 @@ void MainWidget::applyNotifySetting(const MTPNotifyPeer &peer, const MTPPeerNoti
if (!h) h = App::history(updatePeer->id); if (!h) h = App::history(updatePeer->id);
int32 changeIn = 0; int32 changeIn = 0;
if (isNotifyMuted(setTo, &changeIn)) { if (isNotifyMuted(setTo, &changeIn)) {
AuthSession::Current().notifications()->clearFromHistory(h); AuthSession::Current().notifications().clearFromHistory(h);
h->setMute(true); h->setMute(true);
App::regMuted(updatePeer, changeIn); App::regMuted(updatePeer, changeIn);
} else { } else {

View File

@ -357,8 +357,6 @@ public:
void choosePeer(PeerId peerId, MsgId showAtMsgId); // does offerPeer or showPeerHistory void choosePeer(PeerId peerId, MsgId showAtMsgId); // does offerPeer or showPeerHistory
void clearBotStartToken(PeerData *peer); void clearBotStartToken(PeerData *peer);
void contactsReceived();
void ptsWaiterStartTimerFor(ChannelData *channel, int32 ms); // ms <= 0 - stop timer void ptsWaiterStartTimerFor(ChannelData *channel, int32 ms); // ms <= 0 - stop timer
void feedUpdates(const MTPUpdates &updates, uint64 randomId = 0); void feedUpdates(const MTPUpdates &updates, uint64 randomId = 0);
void feedUpdate(const MTPUpdate &update); void feedUpdate(const MTPUpdate &update);

View File

@ -228,7 +228,7 @@ void MainWindow::clearPasscode() {
} else { } else {
_main->showAnimated(bg, true); _main->showAnimated(bg, true);
} }
AuthSession::Current().notifications()->updateAll(); AuthSession::Current().notifications().updateAll();
updateGlobalMenu(); updateGlobalMenu();
if (_main) { if (_main) {
@ -253,7 +253,7 @@ void MainWindow::setupPasscode() {
} }
_shouldLockAt = 0; _shouldLockAt = 0;
if (AuthSession::Exists()) { if (AuthSession::Exists()) {
AuthSession::Current().notifications()->updateAll(); AuthSession::Current().notifications().updateAll();
} }
updateGlobalMenu(); updateGlobalMenu();
} }
@ -280,8 +280,6 @@ void MainWindow::checkAutoLock() {
} }
void MainWindow::setupIntro() { void MainWindow::setupIntro() {
cSetContactsReceived(false);
cSetDialogsReceived(false);
if (_intro && !_intro->isHidden() && !_main) return; if (_intro && !_intro->isHidden() && !_main) return;
Ui::hideSettingsAndLayer(true); Ui::hideSettingsAndLayer(true);
@ -830,9 +828,9 @@ void MainWindow::toggleDisplayNotifyFromTray() {
} }
} }
Local::writeUserSettings(); Local::writeUserSettings();
AuthSession::Current().notifications()->settingsChanged().notify(Window::Notifications::ChangeType::DesktopEnabled); AuthSession::Current().notifications().settingsChanged().notify(Window::Notifications::ChangeType::DesktopEnabled);
if (soundNotifyChanged) { if (soundNotifyChanged) {
AuthSession::Current().notifications()->settingsChanged().notify(Window::Notifications::ChangeType::SoundEnabled); AuthSession::Current().notifications().settingsChanged().notify(Window::Notifications::ChangeType::SoundEnabled);
} }
} }

View File

@ -1168,7 +1168,7 @@ void MediaView::displayPhoto(PhotoData *photo, HistoryItem *item) {
} }
_zoomToScreen = 0; _zoomToScreen = 0;
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
_full = -1; _full = -1;
_current = QPixmap(); _current = QPixmap();
_down = OverNone; _down = OverNone;

View File

@ -61,7 +61,7 @@ OverviewInner::OverviewInner(OverviewWidget *overview, Ui::ScrollArea *scroll, P
, _cancelSearch(this, st::dialogsCancelSearch) , _cancelSearch(this, st::dialogsCancelSearch)
, _itemsToBeLoaded(LinksOverviewPerPage * 2) , _itemsToBeLoaded(LinksOverviewPerPage * 2)
, _width(st::windowMinWidth) { , _width(st::windowMinWidth) {
subscribe(AuthSession::Current().downloader()->taskFinished(), [this] { update(); }); subscribe(AuthSession::Current().downloader().taskFinished(), [this] { update(); });
subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) { subscribe(Global::RefItemRemoved(), [this](HistoryItem *item) {
itemRemoved(item); itemRemoved(item);
}); });
@ -1919,7 +1919,7 @@ void OverviewWidget::clear() {
} }
void OverviewWidget::onScroll() { void OverviewWidget::onScroll() {
AuthSession::Current().downloader()->clearPriorities(); AuthSession::Current().downloader().clearPriorities();
int32 preloadThreshold = _scroll->height() * 5; int32 preloadThreshold = _scroll->height() * 5;
bool needToPreload = false; bool needToPreload = false;
do { do {

View File

@ -114,9 +114,6 @@ QString gPlatformString;
QUrl gUpdateURL; QUrl gUpdateURL;
bool gIsElCapitan = false; bool gIsElCapitan = false;
bool gContactsReceived = false;
bool gDialogsReceived = false;
int gOtherOnline = 0; int gOtherOnline = 0;
SavedPeers gSavedPeers; SavedPeers gSavedPeers;

View File

@ -257,9 +257,6 @@ DeclareReadSetting(QString, PlatformString);
DeclareReadSetting(bool, IsElCapitan); DeclareReadSetting(bool, IsElCapitan);
DeclareReadSetting(QUrl, UpdateURL); DeclareReadSetting(QUrl, UpdateURL);
DeclareSetting(bool, ContactsReceived);
DeclareSetting(bool, DialogsReceived);
DeclareSetting(int, OtherOnline); DeclareSetting(int, OtherOnline);
class PeerData; class PeerData;

View File

@ -42,7 +42,7 @@ using ChangeType = Window::Notifications::ChangeType;
NotificationsWidget::NotificationsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_notify)) { NotificationsWidget::NotificationsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_notify)) {
createControls(); createControls();
subscribe(AuthSession::Current().notifications()->settingsChanged(), [this](ChangeType type) { subscribe(AuthSession::Current().notifications().settingsChanged(), [this](ChangeType type) {
if (type == ChangeType::DesktopEnabled) { if (type == ChangeType::DesktopEnabled) {
desktopEnabledUpdated(); desktopEnabledUpdated();
} else if (type == ChangeType::ViewParams) { } else if (type == ChangeType::ViewParams) {
@ -101,7 +101,7 @@ void NotificationsWidget::onDesktopNotifications() {
} }
Global::SetDesktopNotify(_desktopNotifications->checked()); Global::SetDesktopNotify(_desktopNotifications->checked());
Local::writeUserSettings(); Local::writeUserSettings();
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::DesktopEnabled); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::DesktopEnabled);
} }
void NotificationsWidget::desktopEnabledUpdated() { void NotificationsWidget::desktopEnabledUpdated() {
@ -124,7 +124,7 @@ void NotificationsWidget::onShowSenderName() {
} }
Global::SetNotifyView(viewParam); Global::SetNotifyView(viewParam);
Local::writeUserSettings(); Local::writeUserSettings();
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::ViewParams); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::ViewParams);
} }
void NotificationsWidget::onShowMessagePreview() { void NotificationsWidget::onShowMessagePreview() {
@ -142,7 +142,7 @@ void NotificationsWidget::onShowMessagePreview() {
Global::SetNotifyView(viewParam); Global::SetNotifyView(viewParam);
Local::writeUserSettings(); Local::writeUserSettings();
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::ViewParams); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::ViewParams);
} }
void NotificationsWidget::viewParamUpdated() { void NotificationsWidget::viewParamUpdated() {
@ -157,7 +157,7 @@ void NotificationsWidget::onNativeNotifications() {
Global::SetNativeNotifications(_nativeNotifications->checked()); Global::SetNativeNotifications(_nativeNotifications->checked());
Local::writeUserSettings(); Local::writeUserSettings();
AuthSession::Current().notifications()->createManager(); AuthSession::Current().notifications().createManager();
_advanced->toggleAnimated(!Global::NativeNotifications()); _advanced->toggleAnimated(!Global::NativeNotifications());
} }
@ -173,13 +173,13 @@ void NotificationsWidget::onPlaySound() {
Global::SetSoundNotify(_playSound->checked()); Global::SetSoundNotify(_playSound->checked());
Local::writeUserSettings(); Local::writeUserSettings();
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::SoundEnabled); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::SoundEnabled);
} }
void NotificationsWidget::onIncludeMuted() { void NotificationsWidget::onIncludeMuted() {
Global::SetIncludeMuted(_includeMuted->checked()); Global::SetIncludeMuted(_includeMuted->checked());
Local::writeUserSettings(); Local::writeUserSettings();
AuthSession::Current().notifications()->settingsChanged().notify(ChangeType::IncludeMuted); AuthSession::Current().notifications().settingsChanged().notify(ChangeType::IncludeMuted);
} }
} // namespace Settings } // namespace Settings

View File

@ -71,7 +71,7 @@ namespace {
} }
FileLoader::FileLoader(const QString &toFile, int32 size, LocationType locationType, LoadToCacheSetting toCache, LoadFromCloudSetting fromCloud, bool autoLoading) FileLoader::FileLoader(const QString &toFile, int32 size, LocationType locationType, LoadToCacheSetting toCache, LoadFromCloudSetting fromCloud, bool autoLoading)
: _downloader(AuthSession::Current().downloader()) : _downloader(&AuthSession::Current().downloader())
, _autoLoading(autoLoading) , _autoLoading(autoLoading)
, _file(toFile) , _file(toFile)
, _fname(toFile) , _fname(toFile)

View File

@ -64,7 +64,7 @@ std::unique_ptr<Manager> Create(System *system) {
} }
Manager::Manager(System *system) : Notifications::Manager(system) { Manager::Manager(System *system) : Notifications::Manager(system) {
subscribe(system->authSession()->downloader()->taskFinished(), [this] { subscribe(system->authSession()->downloader().taskFinished(), [this] {
for_const (auto &notification, _notifications) { for_const (auto &notification, _notifications) {
notification->updatePeerPhoto(); notification->updatePeerPhoto();
} }