2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Replace App::self() with Auth().user().

Always have self Auth().user() when AuthSession exists.
This commit is contained in:
John Preston
2018-09-11 15:50:40 +03:00
parent 12ebae01b0
commit 0c8709ca5f
41 changed files with 227 additions and 230 deletions

View File

@@ -594,7 +594,9 @@ QString Widget::Step::nextButtonText() const {
}
void Widget::Step::finish(const MTPUser &user, QImage &&photo) {
if (user.type() != mtpc_user || !user.c_user().is_self()) {
if (user.type() != mtpc_user
|| !user.c_user().is_self()
|| !user.c_user().vid.v) {
// No idea what to do here.
// We could've reset intro and MTP, but this really should not happen.
Ui::show(Box<InformBox>("Internal error: bad user.is_self() after sign in."));
@@ -610,16 +612,13 @@ void Widget::Step::finish(const MTPUser &user, QImage &&photo) {
Local::writeLangPack();
}
Messenger::Instance().authSessionCreate(user.c_user().vid.v);
Messenger::Instance().authSessionCreate(user);
Local::writeMtpData();
App::wnd()->setupMain(&user);
App::wnd()->setupMain();
// "this" is already deleted here by creating the main widget.
if (const auto user = App::self()) {
Auth().api().requestFullPeer(user);
if (!photo.isNull()) {
Auth().api().uploadPeerPhoto(user, std::move(photo));
}
if (AuthSession::Exists() && !photo.isNull()) {
Auth().api().uploadPeerPhoto(Auth().user(), std::move(photo));
}
}