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

Move some calls from App namespace.

This commit is contained in:
John Preston
2019-01-18 16:27:37 +04:00
parent e7804d014d
commit 4111da1dd0
74 changed files with 896 additions and 852 deletions

View File

@@ -95,7 +95,7 @@ void IndexedList::peerNameChanged(
const base::flat_set<QChar> &oldLetters) {
Expects(_sortMode != SortMode::Date);
if (const auto history = App::historyLoaded(peer)) {
if (const auto history = peer->owner().historyLoaded(peer)) {
if (_sortMode == SortMode::Name) {
adjustByName(history, oldLetters);
} else {
@@ -110,7 +110,7 @@ void IndexedList::peerNameChanged(
const base::flat_set<QChar> &oldLetters) {
Expects(_sortMode == SortMode::Date);
if (const auto history = App::historyLoaded(peer)) {
if (const auto history = peer->owner().historyLoaded(peer)) {
adjustNames(list, history, oldLetters);
}
}

View File

@@ -1410,7 +1410,7 @@ void DialogsInner::updateDialogRow(
if (IsServerMsgId(-row.fullId.msg)) {
if (const auto peer = row.key.peer()) {
if (const auto from = peer->migrateFrom()) {
if (const auto migrated = App::historyLoaded(from)) {
if (const auto migrated = from->owner().historyLoaded(from)) {
row = Dialogs::RowDescriptor(
migrated,
FullMsgId(0, -row.fullId.msg));
@@ -1871,7 +1871,7 @@ void DialogsInner::applyDialog(const MTPDdialog &dialog) {
return;
}
const auto history = App::history(peerId);
const auto history = Auth().data().history(peerId);
history->applyDialog(dialog);
if (!history->useProxyPromotion() && !history->isPinnedDialog()) {
@@ -1882,7 +1882,7 @@ void DialogsInner::applyDialog(const MTPDdialog &dialog) {
}
_contactsNoDialogs->del(history);
if (const auto from = history->peer->migrateFrom()) {
if (const auto historyFrom = App::historyLoaded(from)) {
if (const auto historyFrom = from->owner().historyLoaded(from)) {
removeDialog(historyFrom);
}
} else if (const auto to = history->peer->migrateTo()) {
@@ -1912,7 +1912,7 @@ void DialogsInner::addSavedPeersAfter(const QDateTime &date) {
const auto lastPeer = saved.last();
saved.remove(lastDate, lastPeer);
const auto history = App::history(lastPeer);
const auto history = Auth().data().history(lastPeer);
history->setChatListTimeId(ServerTimeFromParsed(lastDate));
_contactsNoDialogs->del(history);
}
@@ -1953,7 +1953,7 @@ bool DialogsInner::searchReceived(
auto msgId = IdFromMessage(message);
auto peerId = PeerFromMessage(message);
auto lastDate = DateFromMessage(message);
if (const auto peer = App::peerLoaded(peerId)) {
if (const auto peer = Auth().data().peerLoaded(peerId)) {
if (lastDate) {
const auto item = Auth().data().addNewMessage(
message,
@@ -2025,14 +2025,14 @@ void DialogsInner::peerSearchReceived(
_peerSearchResults.clear();
_peerSearchResults.reserve(result.size());
for (const auto &mtpPeer : my) {
if (const auto peer = App::peerLoaded(peerFromMTP(mtpPeer))) {
if (const auto peer = Auth().data().peerLoaded(peerFromMTP(mtpPeer))) {
if (alreadyAdded(peer)) {
continue;
}
const auto prev = nullptr, next = nullptr;
const auto position = 0;
auto row = std::make_unique<Dialogs::Row>(
App::history(peer),
peer->owner().history(peer),
prev,
next,
position);
@@ -2047,8 +2047,8 @@ void DialogsInner::peerSearchReceived(
}
}
for (const auto &mtpPeer : result) {
if (const auto peer = App::peerLoaded(peerFromMTP(mtpPeer))) {
if (const auto history = App::historyLoaded(peer)) {
if (const auto peer = Auth().data().peerLoaded(peerFromMTP(mtpPeer))) {
if (const auto history = peer->owner().historyLoaded(peer)) {
if (history->inChatList(Dialogs::Mode::All)) {
continue; // skip existing chats
}
@@ -2071,13 +2071,13 @@ void DialogsInner::userIsContactUpdated(not_null<UserData*> user) {
return;
}
if (user->contactStatus() == UserData::ContactStatus::Contact) {
const auto history = App::history(user->id);
const auto history = user->owner().history(user->id);
_contacts->addByName(history);
if (!shownDialogs()->getRow(history)
&& !_dialogs->contains(history)) {
_contactsNoDialogs->addByName(history);
}
} else if (const auto history = App::historyLoaded(user)) {
} else if (const auto history = user->owner().historyLoaded(user)) {
if (_selected && _selected->history() == history) {
_selected = nullptr;
}
@@ -2196,9 +2196,9 @@ void DialogsInner::searchInChat(Dialogs::Key key, UserData *from) {
_searchInMigrated = nullptr;
if (const auto peer = key.peer()) {
if (const auto migrateTo = peer->migrateTo()) {
return searchInChat(App::history(migrateTo), from);
return searchInChat(peer->owner().history(migrateTo), from);
} else if (const auto migrateFrom = peer->migrateFrom()) {
_searchInMigrated = App::history(migrateFrom);
_searchInMigrated = peer->owner().history(migrateFrom);
}
}
_searchInChat = key;
@@ -2544,7 +2544,7 @@ DialogsInner::ChosenRow DialogsInner::computeChosenRow() const {
};
} else if (base::in_range(_peerSearchSelected, 0, _peerSearchResults.size())) {
return {
App::history(_peerSearchResults[_peerSearchSelected]->peer),
Auth().data().history(_peerSearchResults[_peerSearchSelected]->peer),
Data::UnreadMessagePosition
};
} else if (base::in_range(_searchedSelected, 0, _searchResults.size())) {
@@ -2666,7 +2666,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryBefore(
FullMsgId(NoChannel, ShowAtUnreadMsgId));
}
return Dialogs::RowDescriptor(
App::history(_peerSearchResults.back()->peer),
Auth().data().history(_peerSearchResults.back()->peer),
FullMsgId(NoChannel, ShowAtUnreadMsgId));
}
}
@@ -2683,7 +2683,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryBefore(
for (auto b = _peerSearchResults.cbegin(), i = b + 1, e = _peerSearchResults.cend(); i != e; ++i) {
if ((*i)->peer == whichHistory->peer) {
return Dialogs::RowDescriptor(
App::history((*(i - 1))->peer),
Auth().data().history((*(i - 1))->peer),
FullMsgId(NoChannel, ShowAtUnreadMsgId));
}
}
@@ -2739,7 +2739,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryAfter(
++i;
if (i != e) {
return Dialogs::RowDescriptor(
App::history((*i)->peer),
Auth().data().history((*i)->peer),
FullMsgId(NoChannel, ShowAtUnreadMsgId));
} else if (!_searchResults.empty()) {
return Dialogs::RowDescriptor(
@@ -2758,7 +2758,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryAfter(
FullMsgId(NoChannel, ShowAtUnreadMsgId));
} else if (!_peerSearchResults.empty()) {
return Dialogs::RowDescriptor(
App::history(_peerSearchResults.front()->peer),
Auth().data().history(_peerSearchResults.front()->peer),
FullMsgId(NoChannel, ShowAtUnreadMsgId));
} else if (!_searchResults.empty()) {
return Dialogs::RowDescriptor(
@@ -2786,7 +2786,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryFirst() const {
FullMsgId(NoChannel, ShowAtUnreadMsgId));
} else if (!_peerSearchResults.empty()) {
return Dialogs::RowDescriptor(
App::history(_peerSearchResults.front()->peer),
Auth().data().history(_peerSearchResults.front()->peer),
FullMsgId(NoChannel, ShowAtUnreadMsgId));
} else if (!_searchResults.empty()) {
return Dialogs::RowDescriptor(
@@ -2811,7 +2811,7 @@ Dialogs::RowDescriptor DialogsInner::chatListEntryLast() const {
_searchResults.back()->item()->fullId());
} else if (!_peerSearchResults.empty()) {
return Dialogs::RowDescriptor(
App::history(_peerSearchResults.back()->peer),
Auth().data().history(_peerSearchResults.back()->peer),
FullMsgId(NoChannel, ShowAtUnreadMsgId));
} else if (!_filterResults.empty()) {
return Dialogs::RowDescriptor(

View File

@@ -310,7 +310,7 @@ void DialogsWidget::createDialog(Dialogs::Key key) {
_inner->createDialog(key);
const auto history = key.history();
if (creating && history && history->peer->migrateFrom()) {
if (const auto migrated = App::historyLoaded(
if (const auto migrated = history->owner().historyLoaded(
history->peer->migrateFrom())) {
if (migrated->inChatList(Dialogs::Mode::All)) {
_inner->removeDialog(migrated);
@@ -445,8 +445,8 @@ void DialogsWidget::dialogsReceived(
const auto [dialogsList, messagesList] = [&] {
const auto process = [&](const auto &data) {
App::feedUsers(data.vusers);
App::feedChats(data.vchats);
Auth().data().processUsers(data.vusers);
Auth().data().processChats(data.vchats);
return std::make_tuple(&data.vdialogs.v, &data.vmessages.v);
};
switch (dialogs.type()) {
@@ -514,7 +514,7 @@ void DialogsWidget::updateDialogsOffset(
if (lastDate) {
_dialogsOffsetDate = lastDate;
_dialogsOffsetId = lastMsgId;
_dialogsOffsetPeer = App::peer(lastPeer);
_dialogsOffsetPeer = Auth().data().peer(lastPeer);
} else {
_dialogsFull = true;
}
@@ -564,8 +564,8 @@ void DialogsWidget::pinnedDialogsReceived(
if (_pinnedDialogsRequestId != requestId) return;
auto &data = result.c_messages_peerDialogs();
App::feedUsers(data.vusers);
App::feedChats(data.vchats);
Auth().data().processUsers(data.vusers);
Auth().data().processChats(data.vchats);
Auth().data().applyPinnedDialogs(data.vdialogs.v);
applyReceivedDialogs(data.vdialogs.v, data.vmessages.v);
@@ -932,8 +932,8 @@ void DialogsWidget::searchReceived(
auto &d = result.c_messages_messages();
if (_searchRequest != 0) {
// Don't apply cached data!
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
Auth().data().processUsers(d.vusers);
Auth().data().processChats(d.vchats);
}
auto &msgs = d.vmessages.v;
if (!_inner->searchReceived(msgs, type, msgs.size())) {
@@ -949,8 +949,8 @@ void DialogsWidget::searchReceived(
auto &d = result.c_messages_messagesSlice();
if (_searchRequest != 0) {
// Don't apply cached data!
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
Auth().data().processUsers(d.vusers);
Auth().data().processChats(d.vchats);
}
auto &msgs = d.vmessages.v;
if (!_inner->searchReceived(msgs, type, d.vcount.v)) {
@@ -979,8 +979,8 @@ void DialogsWidget::searchReceived(
}
if (_searchRequest != 0) {
// Don't apply cached data!
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
Auth().data().processUsers(d.vusers);
Auth().data().processChats(d.vchats);
}
auto &msgs = d.vmessages.v;
if (!_inner->searchReceived(msgs, type, d.vcount.v)) {
@@ -1026,8 +1026,8 @@ void DialogsWidget::peerSearchReceived(
switch (result.type()) {
case mtpc_contacts_found: {
auto &d = result.c_contacts_found();
App::feedUsers(d.vusers);
App::feedChats(d.vchats);
Auth().data().processUsers(d.vusers);
Auth().data().processChats(d.vchats);
_inner->peerSearchReceived(q, d.vmy_results.v, d.vresults.v);
} break;
}
@@ -1186,9 +1186,9 @@ void DialogsWidget::setSearchInChat(Dialogs::Key chat, UserData *from) {
_searchInMigrated = nullptr;
if (const auto peer = chat.peer()) {
if (const auto migrateTo = peer->migrateTo()) {
return setSearchInChat(App::history(migrateTo), from);
return setSearchInChat(peer->owner().history(migrateTo), from);
} else if (const auto migrateFrom = peer->migrateFrom()) {
_searchInMigrated = App::history(migrateFrom);
_searchInMigrated = peer->owner().history(migrateFrom);
}
}
const auto searchInPeerUpdated = (_searchInChat != chat);