2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 23:55:12 +00:00

Better special config implementation.

This commit is contained in:
John Preston
2018-05-02 22:27:03 +03:00
parent 95fee543ec
commit 4bf66cb6e9
12 changed files with 200 additions and 85 deletions

View File

@@ -390,7 +390,11 @@ void Messenger::setMtpAuthorization(const QByteArray &serialized) {
void Messenger::startMtp() {
Expects(!_mtproto);
_mtproto = std::make_unique<MTP::Instance>(_dcOptions.get(), MTP::Instance::Mode::Normal, base::take(_private->mtpConfig));
_mtproto = std::make_unique<MTP::Instance>(
_dcOptions.get(),
MTP::Instance::Mode::Normal,
base::take(_private->mtpConfig));
_mtproto->setUserPhone(cLoggedPhoneNumber());
_private->mtpConfig.mainDcId = _mtproto->mainDcId();
_mtproto->setStateChangedHandler([](MTP::ShiftedDcId shiftedDcId, int32 state) {
@@ -489,6 +493,20 @@ void Messenger::startLocalStorage() {
}
});
});
subscribe(Global::RefSelfChanged(), [=] {
InvokeQueued(this, [=] {
const auto phone = App::self()
? App::self()->phone()
: QString();
if (cLoggedPhoneNumber() != phone) {
cSetLoggedPhoneNumber(phone);
if (_mtproto) {
_mtproto->setUserPhone(phone);
}
Local::writeSettings();
}
});
});
}
void Messenger::regPhotoUpdate(const PeerId &peer, const FullMsgId &msgId) {