mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Replace App::self() with Auth().user().
Always have self Auth().user() when AuthSession exists.
This commit is contained in:
@@ -1112,7 +1112,12 @@ void MainWidget::deleteConversation(
|
||||
|
||||
void MainWidget::deleteAndExit(ChatData *chat) {
|
||||
PeerData *peer = chat;
|
||||
MTP::send(MTPmessages_DeleteChatUser(chat->inputChat, App::self()->inputUser), rpcDone(&MainWidget::deleteHistoryAfterLeave, peer), rpcFail(&MainWidget::leaveChatFailed, peer));
|
||||
MTP::send(
|
||||
MTPmessages_DeleteChatUser(
|
||||
chat->inputChat,
|
||||
Auth().user()->inputUser),
|
||||
rpcDone(&MainWidget::deleteHistoryAfterLeave, peer),
|
||||
rpcFail(&MainWidget::leaveChatFailed, peer));
|
||||
}
|
||||
|
||||
void MainWidget::addParticipants(
|
||||
@@ -3647,26 +3652,13 @@ void MainWidget::mtpPing() {
|
||||
MTP::ping();
|
||||
}
|
||||
|
||||
void MainWidget::start(const MTPUser *self) {
|
||||
void MainWidget::start() {
|
||||
Auth().api().requestNotifySettings(MTP_inputNotifyUsers());
|
||||
Auth().api().requestNotifySettings(MTP_inputNotifyChats());
|
||||
|
||||
if (!self) {
|
||||
MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf));
|
||||
return;
|
||||
} else if (!Auth().validateSelf(*self)) {
|
||||
constexpr auto kRequestUserAgainTimeout = TimeMs(10000);
|
||||
App::CallDelayed(kRequestUserAgainTimeout, this, [=] {
|
||||
MTP::send(MTPusers_GetFullUser(MTP_inputUserSelf()), rpcDone(&MainWidget::startWithSelf));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Local::readSavedPeers();
|
||||
cSetOtherOnline(0);
|
||||
if (const auto user = App::feedUsers(MTP_vector<MTPUser>(1, *self))) {
|
||||
user->loadUserpic();
|
||||
}
|
||||
Auth().user()->loadUserpic();
|
||||
|
||||
MTP::send(MTPupdates_GetState(), rpcDone(&MainWidget::gotState));
|
||||
update();
|
||||
@@ -3938,15 +3930,6 @@ bool MainWidget::inviteImportFail(const RPCError &error) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainWidget::startWithSelf(const MTPUserFull &result) {
|
||||
Expects(result.type() == mtpc_userFull);
|
||||
auto &d = result.c_userFull();
|
||||
start(&d.vuser);
|
||||
if (auto user = App::self()) {
|
||||
Auth().api().processFullPeer(user, result);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWidget::incrementSticker(DocumentData *sticker) {
|
||||
if (!sticker || !sticker->sticker()) return;
|
||||
if (sticker->sticker()->set.type() == mtpc_inputStickerSetEmpty) return;
|
||||
@@ -4145,12 +4128,11 @@ void MainWidget::updateOnline(bool gotOtherOffline) {
|
||||
_lastSetOnline = ms;
|
||||
_onlineRequest = MTP::send(MTPaccount_UpdateStatus(MTP_bool(!isOnline)));
|
||||
|
||||
if (App::self()) {
|
||||
App::self()->onlineTill = unixtime() + (isOnline ? (Global::OnlineUpdatePeriod() / 1000) : -1);
|
||||
Notify::peerUpdatedDelayed(
|
||||
App::self(),
|
||||
Notify::PeerUpdate::Flag::UserOnlineChanged);
|
||||
}
|
||||
const auto self = Auth().user();
|
||||
self->onlineTill = unixtime() + (isOnline ? (Global::OnlineUpdatePeriod() / 1000) : -1);
|
||||
Notify::peerUpdatedDelayed(
|
||||
self,
|
||||
Notify::PeerUpdate::Flag::UserOnlineChanged);
|
||||
if (!isOnline) { // Went offline, so we need to save message draft to the cloud.
|
||||
saveDraftToCloud();
|
||||
}
|
||||
|
Reference in New Issue
Block a user