2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-04 16:35:44 +00:00

Remove some more Auth() calls.

This commit is contained in:
John Preston
2019-07-24 16:00:30 +02:00
parent ff44094ded
commit 137fa0378c
59 changed files with 840 additions and 460 deletions

View File

@@ -232,7 +232,7 @@ EditCaptionBox::EditCaptionBox(
_thumbnailImageLoaded = _thumbnailImage
? _thumbnailImage->loaded()
: true;
subscribe(Auth().downloaderTaskFinished(), [=] {
subscribe(_controller->session().downloaderTaskFinished(), [=] {
if (!_thumbnailImageLoaded
&& _thumbnailImage
&& _thumbnailImage->loaded()) {
@@ -876,7 +876,7 @@ void EditCaptionBox::setInnerFocus() {
void EditCaptionBox::save() {
if (_saveRequestId) return;
const auto item = Auth().data().message(_msgId);
const auto item = _controller->session().data().message(_msgId);
if (!item) {
_error = tr::lng_edit_deleted(tr::now);
update();
@@ -894,7 +894,7 @@ void EditCaptionBox::save() {
};
const auto prepareFlags = Ui::ItemTextOptions(
item->history(),
Auth().user()).flags;
_controller->session().user()).flags;
TextUtilities::PrepareForSending(sending, prepareFlags);
TextUtilities::Trim(sending);
@@ -913,7 +913,7 @@ void EditCaptionBox::save() {
};
item->setText(sending);
Auth().api().editMedia(
_controller->session().api().editMedia(
std::move(_preparedList),
(!_asFile && _photo) ? SendMediaType::Photo : SendMediaType::File,
_field->getTextWithAppliedMarkdown(),
@@ -938,21 +938,24 @@ void EditCaptionBox::save() {
void EditCaptionBox::saveDone(const MTPUpdates &updates) {
_saveRequestId = 0;
const auto controller = _controller;
closeBox();
Auth().api().applyUpdates(updates);
controller->session().api().applyUpdates(updates);
}
bool EditCaptionBox::saveFail(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
_saveRequestId = 0;
QString err = error.type();
if (err == qstr("MESSAGE_ID_INVALID") || err == qstr("CHAT_ADMIN_REQUIRED") || err == qstr("MESSAGE_EDIT_TIME_EXPIRED")) {
const auto &type = error.type();
if (type == qstr("MESSAGE_ID_INVALID")
|| type == qstr("CHAT_ADMIN_REQUIRED")
|| type == qstr("MESSAGE_EDIT_TIME_EXPIRED")) {
_error = tr::lng_edit_error(tr::now);
} else if (err == qstr("MESSAGE_NOT_MODIFIED")) {
} else if (type == qstr("MESSAGE_NOT_MODIFIED")) {
closeBox();
return true;
} else if (err == qstr("MESSAGE_EMPTY")) {
} else if (type == qstr("MESSAGE_EMPTY")) {
_field->setFocus();
_field->showError();
} else {