mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Remove some more Auth() calls.
This commit is contained in:
@@ -459,7 +459,8 @@ DeleteMessagesBox::DeleteMessagesBox(
|
||||
QWidget*,
|
||||
not_null<HistoryItem*> item,
|
||||
bool suggestModerateActions)
|
||||
: _ids(1, item->fullId()) {
|
||||
: _session(&item->history()->session())
|
||||
, _ids(1, item->fullId()) {
|
||||
if (suggestModerateActions) {
|
||||
_moderateBan = item->suggestBanReport();
|
||||
_moderateDeleteAll = item->suggestDeleteAllReport();
|
||||
@@ -472,8 +473,10 @@ DeleteMessagesBox::DeleteMessagesBox(
|
||||
|
||||
DeleteMessagesBox::DeleteMessagesBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
MessageIdsList &&selected)
|
||||
: _ids(std::move(selected)) {
|
||||
: _session(session)
|
||||
, _ids(std::move(selected)) {
|
||||
Expects(!_ids.empty());
|
||||
}
|
||||
|
||||
@@ -481,7 +484,8 @@ DeleteMessagesBox::DeleteMessagesBox(
|
||||
QWidget*,
|
||||
not_null<PeerData*> peer,
|
||||
bool justClear)
|
||||
: _wipeHistoryPeer(peer)
|
||||
: _session(&peer->session())
|
||||
, _wipeHistoryPeer(peer)
|
||||
, _wipeHistoryJustClear(justClear) {
|
||||
}
|
||||
|
||||
@@ -579,7 +583,7 @@ void DeleteMessagesBox::prepare() {
|
||||
PeerData *DeleteMessagesBox::checkFromSinglePeer() const {
|
||||
auto result = (PeerData*)nullptr;
|
||||
for (const auto fullId : std::as_const(_ids)) {
|
||||
if (const auto item = Auth().data().message(fullId)) {
|
||||
if (const auto item = _session->data().message(fullId)) {
|
||||
const auto peer = item->history()->peer;
|
||||
if (!result) {
|
||||
result = peer;
|
||||
@@ -762,7 +766,7 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||
|
||||
base::flat_map<not_null<PeerData*>, QVector<MTPint>> idsByPeer;
|
||||
for (const auto itemId : _ids) {
|
||||
if (const auto item = Auth().data().message(itemId)) {
|
||||
if (const auto item = _session->data().message(itemId)) {
|
||||
const auto history = item->history();
|
||||
const auto wasOnServer = IsServerMsgId(item->id);
|
||||
const auto wasLast = (history->lastMessage() == item);
|
||||
@@ -780,18 +784,21 @@ void DeleteMessagesBox::deleteAndClear() {
|
||||
for (const auto &[peer, ids] : idsByPeer) {
|
||||
peer->session().api().deleteMessages(peer, ids, revoke);
|
||||
}
|
||||
const auto session = _session;
|
||||
Ui::hideLayer();
|
||||
Auth().data().sendHistoryChangeNotifications();
|
||||
session->data().sendHistoryChangeNotifications();
|
||||
}
|
||||
|
||||
ConfirmInviteBox::ConfirmInviteBox(
|
||||
QWidget*,
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data,
|
||||
Fn<void()> submit)
|
||||
: _submit(std::move(submit))
|
||||
: _session(session)
|
||||
, _submit(std::move(submit))
|
||||
, _title(this, st::confirmInviteTitle)
|
||||
, _status(this, st::confirmInviteStatus)
|
||||
, _participants(GetParticipants(data))
|
||||
, _participants(GetParticipants(_session, data))
|
||||
, _isChannel(data.is_channel() && !data.is_megagroup()) {
|
||||
const auto title = qs(data.vtitle());
|
||||
const auto count = data.vparticipants_count().v;
|
||||
@@ -807,11 +814,11 @@ ConfirmInviteBox::ConfirmInviteBox(
|
||||
_title->setText(title);
|
||||
_status->setText(status);
|
||||
|
||||
const auto photo = Auth().data().processPhoto(data.vphoto());
|
||||
const auto photo = _session->data().processPhoto(data.vphoto());
|
||||
if (!photo->isNull()) {
|
||||
_photo = photo->thumbnail();
|
||||
if (!_photo->loaded()) {
|
||||
subscribe(Auth().downloaderTaskFinished(), [=] {
|
||||
subscribe(_session->downloaderTaskFinished(), [=] {
|
||||
update();
|
||||
});
|
||||
_photo->load(Data::FileOrigin());
|
||||
@@ -824,6 +831,7 @@ ConfirmInviteBox::ConfirmInviteBox(
|
||||
}
|
||||
|
||||
std::vector<not_null<UserData*>> ConfirmInviteBox::GetParticipants(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPDchatInvite &data) {
|
||||
const auto participants = data.vparticipants();
|
||||
if (!participants) {
|
||||
@@ -833,7 +841,7 @@ std::vector<not_null<UserData*>> ConfirmInviteBox::GetParticipants(
|
||||
auto result = std::vector<not_null<UserData*>>();
|
||||
result.reserve(v.size());
|
||||
for (const auto &participant : v) {
|
||||
if (const auto user = Auth().data().processUser(participant)) {
|
||||
if (const auto user = session->data().processUser(participant)) {
|
||||
result.push_back(user);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user