|
本帖最后由 Qter 于 2020-3-14 14:26 编辑
------用户名更新-------
App::main()->contactsList()
\Telegram\SourceFiles\mainwidget.h
object_ptr<DialogsWidget> _dialogs;
_dialogs->contactsList()
\Telegram\SourceFiles\dialogs\dialogs_widget.h
QPointer<DialogsInner> _inner;
_inner->contactsList();
\Telegram\SourceFiles\dialogs\dialogs_inner_widget.h
std::unique_ptr<Dialogs::IndexedList> _contacts;
return _contacts.get();
void DialogsInner::handlePeerNameChange(...) {
_contacts->peerNameChanged(peer, oldLetters);
}
subscribe(Notify:: PeerUpdated(), Notify:: PeerUpdatedHandler(changes, [=](const Notify:: PeerUpdate &update) {
if (update.flags & UpdateFlag::NameChanged) {
handlePeerNameChange(update.peer, update.oldNameFirstLetters);
}
}
\Telegram\SourceFiles\data\data_peer.cpp
void PeerData::updateNameDelayed(...)
{
Notify:: PeerUpdated().notify(update, true);
}
\Telegram\SourceFiles\data\data_user.cpp
void UserData::setName(...)
{
updateNameDelayed(newFullName, newPhoneName, newUsername);
}
客户端添加联系人等网络返回时也会调用,重点还是下面的调用
\Telegram\SourceFiles\mainwidget.cpp
void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_updateUserName: { -- 0xa7332b73, 对应scheme.tl中的updateUserName#a7332b73 user_id:int first_name:string last_name:string username:string = Update;
user->setName(
TextUtilities::SingleLine(user->firstName),
TextUtilities::SingleLine(user->lastName),
user->nameOrPhone,
TextUtilities::SingleLine(qs(d.vusername)));
}
}
void MainWidget::feedUpdates(const MTPUpdates &updates, uint64 randomId) {
case mtpc_updateShort: { = 0x78d4dec1, updateShort#78d4dec1 update:Update date:int = Updates;
auto &d = updates.c_updateShort();
feedUpdate(d.vupdate);
} break;
}
\Telegram\SourceFiles\apiwrap.cpp
void ApiWrap::applyUpdates(
const MTPUpdates &updates,
uint64 sentMessageRandomId) {
App::main()->feedUpdates(updates, sentMessageRandomId);
}
这里调用地方比较多了 如下创建群组...
\Telegram\SourceFiles\boxes\add_contact_box.cpp
_creationRequestId = request(MTPmessages_CreateChat(
MTP_vector<MTPInputUser>(inputs),
MTP_string(title)
)).done([=](const MTPUpdates &result) {
auto image = _photo->takeResultImage();
Ui::hideLayer();
Auth().api().applyUpdates(result);
即当一个地方发生了网络请求,等数据回来后,要通知到其它需要显示的地方,使数据显示同步
|
|