|
本帖最后由 Qter 于 2020-3-26 09:36 编辑
void DialogsWidget::dialogsReceived(..){
Auth().api().requestContacts(); }
void ApiWrap::requestContacts() {
if (_session->data().contactsLoaded().value() || _contactsRequestId) {
return;
}
_contactsRequestId = request(MTPcontacts_GetContacts(
MTP_int(0)
)).done([=](const MTPcontacts_Contacts &result) {
_contactsRequestId = 0;
if (result.type() == mtpc_contacts_contactsNotModified) {
return;
}
Assert(result.type() == mtpc_contacts_contacts);
const auto &d = result.c_contacts_contacts();
_session->data().processUsers(d.vusers);
for (const auto &contact : d.vcontacts.v) {
if (contact.type() != mtpc_contact) continue;
const auto userId = contact.c_contact().vuser_id.v;
if (userId == _session->userId()) {
_session->user()->setContactStatus(
UserData::ContactStatus::Contact);
}
}
_session->data().contactsLoaded().set(true);
}).fail([=](const RPCError &error) {
_contactsRequestId = 0;
}).send();
}
session
App::main() --> mainwidget.h
Dialogs::IndexedList *MainWidget::contactsList() {
return _dialogs->contactsList();
}
object_ptr<DialogsWidget> _dialogs;
DialogsWidget
return _inner->contactsList();
QPointer<DialogsInner> _inner;
return _contacts.get();
std::unique_ptr<Dialogs::IndexedList> _contacts;
QMap<uint64, QSet<uint64>> _mapUser2Group;
////////////////
void MainWidget::start() {
MTP::send(MTPupdates_GetState(), rpcDone(&MainWidget::gotState));
/////////////////////////
/////////////////
DialogsWidget:ialogsWidget
构造函数中调用loadDialogs
void DialogsWidget::loadDialogs() {
_dialogsRequestId = MTP::send(
MTPmessages_GetDialogs(
MTP_flags(flags),
//MTP_int(feedId), // #feed
MTP_int(_dialogsOffsetDate),
MTP_int(_dialogsOffsetId),
_dialogsOffsetPeer
? _dialogsOffsetPeer->input
: MTP_inputPeerEmpty(),
MTP_int(loadCount),
MTP_int(hash)),
rpcDone(&DialogsWidget::dialogsReceived),
rpcFail(&DialogsWidget::dialogsFailed));
if (!_pinnedDialogsReceived) {
loadPinnedDialogs();
}
refreshLoadMoreButton();
}
/////////////////
DialogsWidget:ialogsWidget
在构造函数中调用
////////////
|
|