Remove some more Auth() calls.

This commit is contained in:
John Preston 2020-06-08 13:06:50 +04:00
parent bede709f6b
commit 3878a1b212
67 changed files with 380 additions and 299 deletions

View file

@ -1060,7 +1060,7 @@ void ApiWrap::requestWallPaper(
)).done([=](const MTPWallPaper &result) { )).done([=](const MTPWallPaper &result) {
_wallPaperRequestId = 0; _wallPaperRequestId = 0;
_wallPaperSlug = QString(); _wallPaperSlug = QString();
if (const auto paper = Data::WallPaper::Create(result)) { if (const auto paper = Data::WallPaper::Create(&session(), result)) {
if (const auto done = base::take(_wallPaperDone)) { if (const auto done = base::take(_wallPaperDone)) {
done(*paper); done(*paper);
} }

View file

@ -98,7 +98,9 @@ int Style::minButtonWidth(HistoryMessageMarkupButton::Type type) const {
} // namespace } // namespace
BotKeyboard::BotKeyboard(QWidget *parent) : TWidget(parent) BotKeyboard::BotKeyboard(not_null<Main::Session*> session, QWidget *parent)
: TWidget(parent)
, _session(session)
, _st(&st::botKbButton) { , _st(&st::botKbButton) {
setGeometry(0, 0, _st->margin, st::botKbScroll.deltat); setGeometry(0, 0, _st->margin, st::botKbScroll.deltat);
_height = st::botKbScroll.deltat; _height = st::botKbScroll.deltat;
@ -149,7 +151,7 @@ void BotKeyboard::leaveEventHook(QEvent *e) {
} }
bool BotKeyboard::moderateKeyActivate(int key) { bool BotKeyboard::moderateKeyActivate(int key) {
if (const auto item = Auth().data().message(_wasForMsgId)) { if (const auto item = _session->data().message(_wasForMsgId)) {
if (const auto markup = item->Get<HistoryMessageReplyMarkup>()) { if (const auto markup = item->Get<HistoryMessageReplyMarkup>()) {
if (key >= Qt::Key_1 && key <= Qt::Key_9) { if (key >= Qt::Key_1 && key <= Qt::Key_9) {
const auto index = int(key - Qt::Key_1); const auto index = int(key - Qt::Key_1);

View file

@ -9,18 +9,22 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/tooltip.h" #include "ui/widgets/tooltip.h"
class ReplyKeyboard;
namespace style { namespace style {
struct BotKeyboardButton; struct BotKeyboardButton;
} // namespace style } // namespace style
class ReplyKeyboard; namespace Main {
class Session;
} // namespace Main
class BotKeyboard class BotKeyboard
: public TWidget : public TWidget
, public Ui::AbstractTooltipShower , public Ui::AbstractTooltipShower
, public ClickHandlerHost { , public ClickHandlerHost {
public: public:
BotKeyboard(QWidget *parent); BotKeyboard(not_null<Main::Session*> session, QWidget *parent);
bool moderateKeyActivate(int index); bool moderateKeyActivate(int index);
@ -70,6 +74,7 @@ private:
void updateStyle(int newWidth); void updateStyle(int newWidth);
void clearSelection(); void clearSelection();
const not_null<Main::Session*> _session;
FullMsgId _wasForMsgId; FullMsgId _wasForMsgId;
int _height = 0; int _height = 0;
int _maxOuterHeight = 0; int _maxOuterHeight = 0;

View file

@ -527,7 +527,7 @@ void EmojiKeywords::handleSessionChanges() {
void EmojiKeywords::apiChanged(ApiWrap *api) { void EmojiKeywords::apiChanged(ApiWrap *api) {
_api = api; _api = api;
if (_api) { if (_api) {
crl::on_main(&Auth(), crl::guard(&_guard, [=] { crl::on_main(&_api->session(), crl::guard(&_guard, [=] {
base::ObservableViewer( base::ObservableViewer(
Lang::CurrentCloudManager().firstLanguageSuggestion() Lang::CurrentCloudManager().firstLanguageSuggestion()
) | rpl::filter([=] { ) | rpl::filter([=] {

View file

@ -698,7 +698,7 @@ void EmojiListWidget::colorChosen(EmojiPtr emoji) {
cRefEmojiVariants().insert( cRefEmojiVariants().insert(
emoji->nonColoredId(), emoji->nonColoredId(),
emoji->variantIndex(emoji)); emoji->variantIndex(emoji));
Auth().saveSettingsDelayed(); controller()->session().saveSettingsDelayed();
} }
if (_pickerSel >= 0) { if (_pickerSel >= 0) {
auto section = (_pickerSel / MatrixRowShift); auto section = (_pickerSel / MatrixRowShift);

View file

@ -254,7 +254,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
}; };
mrows.reserve(mrows.size() + (_chat->participants.empty() ? _chat->lastAuthors.size() : _chat->participants.size())); mrows.reserve(mrows.size() + (_chat->participants.empty() ? _chat->lastAuthors.size() : _chat->participants.size()));
if (_chat->noParticipantInfo()) { if (_chat->noParticipantInfo()) {
Auth().api().requestFullPeer(_chat); _chat->session().api().requestFullPeer(_chat);
} else if (!_chat->participants.empty()) { } else if (!_chat->participants.empty()) {
for (const auto user : _chat->participants) { for (const auto user : _chat->participants) {
if (user->isInaccessible()) continue; if (user->isInaccessible()) continue;
@ -277,7 +277,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
} else if (_channel && _channel->isMegagroup()) { } else if (_channel && _channel->isMegagroup()) {
QMultiMap<int32, UserData*> ordered; QMultiMap<int32, UserData*> ordered;
if (_channel->lastParticipantsRequestNeeded()) { if (_channel->lastParticipantsRequestNeeded()) {
Auth().api().requestLastParticipants(_channel); _channel->session().api().requestLastParticipants(_channel);
} else { } else {
mrows.reserve(mrows.size() + _channel->mgInfo->lastParticipants.size()); mrows.reserve(mrows.size() + _channel->mgInfo->lastParticipants.size());
for (const auto user : _channel->mgInfo->lastParticipants) { for (const auto user : _channel->mgInfo->lastParticipants) {
@ -600,7 +600,9 @@ FieldAutocompleteInner::FieldAutocompleteInner(
, _brows(brows) , _brows(brows)
, _srows(srows) , _srows(srows)
, _previewTimer([=] { showPreview(); }) { , _previewTimer([=] { showPreview(); }) {
subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); subscribe(
controller->session().downloaderTaskFinished(),
[=] { update(); });
} }
void FieldAutocompleteInner::paintEvent(QPaintEvent *e) { void FieldAutocompleteInner::paintEvent(QPaintEvent *e) {

View file

@ -48,17 +48,13 @@ constexpr auto kParseLinksTimeout = crl::time(1000);
// For mention tags save and validate userId, ignore tags for different userId. // For mention tags save and validate userId, ignore tags for different userId.
class FieldTagMimeProcessor : public Ui::InputField::TagMimeProcessor { class FieldTagMimeProcessor : public Ui::InputField::TagMimeProcessor {
public: public:
QString tagFromMimeTag(const QString &mimeTag) override { explicit FieldTagMimeProcessor(
if (TextUtilities::IsMentionLink(mimeTag)) { not_null<Window::SessionController*> controller);
auto match = QRegularExpression(":(\\d+)$").match(mimeTag);
if (!match.hasMatch() QString tagFromMimeTag(const QString &mimeTag) override;
|| match.capturedRef(1).toInt() != Auth().userId()) {
return QString(); private:
} const not_null<Window::SessionController*> _controller;
return mimeTag.mid(0, mimeTag.size() - match.capturedLength());
}
return mimeTag;
}
}; };
@ -85,6 +81,24 @@ private:
}; };
FieldTagMimeProcessor::FieldTagMimeProcessor(
not_null<Window::SessionController*> controller)
: _controller(controller) {
}
QString FieldTagMimeProcessor::tagFromMimeTag(const QString &mimeTag) {
if (TextUtilities::IsMentionLink(mimeTag)) {
const auto userId = _controller->session().userId();
auto match = QRegularExpression(":(\\d+)$").match(mimeTag);
if (!match.hasMatch()
|| match.capturedRef(1).toInt() != userId) {
return QString();
}
return mimeTag.mid(0, mimeTag.size() - match.capturedLength());
}
return mimeTag;
}
//bool ValidateUrl(const QString &value) { //bool ValidateUrl(const QString &value) {
// const auto match = qthelp::RegExpDomain().match(value); // const auto match = qthelp::RegExpDomain().match(value);
// if (!match.hasMatch() || match.capturedStart() != 0) { // if (!match.hasMatch() || match.capturedStart() != 0) {
@ -264,7 +278,8 @@ void InitMessageField(
field->setMinHeight(st::historySendSize.height() - 2 * st::historySendPadding); field->setMinHeight(st::historySendSize.height() - 2 * st::historySendPadding);
field->setMaxHeight(st::historyComposeFieldMaxHeight); field->setMaxHeight(st::historyComposeFieldMaxHeight);
field->setTagMimeProcessor(std::make_unique<FieldTagMimeProcessor>()); field->setTagMimeProcessor(
std::make_unique<FieldTagMimeProcessor>(controller));
field->document()->setDocumentMargin(4.); field->document()->setDocumentMargin(4.);
field->setAdditionalMargin(style::ConvertScale(4) - 4); field->setAdditionalMargin(style::ConvertScale(4) - 4);
@ -307,7 +322,9 @@ bool HasSendText(not_null<const Ui::InputField*> field) {
return false; return false;
} }
InlineBotQuery ParseInlineBotQuery(not_null<const Ui::InputField*> field) { InlineBotQuery ParseInlineBotQuery(
not_null<Main::Session*> session,
not_null<const Ui::InputField*> field) {
auto result = InlineBotQuery(); auto result = InlineBotQuery();
const auto &full = field->getTextWithTags(); const auto &full = field->getTextWithTags();
@ -345,7 +362,7 @@ InlineBotQuery ParseInlineBotQuery(not_null<const Ui::InputField*> field) {
auto username = text.midRef(inlineUsernameStart, inlineUsernameLength); auto username = text.midRef(inlineUsernameStart, inlineUsernameLength);
if (username != result.username) { if (username != result.username) {
result.username = username.toString(); result.username = username.toString();
if (const auto peer = Auth().data().peerByUsername(result.username)) { if (const auto peer = session->data().peerByUsername(result.username)) {
if (const auto user = peer->asUser()) { if (const auto user = peer->asUser()) {
result.bot = peer->asUser(); result.bot = peer->asUser();
} else { } else {

View file

@ -52,7 +52,9 @@ struct InlineBotQuery {
UserData *bot = nullptr; UserData *bot = nullptr;
bool lookingUpBot = false; bool lookingUpBot = false;
}; };
InlineBotQuery ParseInlineBotQuery(not_null<const Ui::InputField*> field); InlineBotQuery ParseInlineBotQuery(
not_null<Main::Session*> session,
not_null<const Ui::InputField*> field);
struct AutocompleteQuery { struct AutocompleteQuery {
QString query; QString query;

View file

@ -73,9 +73,9 @@ private:
class MentionNameClickHandler : public ClickHandler { class MentionNameClickHandler : public ClickHandler {
public: public:
MentionNameClickHandler(QString text, UserId userId, uint64 accessHash) MentionNameClickHandler(QString text, UserId userId, uint64 accessHash)
: _text(text) : _text(text)
, _userId(userId) , _userId(userId)
, _accessHash(accessHash) { , _accessHash(accessHash) {
} }
void onClick(ClickContext context) const override; void onClick(ClickContext context) const override;

View file

@ -1579,7 +1579,7 @@ void UpdateApplication() {
if (const auto controller = window->sessionController()) { if (const auto controller = window->sessionController()) {
controller->showSection( controller->showSection(
Info::Memento( Info::Memento(
Info::Settings::Tag{ Auth().user() }, Info::Settings::Tag{ controller->session().user() },
Info::Section::SettingsType::Advanced), Info::Section::SettingsType::Advanced),
Window::SectionShow()); Window::SectionShow());
} else { } else {

View file

@ -65,11 +65,14 @@ QString JoinStringList(const QStringList &list, const QString &separator) {
return result; return result;
} }
void LaunchWithWarning(const QString &name, HistoryItem *item) { void LaunchWithWarning(
not_null<Main::Session*> session,
const QString &name,
HistoryItem *item) {
const auto warn = [&] { const auto warn = [&] {
if (!Data::IsExecutableName(name)) { if (!Data::IsExecutableName(name)) {
return false; return false;
} else if (!Auth().settings().exeLaunchWarning()) { } else if (!session->settings().exeLaunchWarning()) {
return false; return false;
} else if (item && item->history()->peer->isVerified()) { } else if (item && item->history()->peer->isVerified()) {
return false; return false;
@ -81,13 +84,13 @@ void LaunchWithWarning(const QString &name, HistoryItem *item) {
return; return;
} }
const auto extension = '.' + Data::FileExtension(name); const auto extension = '.' + Data::FileExtension(name);
const auto callback = [=](bool checked) { const auto callback = crl::guard(session, [=](bool checked) {
if (checked) { if (checked) {
Auth().settings().setExeLaunchWarning(false); session->settings().setExeLaunchWarning(false);
Auth().saveSettingsDelayed(); session->saveSettingsDelayed();
} }
File::Launch(name); File::Launch(name);
}; });
Ui::show(Box<ConfirmDontWarnBox>( Ui::show(Box<ConfirmDontWarnBox>(
tr::lng_launch_exe_warning( tr::lng_launch_exe_warning(
lt_extension, lt_extension,
@ -313,7 +316,7 @@ void DocumentOpenClickHandler::Open(
return; return;
} }
} }
LaunchWithWarning(location.name(), context); LaunchWithWarning(&data->session(), location.name(), context);
}; };
const auto media = data->createMediaView(); const auto media = data->createMediaView();
const auto &location = data->location(true); const auto &location = data->location(true);

View file

@ -186,10 +186,12 @@ SearchResult ParseSearchResult(
return result; return result;
} }
SearchController::CacheEntry::CacheEntry(const Query &query) SearchController::CacheEntry::CacheEntry(
: peerData(Auth().data().peer(query.peerId)) not_null<Main::Session*> session,
const Query &query)
: peerData(session->data().peer(query.peerId))
, migratedData(query.migratedPeerId , migratedData(query.migratedPeerId
? base::make_optional(Data(Auth().data().peer(query.migratedPeerId))) ? base::make_optional(Data(session->data().peer(query.migratedPeerId)))
: std::nullopt) { : std::nullopt) {
} }
@ -211,7 +213,7 @@ void SearchController::setQuery(const Query &query) {
if (_current == _cache.end()) { if (_current == _cache.end()) {
_current = _cache.emplace( _current = _cache.emplace(
query, query,
std::make_unique<CacheEntry>(query)).first; std::make_unique<CacheEntry>(_session, query)).first;
} }
} }
@ -286,14 +288,14 @@ rpl::producer<SparseIdsSlice> SearchController::simpleIdsSlice(
return builder->applyUpdate(update); return builder->applyUpdate(update);
}) | rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
Auth().data().itemRemoved( _session->data().itemRemoved(
) | rpl::filter([=](not_null<const HistoryItem*> item) { ) | rpl::filter([=](not_null<const HistoryItem*> item) {
return (item->history()->peer->id == peerId); return (item->history()->peer->id == peerId);
}) | rpl::filter([=](not_null<const HistoryItem*> item) { }) | rpl::filter([=](not_null<const HistoryItem*> item) {
return builder->removeOne(item->id); return builder->removeOne(item->id);
}) | rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
Auth().data().historyCleared( _session->data().historyCleared(
) | rpl::filter([=](not_null<const History*> history) { ) | rpl::filter([=](not_null<const History*> history) {
return (history->peer->id == peerId); return (history->peer->id == peerId);
}) | rpl::filter([=] { }) | rpl::filter([=] {
@ -337,7 +339,7 @@ void SearchController::restoreState(SavedState &&state) {
if (it == _cache.end()) { if (it == _cache.end()) {
it = _cache.emplace( it = _cache.emplace(
state.query, state.query,
std::make_unique<CacheEntry>(state.query)).first; std::make_unique<CacheEntry>(_session, state.query)).first;
} }
auto replace = Data(it->second->peerData.peer); auto replace = Data(it->second->peerData.peer);
replace.list = std::move(state.peerList); replace.list = std::move(state.peerList);

View file

@ -102,7 +102,7 @@ private:
using SliceUpdate = Storage::SparseIdsSliceUpdate; using SliceUpdate = Storage::SparseIdsSliceUpdate;
struct CacheEntry { struct CacheEntry {
CacheEntry(const Query &query); CacheEntry(not_null<Main::Session*> session, const Query &query);
Data peerData; Data peerData;
std::optional<Data> migratedData; std::optional<Data> migratedData;

View file

@ -2616,7 +2616,9 @@ void Session::documentApplyFields(
not_null<WebPageData*> Session::webpage(WebPageId id) { not_null<WebPageData*> Session::webpage(WebPageId id) {
auto i = _webpages.find(id); auto i = _webpages.find(id);
if (i == _webpages.cend()) { if (i == _webpages.cend()) {
i = _webpages.emplace(id, std::make_unique<WebPageData>(id)).first; i = _webpages.emplace(
id,
std::make_unique<WebPageData>(this, id)).first;
} }
return i->second.get(); return i->second.get();
} }
@ -2773,7 +2775,7 @@ void Session::webpageApplyFields(
description, description,
photo ? processPhoto(*photo).get() : nullptr, photo ? processPhoto(*photo).get() : nullptr,
document ? processDocument(*document).get() : lookupThemeDocument(), document ? processDocument(*document).get() : lookupThemeDocument(),
WebPageCollage(data), WebPageCollage(this, data),
data.vduration().value_or_empty(), data.vduration().value_or_empty(),
qs(data.vauthor().value_or_empty()), qs(data.vauthor().value_or_empty()),
pendingTill); pendingTill);
@ -3800,7 +3802,7 @@ void Session::setWallpapers(const QVector<MTPWallPaper> &data, int32 hash) {
_wallpapers.back().setLocalImageAsThumbnail(std::make_shared<Image>( _wallpapers.back().setLocalImageAsThumbnail(std::make_shared<Image>(
u":/gui/art/bg_initial.jpg"_q)); u":/gui/art/bg_initial.jpg"_q));
for (const auto &paper : data) { for (const auto &paper : data) {
if (const auto parsed = Data::WallPaper::Create(paper)) { if (const auto parsed = Data::WallPaper::Create(&session(), paper)) {
_wallpapers.push_back(*parsed); _wallpapers.push_back(*parsed);
} }
} }

View file

@ -48,7 +48,7 @@ void SharedMediaShowOverview(
not_null<History*> history) { not_null<History*> history) {
if (SharedMediaOverviewType(type)) { if (SharedMediaOverviewType(type)) {
App::wnd()->sessionController()->showSection(Info::Memento( App::wnd()->sessionController()->showSection(Info::Memento(
history->peer->id, history->peer,
Info::Section(type))); Info::Section(type)));
} }
} }
@ -63,6 +63,7 @@ bool SharedMediaAllowSearch(Storage::SharedMediaType type) {
} }
rpl::producer<SparseIdsSlice> SharedMediaViewer( rpl::producer<SparseIdsSlice> SharedMediaViewer(
not_null<Main::Session*> session,
Storage::SharedMediaKey key, Storage::SharedMediaKey key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
@ -76,10 +77,10 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
limitBefore, limitBefore,
limitAfter); limitAfter);
auto requestMediaAround = [ auto requestMediaAround = [
peer = Auth().data().peer(key.peerId), peer = session->data().peer(key.peerId),
type = key.type type = key.type
](const SparseIdsSliceBuilder::AroundData &data) { ](const SparseIdsSliceBuilder::AroundData &data) {
Auth().api().requestSharedMedia( peer->session().api().requestSharedMedia(
peer, peer,
type, type,
data.aroundId, data.aroundId,
@ -93,7 +94,7 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
}; };
using SliceUpdate = Storage::SharedMediaSliceUpdate; using SliceUpdate = Storage::SharedMediaSliceUpdate;
Auth().storage().sharedMediaSliceUpdated( session->storage().sharedMediaSliceUpdated(
) | rpl::filter([=](const SliceUpdate &update) { ) | rpl::filter([=](const SliceUpdate &update) {
return (update.peerId == key.peerId) return (update.peerId == key.peerId)
&& (update.type == key.type); && (update.type == key.type);
@ -102,7 +103,7 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
}) | rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
using OneRemoved = Storage::SharedMediaRemoveOne; using OneRemoved = Storage::SharedMediaRemoveOne;
Auth().storage().sharedMediaOneRemoved( session->storage().sharedMediaOneRemoved(
) | rpl::filter([=](const OneRemoved &update) { ) | rpl::filter([=](const OneRemoved &update) {
return (update.peerId == key.peerId) return (update.peerId == key.peerId)
&& update.types.test(key.type); && update.types.test(key.type);
@ -111,7 +112,7 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
}) | rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
using AllRemoved = Storage::SharedMediaRemoveAll; using AllRemoved = Storage::SharedMediaRemoveAll;
Auth().storage().sharedMediaAllRemoved( session->storage().sharedMediaAllRemoved(
) | rpl::filter([=](const AllRemoved &update) { ) | rpl::filter([=](const AllRemoved &update) {
return (update.peerId == key.peerId); return (update.peerId == key.peerId);
}) | rpl::filter([=] { }) | rpl::filter([=] {
@ -119,7 +120,7 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
}) | rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
using InvalidateBottom = Storage::SharedMediaInvalidateBottom; using InvalidateBottom = Storage::SharedMediaInvalidateBottom;
Auth().storage().sharedMediaBottomInvalidated( session->storage().sharedMediaBottomInvalidated(
) | rpl::filter([=](const InvalidateBottom &update) { ) | rpl::filter([=](const InvalidateBottom &update) {
return (update.peerId == key.peerId); return (update.peerId == key.peerId);
}) | rpl::filter([=] { }) | rpl::filter([=] {
@ -127,7 +128,7 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
}) | rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
using Result = Storage::SharedMediaResult; using Result = Storage::SharedMediaResult;
Auth().storage().query(Storage::SharedMediaQuery( session->storage().query(Storage::SharedMediaQuery(
key, key,
limitBefore, limitBefore,
limitAfter limitAfter
@ -143,6 +144,7 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
} }
rpl::producer<SparseIdsMergedSlice> SharedMediaMergedViewer( rpl::producer<SparseIdsMergedSlice> SharedMediaMergedViewer(
not_null<Main::Session*> session,
SharedMediaMergedKey key, SharedMediaMergedKey key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
@ -152,6 +154,7 @@ rpl::producer<SparseIdsMergedSlice> SharedMediaMergedViewer(
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
return SharedMediaViewer( return SharedMediaViewer(
session,
Storage::SharedMediaKey( Storage::SharedMediaKey(
peerId, peerId,
key.type, key.type,
@ -349,12 +352,14 @@ std::optional<FullMsgId> SharedMediaWithLastSlice::LastFullMsgId(
} }
rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer( rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
not_null<Main::Session*> session,
SharedMediaWithLastSlice::Key key, SharedMediaWithLastSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
return [=](auto consumer) { return [=](auto consumer) {
if (base::get_if<not_null<PhotoData*>>(&key.universalId)) { if (base::get_if<not_null<PhotoData*>>(&key.universalId)) {
return SharedMediaMergedViewer( return SharedMediaMergedViewer(
session,
SharedMediaMergedKey( SharedMediaMergedKey(
SharedMediaWithLastSlice::ViewerKey(key), SharedMediaWithLastSlice::ViewerKey(key),
key.type), key.type),
@ -369,12 +374,14 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
} }
return rpl::combine( return rpl::combine(
SharedMediaMergedViewer( SharedMediaMergedViewer(
session,
SharedMediaMergedKey( SharedMediaMergedKey(
SharedMediaWithLastSlice::ViewerKey(key), SharedMediaWithLastSlice::ViewerKey(key),
key.type), key.type),
limitBefore, limitBefore,
limitAfter), limitAfter),
SharedMediaMergedViewer( SharedMediaMergedViewer(
session,
SharedMediaMergedKey( SharedMediaMergedKey(
SharedMediaWithLastSlice::EndingKey(key), SharedMediaWithLastSlice::EndingKey(key),
key.type), key.type),
@ -392,10 +399,12 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
} }
rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastReversedViewer( rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastReversedViewer(
not_null<Main::Session*> session,
SharedMediaWithLastSlice::Key key, SharedMediaWithLastSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
return SharedMediaWithLastViewer( return SharedMediaWithLastViewer(
session,
key, key,
limitBefore, limitBefore,
limitAfter limitAfter

View file

@ -13,6 +13,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class History; class History;
namespace Main {
class Session;
} // namespace Main
std::optional<Storage::SharedMediaType> SharedMediaOverviewType( std::optional<Storage::SharedMediaType> SharedMediaOverviewType(
Storage::SharedMediaType type); Storage::SharedMediaType type);
void SharedMediaShowOverview( void SharedMediaShowOverview(
@ -21,6 +25,7 @@ void SharedMediaShowOverview(
bool SharedMediaAllowSearch(Storage::SharedMediaType type); bool SharedMediaAllowSearch(Storage::SharedMediaType type);
rpl::producer<SparseIdsSlice> SharedMediaViewer( rpl::producer<SparseIdsSlice> SharedMediaViewer(
not_null<Main::Session*> session,
Storage::SharedMediaKey key, Storage::SharedMediaKey key,
int limitBefore, int limitBefore,
int limitAfter); int limitAfter);
@ -46,6 +51,7 @@ struct SharedMediaMergedKey {
}; };
rpl::producer<SparseIdsMergedSlice> SharedMediaMergedViewer( rpl::producer<SparseIdsMergedSlice> SharedMediaMergedViewer(
not_null<Main::Session*> session,
SharedMediaMergedKey key, SharedMediaMergedKey key,
int limitBefore, int limitBefore,
int limitAfter); int limitAfter);
@ -179,11 +185,13 @@ private:
}; };
rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer( rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastViewer(
not_null<Main::Session*> session,
SharedMediaWithLastSlice::Key key, SharedMediaWithLastSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter); int limitAfter);
rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastReversedViewer( rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastReversedViewer(
not_null<Main::Session*> session,
SharedMediaWithLastSlice::Key key, SharedMediaWithLastSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter); int limitAfter);

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h" #include "main/main_session.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_user.h"
#include "storage/storage_facade.h" #include "storage/storage_facade.h"
#include "storage/storage_user_photos.h" #include "storage/storage_user_photos.h"
@ -194,10 +195,11 @@ UserPhotosSlice UserPhotosSliceBuilder::snapshot() const {
} }
rpl::producer<UserPhotosSlice> UserPhotosViewer( rpl::producer<UserPhotosSlice> UserPhotosViewer(
not_null<Main::Session*> session,
UserPhotosSlice::Key key, UserPhotosSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
return [key, limitBefore, limitAfter](auto consumer) { return [=](auto consumer) {
auto lifetime = rpl::lifetime(); auto lifetime = rpl::lifetime();
auto builder = lifetime.make_state<UserPhotosSliceBuilder>( auto builder = lifetime.make_state<UserPhotosSliceBuilder>(
key, key,
@ -208,17 +210,17 @@ rpl::producer<UserPhotosSlice> UserPhotosViewer(
consumer.put_next(builder->snapshot()); consumer.put_next(builder->snapshot());
} }
}; };
auto requestPhotosAround = [user = Auth().data().user(key.userId)]( auto requestPhotosAround = [user = session->data().user(key.userId)](
PhotoId photoId) { PhotoId photoId) {
Auth().api().requestUserPhotos(user, photoId); user->session().api().requestUserPhotos(user, photoId);
}; };
builder->insufficientPhotosAround() builder->insufficientPhotosAround()
| rpl::start_with_next(requestPhotosAround, lifetime); | rpl::start_with_next(requestPhotosAround, lifetime);
Auth().storage().userPhotosSliceUpdated() session->storage().userPhotosSliceUpdated()
| rpl::start_with_next(applyUpdate, lifetime); | rpl::start_with_next(applyUpdate, lifetime);
Auth().storage().query(Storage::UserPhotosQuery( session->storage().query(Storage::UserPhotosQuery(
key, key,
limitBefore, limitBefore,
limitAfter limitAfter
@ -233,10 +235,12 @@ rpl::producer<UserPhotosSlice> UserPhotosViewer(
rpl::producer<UserPhotosSlice> UserPhotosReversedViewer( rpl::producer<UserPhotosSlice> UserPhotosReversedViewer(
not_null<Main::Session*> session,
UserPhotosSlice::Key key, UserPhotosSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
return UserPhotosViewer( return UserPhotosViewer(
session,
key, key,
limitBefore, limitBefore,
limitAfter limitAfter

View file

@ -10,6 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_user_photos.h" #include "storage/storage_user_photos.h"
#include "base/weak_ptr.h" #include "base/weak_ptr.h"
namespace Main {
class Session;
} // namespace Main
class UserPhotosSlice { class UserPhotosSlice {
public: public:
using Key = Storage::UserPhotosKey; using Key = Storage::UserPhotosKey;
@ -46,11 +50,13 @@ private:
}; };
rpl::producer<UserPhotosSlice> UserPhotosViewer( rpl::producer<UserPhotosSlice> UserPhotosViewer(
not_null<Main::Session*> session,
UserPhotosSlice::Key key, UserPhotosSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter); int limitAfter);
rpl::producer<UserPhotosSlice> UserPhotosReversedViewer( rpl::producer<UserPhotosSlice> UserPhotosReversedViewer(
not_null<Main::Session*> session,
UserPhotosSlice::Key key, UserPhotosSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter); int limitAfter);

View file

@ -302,18 +302,22 @@ WallPaper WallPaper::withoutImageData() const {
return result; return result;
} }
std::optional<WallPaper> WallPaper::Create(const MTPWallPaper &data) { std::optional<WallPaper> WallPaper::Create(
return data.match([](const MTPDwallPaper &data) { not_null<Main::Session*> session,
return Create(data); const MTPWallPaper &data) {
return data.match([&](const MTPDwallPaper &data) {
return Create(session, data);
}, [](const MTPDwallPaperNoFile &data) { }, [](const MTPDwallPaperNoFile &data) {
return std::optional<WallPaper>(); // #TODO themes return std::optional<WallPaper>(); // #TODO themes
}); });
} }
std::optional<WallPaper> WallPaper::Create(const MTPDwallPaper &data) { std::optional<WallPaper> WallPaper::Create(
not_null<Main::Session*> session,
const MTPDwallPaper &data) {
using Flag = MTPDwallPaper::Flag; using Flag = MTPDwallPaper::Flag;
const auto document = Auth().data().processDocument( const auto document = session->data().processDocument(
data.vdocument()); data.vdocument());
if (!document->checkWallPaperProperties()) { if (!document->checkWallPaperProperties()) {
return std::nullopt; return std::nullopt;

View file

@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class Image; class Image;
namespace Main {
class Session;
} // namespace Main
namespace Data { namespace Data {
struct FileOrigin; struct FileOrigin;
@ -49,8 +53,10 @@ public:
[[nodiscard]] WallPaper withoutImageData() const; [[nodiscard]] WallPaper withoutImageData() const;
[[nodiscard]] static std::optional<WallPaper> Create( [[nodiscard]] static std::optional<WallPaper> Create(
not_null<Main::Session*> session,
const MTPWallPaper &data); const MTPWallPaper &data);
[[nodiscard]] static std::optional<WallPaper> Create( [[nodiscard]] static std::optional<WallPaper> Create(
not_null<Main::Session*> session,
const MTPDwallPaper &data); const MTPDwallPaper &data);
[[nodiscard]] QByteArray serialize() const; [[nodiscard]] QByteArray serialize() const;

View file

@ -35,6 +35,7 @@ QString SiteNameFromUrl(const QString &url) {
} }
WebPageCollage ExtractCollage( WebPageCollage ExtractCollage(
not_null<Data::Session*> owner,
const QVector<MTPPageBlock> &items, const QVector<MTPPageBlock> &items,
const QVector<MTPPhoto> &photos, const QVector<MTPPhoto> &photos,
const QVector<MTPDocument> &documents) { const QVector<MTPDocument> &documents) {
@ -51,25 +52,24 @@ WebPageCollage ExtractCollage(
return {}; return {};
} }
auto &storage = Auth().data();
for (const auto &photo : photos) { for (const auto &photo : photos) {
storage.processPhoto(photo); owner->processPhoto(photo);
} }
for (const auto &document : documents) { for (const auto &document : documents) {
storage.processDocument(document); owner->processDocument(document);
} }
auto result = WebPageCollage(); auto result = WebPageCollage();
result.items.reserve(count); result.items.reserve(count);
for (const auto &item : items) { for (const auto &item : items) {
const auto good = item.match([&](const MTPDpageBlockPhoto &data) { const auto good = item.match([&](const MTPDpageBlockPhoto &data) {
const auto photo = storage.photo(data.vphoto_id().v); const auto photo = owner->photo(data.vphoto_id().v);
if (photo->isNull()) { if (photo->isNull()) {
return false; return false;
} }
result.items.emplace_back(photo); result.items.emplace_back(photo);
return true; return true;
}, [&](const MTPDpageBlockVideo &data) { }, [&](const MTPDpageBlockVideo &data) {
const auto document = storage.document(data.vvideo_id().v); const auto document = owner->document(data.vvideo_id().v);
if (!document->isVideoFile()) { if (!document->isVideoFile()) {
return false; return false;
} }
@ -85,17 +85,19 @@ WebPageCollage ExtractCollage(
return result; return result;
} }
WebPageCollage ExtractCollage(const MTPDwebPage &data) { WebPageCollage ExtractCollage(
not_null<Data::Session*> owner,
const MTPDwebPage &data) {
const auto page = data.vcached_page(); const auto page = data.vcached_page();
if (!page) { if (!page) {
return {}; return {};
} }
const auto processMedia = [&] { const auto processMedia = [&] {
if (const auto photo = data.vphoto()) { if (const auto photo = data.vphoto()) {
Auth().data().processPhoto(*photo); owner->processPhoto(*photo);
} }
if (const auto document = data.vdocument()) { if (const auto document = data.vdocument()) {
Auth().data().processDocument(*document); owner->processDocument(*document);
} }
}; };
return page->match([&](const auto &page) { return page->match([&](const auto &page) {
@ -111,12 +113,14 @@ WebPageCollage ExtractCollage(const MTPDwebPage &data) {
case mtpc_pageBlockSlideshow: case mtpc_pageBlockSlideshow:
processMedia(); processMedia();
return ExtractCollage( return ExtractCollage(
owner,
block.c_pageBlockSlideshow().vitems().v, block.c_pageBlockSlideshow().vitems().v,
page.vphotos().v, page.vphotos().v,
page.vdocuments().v); page.vdocuments().v);
case mtpc_pageBlockCollage: case mtpc_pageBlockCollage:
processMedia(); processMedia();
return ExtractCollage( return ExtractCollage(
owner,
block.c_pageBlockCollage().vitems().v, block.c_pageBlockCollage().vitems().v,
page.vphotos().v, page.vphotos().v,
page.vdocuments().v); page.vdocuments().v);
@ -148,8 +152,23 @@ WebPageType ParseWebPageType(const MTPDwebPage &page) {
} }
} }
WebPageCollage::WebPageCollage(const MTPDwebPage &data) WebPageCollage::WebPageCollage(
: WebPageCollage(ExtractCollage(data)) { not_null<Data::Session*> owner,
const MTPDwebPage &data)
: WebPageCollage(ExtractCollage(owner, data)) {
}
WebPageData::WebPageData(not_null<Data::Session*> owner, const WebPageId &id)
: id(id)
, _owner(owner) {
}
Data::Session &WebPageData::owner() const {
return *_owner;
}
Main::Session &WebPageData::session() const {
return _owner->session();
} }
bool WebPageData::applyChanges( bool WebPageData::applyChanges(
@ -211,7 +230,7 @@ bool WebPageData::applyChanges(
return false; return false;
} }
if (pendingTill > 0 && newPendingTill <= 0) { if (pendingTill > 0 && newPendingTill <= 0) {
Auth().api().clearWebPageRequest(this); _owner->session().api().clearWebPageRequest(this);
} }
type = newType; type = newType;
url = resultUrl; url = resultUrl;

View file

@ -12,9 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class ChannelData; class ChannelData;
namespace Main { namespace Data {
class Session; class Session;
} // namespace Main } // namespace Data
enum class WebPageType { enum class WebPageType {
Photo, Photo,
@ -32,15 +32,19 @@ struct WebPageCollage {
using Item = base::variant<PhotoData*, DocumentData*>; using Item = base::variant<PhotoData*, DocumentData*>;
WebPageCollage() = default; WebPageCollage() = default;
explicit WebPageCollage(const MTPDwebPage &data); explicit WebPageCollage(
not_null<Data::Session*> owner,
const MTPDwebPage &data);
std::vector<Item> items; std::vector<Item> items;
}; };
struct WebPageData { struct WebPageData {
WebPageData(const WebPageId &id) : id(id) { WebPageData(not_null<Data::Session*> owner, const WebPageId &id);
}
[[nodiscard]] Data::Session &owner() const;
[[nodiscard]] Main::Session &session() const;
bool applyChanges( bool applyChanges(
WebPageType newType, WebPageType newType,
@ -79,4 +83,6 @@ struct WebPageData {
private: private:
void replaceDocumentGoodThumbnail(); void replaceDocumentGoodThumbnail();
const not_null<Data::Session*> _owner;
}; };

View file

@ -230,7 +230,7 @@ void paintRow(
crl::time ms, crl::time ms,
PaintItemCallback &&paintItemCallback, PaintItemCallback &&paintItemCallback,
PaintCounterCallback &&paintCounterCallback) { PaintCounterCallback &&paintCounterCallback) {
const auto supportMode = Auth().supportMode(); const auto supportMode = entry->session().supportMode();
if (supportMode) { if (supportMode) {
draft = nullptr; draft = nullptr;
} }
@ -339,7 +339,7 @@ void paintRow(
history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1); history->cloudDraftTextCache.drawElided(p, nameleft, texttop, availableWidth, 1);
} else if (draft } else if (draft
|| (supportMode || (supportMode
&& Auth().supportHelper().isOccupiedBySomeone(history))) { && entry->session().supportHelper().isOccupiedBySomeone(history))) {
if (!promoted) { if (!promoted) {
PaintRowDate(p, date, rectForName, active, selected); PaintRowDate(p, date, rectForName, active, selected);
} }

View file

@ -553,19 +553,6 @@ bool InnerWidget::elementUnderCursor(
return (App::hoveredItem() == view); return (App::hoveredItem() == view);
} }
void InnerWidget::elementAnimationAutoplayAsync(
not_null<const HistoryView::Element*> view) {
crl::on_main(this, [this, msgId = view->data()->fullId()] {
if (const auto item = session().data().message(msgId)) {
if (const auto view = viewForItem(item)) {
if (const auto media = view->media()) {
media->autoplayAnimation();
}
}
}
});
}
crl::time InnerWidget::elementHighlightTime( crl::time InnerWidget::elementHighlightTime(
not_null<const HistoryView::Element*> element) { not_null<const HistoryView::Element*> element) {
return crl::time(0); return crl::time(0);

View file

@ -96,8 +96,6 @@ public:
HistoryView::Element *replacing = nullptr) override; HistoryView::Element *replacing = nullptr) override;
bool elementUnderCursor( bool elementUnderCursor(
not_null<const HistoryView::Element*> view) override; not_null<const HistoryView::Element*> view) override;
void elementAnimationAutoplayAsync(
not_null<const HistoryView::Element*> view) override;
crl::time elementHighlightTime( crl::time elementHighlightTime(
not_null<const HistoryView::Element*> element) override; not_null<const HistoryView::Element*> element) override;
bool elementInSelectionMode() override; bool elementInSelectionMode() override;

View file

@ -3333,18 +3333,6 @@ not_null<HistoryView::ElementDelegate*> HistoryInner::ElementDelegate() {
not_null<const HistoryView::Element*> view) override { not_null<const HistoryView::Element*> view) override {
return (App::hoveredItem() == view); return (App::hoveredItem() == view);
} }
void elementAnimationAutoplayAsync(
not_null<const HistoryView::Element*> view) override {
crl::on_main(&Auth(), [msgId = view->data()->fullId()] {
if (const auto item = Auth().data().message(msgId)) {
if (const auto view = item->mainView()) {
if (const auto media = view->media()) {
media->autoplayAnimation();
}
}
}
});
}
crl::time elementHighlightTime( crl::time elementHighlightTime(
not_null<const HistoryView::Element*> view) override { not_null<const HistoryView::Element*> view) override {
const auto fullAnimMs = App::main()->highlightStartTime( const auto fullAnimMs = App::main()->highlightStartTime(

View file

@ -354,9 +354,11 @@ void FastShareMessage(not_null<HistoryItem*> item) {
} }
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback( Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
const FullMsgId &msgId) { not_null<HistoryItem*> item) {
return [dependent = msgId](ChannelData *channel, MsgId msgId) { const auto session = &item->history()->session();
if (const auto item = Auth().data().message(dependent)) { const auto dependent = item->fullId();
return [=](ChannelData *channel, MsgId msgId) {
if (const auto item = session->data().message(dependent)) {
item->updateDependencyItem(); item->updateDependencyItem();
} }
}; };
@ -830,7 +832,7 @@ void HistoryMessage::createComponents(const CreateConfig &config) {
history()->session().api().requestMessageData( history()->session().api().requestMessageData(
history()->peer->asChannel(), history()->peer->asChannel(),
reply->replyToMsgId, reply->replyToMsgId,
HistoryDependentItemCallback(fullId())); HistoryDependentItemCallback(this));
} }
} }
if (const auto via = Get<HistoryMessageVia>()) { if (const auto via = Get<HistoryMessageVia>()) {

View file

@ -16,7 +16,7 @@ class Message;
struct HistoryMessageEdited; struct HistoryMessageEdited;
Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback( Fn<void(ChannelData*, MsgId)> HistoryDependentItemCallback(
const FullMsgId &msgId); not_null<HistoryItem*> item);
MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer); MTPDmessage::Flags NewMessageFlags(not_null<PeerData*> peer);
MTPDmessage_ClientFlags NewMessageClientFlags(); MTPDmessage_ClientFlags NewMessageClientFlags();
QString GetErrorTextForSending( QString GetErrorTextForSending(

View file

@ -687,7 +687,7 @@ void HistoryService::createFromMtp(const MTPDmessageService &message) {
history()->session().api().requestMessageData( history()->session().api().requestMessageData(
history()->peer->asChannel(), history()->peer->asChannel(),
dependent->msgId, dependent->msgId,
HistoryDependentItemCallback(fullId())); HistoryDependentItemCallback(this));
} }
} }
} }

View file

@ -371,7 +371,9 @@ HistoryWidget::HistoryWidget(
_topBar->hide(); _topBar->hide();
_scroll->hide(); _scroll->hide();
_keyboard = _kbScroll->setOwnedWidget(object_ptr<BotKeyboard>(this)); _keyboard = _kbScroll->setOwnedWidget(object_ptr<BotKeyboard>(
&session(),
this));
_kbScroll->hide(); _kbScroll->hide();
updateScrollColors(); updateScrollColors();
@ -1039,7 +1041,7 @@ void HistoryWidget::updateInlineBotQuery() {
if (!_history) { if (!_history) {
return; return;
} }
const auto query = ParseInlineBotQuery(_field); const auto query = ParseInlineBotQuery(&session(), _field);
if (_inlineBotUsername != query.username) { if (_inlineBotUsername != query.username) {
_inlineBotUsername = query.username; _inlineBotUsername = query.username;
if (_inlineBotResolveRequestId) { if (_inlineBotResolveRequestId) {
@ -1780,7 +1782,7 @@ void HistoryWidget::showHistory(
_contactStatus = nullptr; _contactStatus = nullptr;
// Unload lottie animations. // Unload lottie animations.
Auth().data().unloadHeavyViewParts(HistoryInner::ElementDelegate()); session().data().unloadHeavyViewParts(HistoryInner::ElementDelegate());
if (peerId) { if (peerId) {
_peer = session().data().peer(peerId); _peer = session().data().peer(peerId);
@ -3841,7 +3843,7 @@ void HistoryWidget::inlineBotResolveDone(
}(); }();
session().data().processChats(data.vchats()); session().data().processChats(data.vchats());
const auto query = ParseInlineBotQuery(_field); const auto query = ParseInlineBotQuery(&session(), _field);
if (_inlineBotUsername == query.username) { if (_inlineBotUsername == query.username) {
applyInlineBotQuery( applyInlineBotQuery(
query.lookingUpBot ? resolvedBot : query.bot, query.lookingUpBot ? resolvedBot : query.bot,

View file

@ -72,10 +72,6 @@ bool SimpleElementDelegate::elementUnderCursor(
return false; return false;
} }
void SimpleElementDelegate::elementAnimationAutoplayAsync(
not_null<const Element*> element) {
}
crl::time SimpleElementDelegate::elementHighlightTime( crl::time SimpleElementDelegate::elementHighlightTime(
not_null<const Element*> element) { not_null<const Element*> element) {
return crl::time(0); return crl::time(0);

View file

@ -43,8 +43,6 @@ public:
not_null<HistoryService*> message, not_null<HistoryService*> message,
Element *replacing = nullptr) = 0; Element *replacing = nullptr) = 0;
virtual bool elementUnderCursor(not_null<const Element*> view) = 0; virtual bool elementUnderCursor(not_null<const Element*> view) = 0;
virtual void elementAnimationAutoplayAsync(
not_null<const Element*> element) = 0;
virtual crl::time elementHighlightTime( virtual crl::time elementHighlightTime(
not_null<const Element*> element) = 0; not_null<const Element*> element) = 0;
virtual bool elementInSelectionMode() = 0; virtual bool elementInSelectionMode() = 0;
@ -71,8 +69,6 @@ public:
not_null<HistoryService*> message, not_null<HistoryService*> message,
Element *replacing = nullptr) override; Element *replacing = nullptr) override;
bool elementUnderCursor(not_null<const Element*> view) override; bool elementUnderCursor(not_null<const Element*> view) override;
void elementAnimationAutoplayAsync(
not_null<const Element*> element) override;
crl::time elementHighlightTime( crl::time elementHighlightTime(
not_null<const Element*> element) override; not_null<const Element*> element) override;
bool elementInSelectionMode() override; bool elementInSelectionMode() override;

View file

@ -1123,17 +1123,6 @@ bool ListWidget::elementUnderCursor(
return (_overElement == view); return (_overElement == view);
} }
void ListWidget::elementAnimationAutoplayAsync(
not_null<const Element*> view) {
crl::on_main(this, [this, msgId = view->data()->fullId()]{
if (const auto view = viewForItem(msgId)) {
if (const auto media = view->media()) {
media->autoplayAnimation();
}
}
});
}
crl::time ListWidget::elementHighlightTime( crl::time ListWidget::elementHighlightTime(
not_null<const HistoryView::Element*> element) { not_null<const HistoryView::Element*> element) {
if (element->data()->fullId() == _highlightedMessageId) { if (element->data()->fullId() == _highlightedMessageId) {

View file

@ -190,8 +190,6 @@ public:
not_null<HistoryService*> message, not_null<HistoryService*> message,
Element *replacing = nullptr) override; Element *replacing = nullptr) override;
bool elementUnderCursor(not_null<const Element*> view) override; bool elementUnderCursor(not_null<const Element*> view) override;
void elementAnimationAutoplayAsync(
not_null<const Element*> view) override;
crl::time elementHighlightTime( crl::time elementHighlightTime(
not_null<const Element*> element) override; not_null<const Element*> element) override;
bool elementInSelectionMode() override; bool elementInSelectionMode() override;

View file

@ -455,7 +455,7 @@ void TopBarWidget::infoClicked() {
// Info::Section(Info::Section::Type::Profile))); // Info::Section(Info::Section::Type::Profile)));
} else if (_activeChat.peer()->isSelf()) { } else if (_activeChat.peer()->isSelf()) {
_controller->showSection(Info::Memento( _controller->showSection(Info::Memento(
_activeChat.peer()->id, _activeChat.peer(),
Info::Section(Storage::SharedMediaType::Photo))); Info::Section(Storage::SharedMediaType::Photo)));
} else { } else {
_controller->showPeerInfo(_activeChat.peer()); _controller->showPeerInfo(_activeChat.peer());

View file

@ -20,18 +20,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Info { namespace Info {
namespace CommonGroups { namespace CommonGroups {
Memento::Memento(not_null<UserData*> user)
: ContentMemento(user, 0) {
}
Section Memento::section() const { Section Memento::section() const {
return Section(Section::Type::CommonGroups); return Section(Section::Type::CommonGroups);
} }
not_null<UserData*> Memento::user() const {
return peer()->asUser();
}
object_ptr<ContentWidget> Memento::createWidget( object_ptr<ContentWidget> Memento::createWidget(
QWidget *parent, QWidget *parent,
not_null<Controller*> controller, not_null<Controller*> controller,
const QRect &geometry) { const QRect &geometry) {
auto result = object_ptr<Widget>( auto result = object_ptr<Widget>(parent, controller, user());
parent,
controller,
Auth().data().user(userId()));
result->setInternalState(geometry, this); result->setInternalState(geometry, this);
return result; return result;
} }
@ -66,7 +71,7 @@ bool Widget::showInternal(not_null<ContentMemento*> memento) {
return false; return false;
} }
if (auto groupsMemento = dynamic_cast<Memento*>(memento.get())) { if (auto groupsMemento = dynamic_cast<Memento*>(memento.get())) {
if (groupsMemento->userId() == user()->bareId()) { if (groupsMemento->user() == user()) {
restoreState(groupsMemento); restoreState(groupsMemento);
return true; return true;
} }
@ -83,7 +88,7 @@ void Widget::setInternalState(
} }
std::unique_ptr<ContentMemento> Widget::doCreateMemento() { std::unique_ptr<ContentMemento> Widget::doCreateMemento() {
auto result = std::make_unique<Memento>(user()->bareId()); auto result = std::make_unique<Memento>(user());
saveState(result.get()); saveState(result.get());
return result; return result;
} }

View file

@ -23,9 +23,7 @@ class InnerWidget;
class Memento final : public ContentMemento { class Memento final : public ContentMemento {
public: public:
Memento(UserId userId) explicit Memento(not_null<UserData*> user);
: ContentMemento(peerFromUser(userId), 0) {
}
object_ptr<ContentWidget> createWidget( object_ptr<ContentWidget> createWidget(
QWidget *parent, QWidget *parent,
@ -34,9 +32,7 @@ public:
Section section() const override; Section section() const override;
UserId userId() const { not_null<UserData*> user() const;
return peerToUser(peerId());
}
void setListState(std::unique_ptr<PeerListState> state); void setListState(std::unique_ptr<PeerListState> state);
std::unique_ptr<PeerListState> listState(); std::unique_ptr<PeerListState> listState();

View file

@ -262,8 +262,8 @@ void ContentWidget::refreshSearchField(bool shown) {
} }
Key ContentMemento::key() const { Key ContentMemento::key() const {
if (const auto peerId = this->peerId()) { if (const auto peer = this->peer()) {
return Key(Auth().data().peer(peerId)); return Key(peer);
//} else if (const auto feed = this->feed()) { // #feed //} else if (const auto feed = this->feed()) { // #feed
// return Key(feed); // return Key(feed);
} else if (const auto poll = this->poll()) { } else if (const auto poll = this->poll()) {

View file

@ -116,8 +116,8 @@ private:
class ContentMemento { class ContentMemento {
public: public:
ContentMemento(PeerId peerId, PeerId migratedPeerId) ContentMemento(not_null<PeerData*> peer, PeerId migratedPeerId)
: _peerId(peerId) : _peer(peer)
, _migratedPeerId(migratedPeerId) { , _migratedPeerId(migratedPeerId) {
} }
//explicit ContentMemento(not_null<Data::Feed*> feed) : _feed(feed) { // #feed //explicit ContentMemento(not_null<Data::Feed*> feed) : _feed(feed) { // #feed
@ -133,8 +133,8 @@ public:
not_null<Controller*> controller, not_null<Controller*> controller,
const QRect &geometry) = 0; const QRect &geometry) = 0;
PeerId peerId() const { PeerData *peer() const {
return _peerId; return _peer;
} }
PeerId migratedPeerId() const { PeerId migratedPeerId() const {
return _migratedPeerId; return _migratedPeerId;
@ -183,7 +183,7 @@ public:
} }
private: private:
const PeerId _peerId = 0; PeerData * const _peer = nullptr;
const PeerId _migratedPeerId = 0; const PeerId _migratedPeerId = 0;
//Data::Feed * const _feed = nullptr; // #feed //Data::Feed * const _feed = nullptr; // #feed
UserData * const _settingsSelf = nullptr; UserData * const _settingsSelf = nullptr;

View file

@ -25,19 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
namespace Info { namespace Info {
namespace {
not_null<PeerData*> CorrectPeer(PeerId peerId) {
Expects(peerId != 0);
const auto result = Auth().data().peer(peerId);
if (const auto to = result->migrateTo()) {
return to;
}
return result;
}
} // namespace
Key::Key(not_null<PeerData*> peer) : _value(peer) { Key::Key(not_null<PeerData*> peer) : _value(peer) {
} }
@ -91,10 +78,13 @@ rpl::producer<SparseIdsMergedSlice> AbstractController::mediaSource(
SparseIdsMergedSlice::UniversalMsgId aroundId, SparseIdsMergedSlice::UniversalMsgId aroundId,
int limitBefore, int limitBefore,
int limitAfter) const { int limitAfter) const {
Expects(peer() != nullptr);
return SharedMediaMergedViewer( return SharedMediaMergedViewer(
&session(),
SharedMediaMergedKey( SharedMediaMergedKey(
SparseIdsMergedSlice::Key( SparseIdsMergedSlice::Key(
peerId(), peer()->id,
migratedPeerId(), migratedPeerId(),
aroundId), aroundId),
section().mediaType()), section().mediaType()),
@ -112,11 +102,8 @@ AbstractController::AbstractController(
, _parent(parent) { , _parent(parent) {
} }
PeerId AbstractController::peerId() const { PeerData *AbstractController::peer() const {
if (const auto peer = key().peer()) { return key().peer();
return peer->id;
}
return PeerId(0);
} }
PeerId AbstractController::migratedPeerId() const { PeerId AbstractController::migratedPeerId() const {
@ -154,7 +141,7 @@ Controller::Controller(
, _widget(widget) , _widget(widget)
, _key(memento->key()) , _key(memento->key())
, _migrated(memento->migratedPeerId() , _migrated(memento->migratedPeerId()
? Auth().data().peer(memento->migratedPeerId()).get() ? window->session().data().peer(memento->migratedPeerId()).get()
: nullptr) : nullptr)
, _section(memento->section()) { , _section(memento->section()) {
updateSearchControllers(memento); updateSearchControllers(memento);
@ -175,7 +162,7 @@ void Controller::setupMigrationViewer() {
const auto section = _section; const auto section = _section;
InvokeQueued(_widget, [=] { InvokeQueued(_widget, [=] {
window->showSection( window->showSection(
Memento(peer->id, section), Memento(peer, section),
Window::SectionShow( Window::SectionShow(
Window::SectionShow::Way::Backward, Window::SectionShow::Way::Backward,
anim::type::instant, anim::type::instant,
@ -195,7 +182,7 @@ rpl::producer<Wrap> Controller::wrapValue() const {
bool Controller::validateMementoPeer( bool Controller::validateMementoPeer(
not_null<ContentMemento*> memento) const { not_null<ContentMemento*> memento) const {
return memento->peerId() == peerId() return memento->peer() == peer()
&& memento->migratedPeerId() == migratedPeerId() && memento->migratedPeerId() == migratedPeerId()
//&& memento->feed() == feed() // #feed //&& memento->feed() == feed() // #feed
&& memento->settingsSelf() == settingsSelf(); && memento->settingsSelf() == settingsSelf();
@ -313,6 +300,7 @@ rpl::producer<SparseIdsMergedSlice> Controller::mediaSource(
} }
return SharedMediaMergedViewer( return SharedMediaMergedViewer(
&session(),
SharedMediaMergedKey( SharedMediaMergedKey(
SparseIdsMergedSlice::Key( SparseIdsMergedSlice::Key(
query.peerId, query.peerId,

View file

@ -114,7 +114,7 @@ public:
virtual PeerData *migrated() const = 0; virtual PeerData *migrated() const = 0;
virtual Section section() const = 0; virtual Section section() const = 0;
PeerId peerId() const; PeerData *peer() const;
PeerId migratedPeerId() const; PeerId migratedPeerId() const;
//Data::Feed *feed() const { // #feed //Data::Feed *feed() const { // #feed
// return key().feed(); // return key().feed();

View file

@ -164,10 +164,10 @@ bool LayerWidget::takeToThirdSection() {
//// shrink the window size. //// shrink the window size.
//// ////
//// See https://github.com/telegramdesktop/tdesktop/issues/4091 //// See https://github.com/telegramdesktop/tdesktop/issues/4091
//Auth().settings().setThirdSectionExtendedBy(0); //localCopy->session()().settings().setThirdSectionExtendedBy(0);
//Auth().settings().setThirdSectionInfoEnabled(true); //localCopy->session()().settings().setThirdSectionInfoEnabled(true);
//Auth().saveSettingsDelayed(); //localCopy->session()().saveSettingsDelayed();
//localCopy->showSection( //localCopy->showSection(
// std::move(memento), // std::move(memento),
// Window::SectionShow( // Window::SectionShow(

View file

@ -27,12 +27,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Info { namespace Info {
Memento::Memento(PeerId peerId) Memento::Memento(not_null<PeerData*> peer)
: Memento(peerId, Section::Type::Profile) { : Memento(peer, Section::Type::Profile) {
} }
Memento::Memento(PeerId peerId, Section section) Memento::Memento(not_null<PeerData*> peer, Section section)
: Memento(DefaultStack(peerId, section)) { : Memento(DefaultStack(peer, section)) {
} }
//Memento::Memento(not_null<Data::Feed*> feed, Section section) // #feed //Memento::Memento(not_null<Data::Feed*> feed, Section section) // #feed
@ -52,10 +52,10 @@ Memento::Memento(std::vector<std::unique_ptr<ContentMemento>> stack)
} }
std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack(
PeerId peerId, not_null<PeerData*> peer,
Section section) { Section section) {
auto result = std::vector<std::unique_ptr<ContentMemento>>(); auto result = std::vector<std::unique_ptr<ContentMemento>>();
result.push_back(DefaultContent(peerId, section)); result.push_back(DefaultContent(peer, section));
return result; return result;
} }
@ -102,7 +102,7 @@ Section Memento::DefaultSection(not_null<PeerData*> peer) {
//} //}
Memento Memento::Default(not_null<PeerData*> peer) { Memento Memento::Default(not_null<PeerData*> peer) {
return Memento(peer->id, DefaultSection(peer)); return Memento(peer, DefaultSection(peer));
} }
// // #feed // // #feed
//Memento Memento::Default(Dialogs::Key key) { //Memento Memento::Default(Dialogs::Key key) {
@ -113,35 +113,29 @@ Memento Memento::Default(not_null<PeerData*> peer) {
//} //}
std::unique_ptr<ContentMemento> Memento::DefaultContent( std::unique_ptr<ContentMemento> Memento::DefaultContent(
PeerId peerId, not_null<PeerData*> peer,
Section section) { Section section) {
Expects(peerId != 0);
auto peer = Auth().data().peer(peerId);
if (auto to = peer->migrateTo()) { if (auto to = peer->migrateTo()) {
peer = to; peer = to;
} }
auto migrated = peer->migrateFrom(); auto migrated = peer->migrateFrom();
peerId = peer->id;
auto migratedPeerId = migrated ? migrated->id : PeerId(0); auto migratedPeerId = migrated ? migrated->id : PeerId(0);
switch (section.type()) { switch (section.type()) {
case Section::Type::Profile: case Section::Type::Profile:
return std::make_unique<Profile::Memento>( return std::make_unique<Profile::Memento>(
peerId, peer,
migratedPeerId); migratedPeerId);
case Section::Type::Media: case Section::Type::Media:
return std::make_unique<Media::Memento>( return std::make_unique<Media::Memento>(
peerId, peer,
migratedPeerId, migratedPeerId,
section.mediaType()); section.mediaType());
case Section::Type::CommonGroups: case Section::Type::CommonGroups:
Assert(peerIsUser(peerId)); return std::make_unique<CommonGroups::Memento>(peer->asUser());
return std::make_unique<CommonGroups::Memento>(
peerToUser(peerId));
case Section::Type::Members: case Section::Type::Members:
return std::make_unique<Members::Memento>( return std::make_unique<Members::Memento>(
peerId, peer,
migratedPeerId); migratedPeerId);
} }
Unexpected("Wrong section type in Info::Memento::DefaultContent()"); Unexpected("Wrong section type in Info::Memento::DefaultContent()");

View file

@ -32,8 +32,8 @@ class WrapWidget;
class Memento final : public Window::SectionMemento { class Memento final : public Window::SectionMemento {
public: public:
explicit Memento(PeerId peerId); explicit Memento(not_null<PeerData*> peer);
Memento(PeerId peerId, Section section); Memento(not_null<PeerData*> peer, Section section);
//Memento(not_null<Data::Feed*> feed, Section section); // #feed //Memento(not_null<Data::Feed*> feed, Section section); // #feed
Memento(Settings::Tag settings, Section section); Memento(Settings::Tag settings, Section section);
Memento(not_null<PollData*> poll, FullMsgId contextId); Memento(not_null<PollData*> poll, FullMsgId contextId);
@ -69,7 +69,7 @@ public:
private: private:
static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( static std::vector<std::unique_ptr<ContentMemento>> DefaultStack(
PeerId peerId, not_null<PeerData*> peer,
Section section); Section section);
//static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( // #feed //static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( // #feed
// not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
@ -85,7 +85,7 @@ private:
// not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
// Section section); // Section section);
static std::unique_ptr<ContentMemento> DefaultContent( static std::unique_ptr<ContentMemento> DefaultContent(
PeerId peerId, not_null<PeerData*> peer,
Section section); Section section);
std::vector<std::unique_ptr<ContentMemento>> _stack; std::vector<std::unique_ptr<ContentMemento>> _stack;

View file

@ -138,9 +138,9 @@ void WrapWidget::injectActiveProfile(Dialogs::Key key) {
} }
void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) { void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) {
const auto firstPeerId = hasStackHistory() const auto firstPeer = hasStackHistory()
? _historyStack.front().section->peerId() ? _historyStack.front().section->peer()
: _controller->peerId(); : _controller->peer();
const auto firstSectionType = hasStackHistory() const auto firstSectionType = hasStackHistory()
? _historyStack.front().section->section().type() ? _historyStack.front().section->section().type()
: _controller->section().type(); : _controller->section().type();
@ -160,12 +160,12 @@ void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) {
: Section::MediaType::kCount; : Section::MediaType::kCount;
if (firstSectionType != expectedType if (firstSectionType != expectedType
|| firstSectionMediaType != expectedMediaType || firstSectionMediaType != expectedMediaType
|| firstPeerId != peer->id) { || firstPeer != peer) {
auto section = peer->isSelf() auto section = peer->isSelf()
? Section(Section::MediaType::Photo) ? Section(Section::MediaType::Photo)
: Section(Section::Type::Profile); : Section(Section::Type::Profile);
injectActiveProfileMemento(std::move( injectActiveProfileMemento(std::move(
Memento(peer->id, section).takeStack().front())); Memento(peer, section).takeStack().front()));
} }
} }
// // #feed // // #feed
@ -519,11 +519,11 @@ void WrapWidget::addProfileNotificationsButton() {
(wrap() == Wrap::Layer (wrap() == Wrap::Layer
? st::infoLayerTopBarNotifications ? st::infoLayerTopBarNotifications
: st::infoTopBarNotifications))); : st::infoTopBarNotifications)));
notifications->addClickHandler([peer] { notifications->addClickHandler([=] {
const auto muteForSeconds = Auth().data().notifyIsMuted(peer) const auto muteForSeconds = peer->owner().notifyIsMuted(peer)
? 0 ? 0
: Data::NotifySettings::kDefaultMutePeriod; : Data::NotifySettings::kDefaultMutePeriod;
Auth().data().updateNotifySettings(peer, muteForSeconds); peer->owner().updateNotifySettings(peer, muteForSeconds);
}); });
Profile::NotificationsEnabledValue( Profile::NotificationsEnabledValue(
peer peer
@ -908,9 +908,9 @@ bool WrapWidget::returnToFirstStackFrame(
if (!hasStackHistory()) { if (!hasStackHistory()) {
return false; return false;
} }
auto firstPeerId = _historyStack.front().section->peerId(); auto firstPeer = _historyStack.front().section->peer();
auto firstSection = _historyStack.front().section->section(); auto firstSection = _historyStack.front().section->section();
if (firstPeerId == memento->peerId() if (firstPeer == memento->peer()
&& firstSection.type() == memento->section().type() && firstSection.type() == memento->section().type()
&& firstSection.type() == Section::Type::Profile) { && firstSection.type() == Section::Type::Profile) {
_historyStack.resize(1); _historyStack.resize(1);

View file

@ -92,7 +92,7 @@ inline auto AddButton(
tracker)->entity(); tracker)->entity();
result->addClickHandler([=] { result->addClickHandler([=] {
navigation->showSection( navigation->showSection(
Info::Memento(peer->id, Section(type))); Info::Memento(peer, Section(type)));
}); });
return result; return result;
}; };
@ -111,7 +111,7 @@ inline auto AddCommonGroupsButton(
tracker)->entity(); tracker)->entity();
result->addClickHandler([=] { result->addClickHandler([=] {
navigation->showSection( navigation->showSection(
Info::Memento(user->id, Section::Type::CommonGroups)); Info::Memento(user, Section::Type::CommonGroups));
}); });
return result; return result;
}; };

View file

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/scroll_area.h" #include "ui/widgets/scroll_area.h"
#include "ui/search_field_controller.h" #include "ui/search_field_controller.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "data/data_peer.h"
#include "styles/style_info.h" #include "styles/style_info.h"
namespace Info { namespace Info {
@ -37,16 +38,16 @@ Type TabIndexToType(int index) {
Memento::Memento(not_null<Controller*> controller) Memento::Memento(not_null<Controller*> controller)
: Memento( : Memento(
controller->peerId(), controller->peer(),
controller->migratedPeerId(), controller->migratedPeerId(),
controller->section().mediaType()) { controller->section().mediaType()) {
} }
Memento::Memento(PeerId peerId, PeerId migratedPeerId, Type type) Memento::Memento(not_null<PeerData*> peer, PeerId migratedPeerId, Type type)
: ContentMemento(peerId, migratedPeerId) : ContentMemento(peer, migratedPeerId)
, _type(type) { , _type(type) {
_searchState.query.type = type; _searchState.query.type = type;
_searchState.query.peerId = peerId; _searchState.query.peerId = peer->id;
_searchState.query.migratedPeerId = migratedPeerId; _searchState.query.migratedPeerId = migratedPeerId;
if (migratedPeerId) { if (migratedPeerId) {
_searchState.migratedList = Storage::SparseIdsList(); _searchState.migratedList = Storage::SparseIdsList();

View file

@ -25,7 +25,7 @@ class InnerWidget;
class Memento final : public ContentMemento { class Memento final : public ContentMemento {
public: public:
Memento(not_null<Controller*> controller); Memento(not_null<Controller*> controller);
Memento(PeerId peerId, PeerId migratedPeerId, Type type); Memento(not_null<PeerData*> peer, PeerId migratedPeerId, Type type);
using SearchState = Api::DelayedSearchController::SavedState; using SearchState = Api::DelayedSearchController::SavedState;

View file

@ -18,12 +18,12 @@ namespace Members {
Memento::Memento(not_null<Controller*> controller) Memento::Memento(not_null<Controller*> controller)
: Memento( : Memento(
controller->peerId(), controller->peer(),
controller->migratedPeerId()) { controller->migratedPeerId()) {
} }
Memento::Memento(PeerId peerId, PeerId migratedPeerId) Memento::Memento(not_null<PeerData*> peer, PeerId migratedPeerId)
: ContentMemento(peerId, migratedPeerId) { : ContentMemento(peer, migratedPeerId) {
} }
Section Memento::section() const { Section Memento::section() const {

View file

@ -24,7 +24,7 @@ using SavedState = Profile::MembersState;
class Memento final : public ContentMemento { class Memento final : public ContentMemento {
public: public:
Memento(not_null<Controller*> controller); Memento(not_null<Controller*> controller);
Memento(PeerId peerId, PeerId migratedPeerId); Memento(not_null<PeerData*> peer, PeerId migratedPeerId);
object_ptr<ContentWidget> createWidget( object_ptr<ContentWidget> createWidget(
QWidget *parent, QWidget *parent,

View file

@ -840,7 +840,7 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
MembersCountValue(channel) | tr::to_count()); MembersCountValue(channel) | tr::to_count());
auto membersCallback = [=] { auto membersCallback = [=] {
controller->showSection(Info::Memento( controller->showSection(Info::Memento(
channel->id, channel,
Section::Type::Members)); Section::Type::Members));
}; };

View file

@ -81,7 +81,7 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
_controller->parentController())); _controller->parentController()));
_cover->showSection( _cover->showSection(
) | rpl::start_with_next([=](Section section) { ) | rpl::start_with_next([=](Section section) {
_controller->showSection(Info::Memento(_peer->id, section)); _controller->showSection(Info::Memento(_peer, section));
}, _cover->lifetime()); }, _cover->lifetime());
_cover->setOnlineCount(rpl::single(0)); _cover->setOnlineCount(rpl::single(0));
auto details = SetupDetails(_controller, parent, _peer); auto details = SetupDetails(_controller, parent, _peer);

View file

@ -150,9 +150,9 @@ rpl::producer<bool> NotificationsEnabledValue(not_null<PeerData*> peer) {
peer, peer,
Notify::PeerUpdate::Flag::NotificationsEnabled Notify::PeerUpdate::Flag::NotificationsEnabled
) | rpl::map([] { return rpl::empty_value(); }), ) | rpl::map([] { return rpl::empty_value(); }),
Auth().data().defaultNotifyUpdates(peer) peer->owner().defaultNotifyUpdates(peer)
) | rpl::map([peer] { ) | rpl::map([=] {
return !Auth().data().notifyIsMuted(peer); return !peer->owner().notifyIsMuted(peer);
}) | rpl::distinct_until_changed(); }) | rpl::distinct_until_changed();
} }
@ -322,6 +322,7 @@ rpl::producer<int> SharedMediaCountValue(
auto aroundId = 0; auto aroundId = 0;
auto limit = 0; auto limit = 0;
auto updated = SharedMediaMergedViewer( auto updated = SharedMediaMergedViewer(
&peer->session(),
SharedMediaMergedKey( SharedMediaMergedKey(
SparseIdsMergedSlice::Key( SparseIdsMergedSlice::Key(
peer->id, peer->id,
@ -391,7 +392,7 @@ rpl::producer<bool> ScamValue(not_null<PeerData*> peer) {
// return rpl::single( // return rpl::single(
// Data::FeedUpdate{ feed, Flag::Channels } // Data::FeedUpdate{ feed, Flag::Channels }
// ) | rpl::then( // ) | rpl::then(
// Auth().data().feedUpdated() // feed->owner().feedUpdated()
// ) | rpl::filter([=](const Data::FeedUpdate &update) { // ) | rpl::filter([=](const Data::FeedUpdate &update) {
// return (update.feed == feed) && (update.flag == Flag::Channels); // return (update.feed == feed) && (update.flag == Flag::Channels);
// }) | rpl::filter([=] { // }) | rpl::filter([=] {

View file

@ -18,12 +18,12 @@ namespace Profile {
Memento::Memento(not_null<Controller*> controller) Memento::Memento(not_null<Controller*> controller)
: Memento( : Memento(
controller->peerId(), controller->peer(),
controller->migratedPeerId()) { controller->migratedPeerId()) {
} }
Memento::Memento(PeerId peerId, PeerId migratedPeerId) Memento::Memento(not_null<PeerData*> peer, PeerId migratedPeerId)
: ContentMemento(peerId, migratedPeerId) { : ContentMemento(peer, migratedPeerId) {
} }
Section Memento::section() const { Section Memento::section() const {

View file

@ -19,7 +19,7 @@ struct MembersState;
class Memento final : public ContentMemento { class Memento final : public ContentMemento {
public: public:
Memento(not_null<Controller*> controller); Memento(not_null<Controller*> controller);
Memento(PeerId peerId, PeerId migratedPeerId); Memento(not_null<PeerData*> peer, PeerId migratedPeerId);
object_ptr<ContentWidget> createWidget( object_ptr<ContentWidget> createWidget(
QWidget *parent, QWidget *parent,

View file

@ -111,13 +111,13 @@ std::unique_ptr<Result> Result::Create(
if (const auto content = r.vcontent()) { if (const auto content = r.vcontent()) {
result->_content_url = GetContentUrl(*content); result->_content_url = GetContentUrl(*content);
if (result->_type == Type::Photo) { if (result->_type == Type::Photo) {
result->_photo = Auth().data().photoFromWeb( result->_photo = session->data().photoFromWeb(
*content, *content,
(imageThumb (imageThumb
? Images::FromWebDocument(*r.vthumb()) ? Images::FromWebDocument(*r.vthumb())
: ImageLocation())); : ImageLocation()));
} else if (contentMime != "text/html"_q) { } else if (contentMime != "text/html"_q) {
result->_document = Auth().data().documentFromWeb( result->_document = session->data().documentFromWeb(
result->adjustAttributes(*content), result->adjustAttributes(*content),
(imageThumb (imageThumb
? Images::FromWebDocument(*r.vthumb()) ? Images::FromWebDocument(*r.vthumb())
@ -140,10 +140,10 @@ std::unique_ptr<Result> Result::Create(
result->_title = qs(r.vtitle().value_or_empty()); result->_title = qs(r.vtitle().value_or_empty());
result->_description = qs(r.vdescription().value_or_empty()); result->_description = qs(r.vdescription().value_or_empty());
if (const auto photo = r.vphoto()) { if (const auto photo = r.vphoto()) {
result->_photo = Auth().data().processPhoto(*photo); result->_photo = session->data().processPhoto(*photo);
} }
if (const auto document = r.vdocument()) { if (const auto document = r.vdocument()) {
result->_document = Auth().data().processDocument(*document); result->_document = session->data().processDocument(*document);
} }
message = &r.vsend_message(); message = &r.vsend_message();
} break; } break;
@ -186,7 +186,7 @@ std::unique_ptr<Result> Result::Create(
message, message,
entities); entities);
} else if (result->_type == Type::Game) { } else if (result->_type == Type::Game) {
result->createGame(); result->createGame(session);
result->sendData = std::make_unique<internal::SendGame>( result->sendData = std::make_unique<internal::SendGame>(
session, session,
result->_game); result->_game);
@ -412,11 +412,13 @@ QString Result::getLayoutDescription() const {
Result::~Result() { Result::~Result() {
} }
void Result::createGame() { void Result::createGame(not_null<Main::Session*> session) {
if (_game) return; if (_game) {
return;
}
const auto gameId = rand_value<GameId>(); const auto gameId = rand_value<GameId>();
_game = Auth().data().game( _game = session->data().game(
gameId, gameId,
0, 0,
QString(), QString(),

View file

@ -77,7 +77,7 @@ public:
~Result(); ~Result();
private: private:
void createGame(); void createGame(not_null<Main::Session*> session);
QSize thumbBox() const; QSize thumbBox() const;
MTPWebDocument adjustAttributes(const MTPWebDocument &document); MTPWebDocument adjustAttributes(const MTPWebDocument &document);
MTPVector<MTPDocumentAttribute> adjustAttributes( MTPVector<MTPDocumentAttribute> adjustAttributes(

View file

@ -32,7 +32,7 @@ namespace Intro {
namespace details { namespace details {
namespace { namespace {
void PrepareSupportMode() { void PrepareSupportMode(not_null<Main::Session*> session) {
using ::Data::AutoDownload::Full; using ::Data::AutoDownload::Full;
anim::SetDisabled(true); anim::SetDisabled(true);
@ -41,7 +41,7 @@ void PrepareSupportMode() {
Global::SetDesktopNotify(false); Global::SetDesktopNotify(false);
Global::SetSoundNotify(false); Global::SetSoundNotify(false);
Global::SetFlashBounceNotify(false); Global::SetFlashBounceNotify(false);
Auth().settings().autoDownload() = Full::FullDisabled(); session->settings().autoDownload() = Full::FullDisabled();
Local::writeUserSettings(); Local::writeUserSettings();
} }
@ -151,7 +151,7 @@ void Step::finish(const MTPUser &user, QImage &&photo) {
session.api().uploadPeerPhoto(session.user(), std::move(photo)); session.api().uploadPeerPhoto(session.user(), std::move(photo));
} }
if (session.supportMode()) { if (session.supportMode()) {
PrepareSupportMode(); PrepareSupportMode(&session);
} }
} }
} }

View file

@ -2571,7 +2571,7 @@ auto MainWidget::thirdSectionForCurrentMainSection(
return std::move(_thirdSectionFromStack); return std::move(_thirdSectionFromStack);
} else if (const auto peer = key.peer()) { } else if (const auto peer = key.peer()) {
return std::make_unique<Info::Memento>( return std::make_unique<Info::Memento>(
peer->id, peer,
Info::Memento::DefaultSection(peer)); Info::Memento::DefaultSection(peer));
//} else if (const auto feed = key.feed()) { // #feed //} else if (const auto feed = key.feed()) { // #feed
// return std::make_unique<Info::Memento>( // return std::make_unique<Info::Memento>(

View file

@ -176,7 +176,9 @@ void Instance::setCurrent(const AudioMsgId &audioId) {
data->current = audioId; data->current = audioId;
data->isPlaying = false; data->isPlaying = false;
const auto item = Auth().data().message(data->current.contextId()); const auto item = (audioId.audio() && audioId.contextId())
? audioId.audio()->owner().message(audioId.contextId())
: nullptr;
if (item) { if (item) {
data->history = item->history()->migrateToOrMe(); data->history = item->history()->migrateToOrMe();
data->migrated = data->history->migrateFrom(); data->migrated = data->history->migrateFrom();
@ -264,6 +266,7 @@ void Instance::validatePlaylist(not_null<Data*> data) {
if (const auto key = playlistKey(data)) { if (const auto key = playlistKey(data)) {
data->playlistRequestedKey = key; data->playlistRequestedKey = key;
SharedMediaMergedViewer( SharedMediaMergedViewer(
&data->history->session(),
SharedMediaMergedKey(*key, data->overview), SharedMediaMergedKey(*key, data->overview),
kIdsLimit, kIdsLimit,
kIdsLimit kIdsLimit
@ -302,8 +305,9 @@ HistoryItem *Instance::itemByIndex(not_null<Data*> data, int index) {
|| index >= data->playlistSlice->size()) { || index >= data->playlistSlice->size()) {
return nullptr; return nullptr;
} }
Assert(data->history != nullptr);
const auto fullId = (*data->playlistSlice)[index]; const auto fullId = (*data->playlistSlice)[index];
return Auth().data().message(fullId); return data->history->owner().message(fullId);
} }
bool Instance::moveInPlaylist( bool Instance::moveInPlaylist(
@ -740,20 +744,21 @@ void Instance::handleStreamingUpdate(
HistoryItem *Instance::roundVideoItem() const { HistoryItem *Instance::roundVideoItem() const {
const auto data = getData(AudioMsgId::Type::Voice); const auto data = getData(AudioMsgId::Type::Voice);
return (data->streamed return (data->streamed
&& !data->streamed->instance.info().video.size.isEmpty()) && !data->streamed->instance.info().video.size.isEmpty()
? Auth().data().message(data->streamed->id.contextId()) && data->history)
? data->history->owner().message(data->streamed->id.contextId())
: nullptr; : nullptr;
} }
void Instance::requestRoundVideoResize() const { void Instance::requestRoundVideoResize() const {
if (const auto item = roundVideoItem()) { if (const auto item = roundVideoItem()) {
Auth().data().requestItemResize(item); item->history()->owner().requestItemResize(item);
} }
} }
void Instance::requestRoundVideoRepaint() const { void Instance::requestRoundVideoRepaint() const {
if (const auto item = roundVideoItem()) { if (const auto item = roundVideoItem()) {
Auth().data().requestItemRepaint(item); item->history()->owner().requestItemRepaint(item);
} }
} }

View file

@ -288,7 +288,7 @@ void Panel::refreshList() {
}, weak->lifetime()); }, weak->lifetime());
auto memento = Info::Media::Memento( auto memento = Info::Media::Memento(
peerId(), peer,
migratedPeerId(), migratedPeerId(),
section().mediaType()); section().mediaType());
memento.setAroundId(contextId); memento.setAroundId(contextId);

View file

@ -302,9 +302,13 @@ void Widget::mouseReleaseEvent(QMouseEvent *e) {
if (auto downLabels = base::take(_labelsDown)) { if (auto downLabels = base::take(_labelsDown)) {
if (_labelsOver == downLabels) { if (_labelsOver == downLabels) {
if (_type == AudioMsgId::Type::Voice) { if (_type == AudioMsgId::Type::Voice) {
auto current = instance()->current(_type); const auto current = instance()->current(_type);
if (auto item = Auth().data().message(current.contextId())) { const auto document = current.audio();
Ui::showPeerHistoryAtItem(item); const auto context = current.contextId();
if (document && context) {
if (const auto item = document->owner().message(context)) {
Ui::showPeerHistoryAtItem(item);
}
} }
} }
} }
@ -516,7 +520,7 @@ void Widget::handleSongChange() {
TextWithEntities textWithEntities; TextWithEntities textWithEntities;
if (document->isVoiceMessage() || document->isVideoMessage()) { if (document->isVoiceMessage() || document->isVideoMessage()) {
if (const auto item = Auth().data().message(current.contextId())) { if (const auto item = document->owner().message(current.contextId())) {
const auto name = item->fromOriginal()->name; const auto name = item->fromOriginal()->name;
const auto date = [item] { const auto date = [item] {
const auto parsed = ItemDateTime(item); const auto parsed = ItemDateTime(item);

View file

@ -1589,12 +1589,15 @@ bool OverlayWidget::validSharedMedia() const {
} }
void OverlayWidget::validateSharedMedia() { void OverlayWidget::validateSharedMedia() {
if (auto key = sharedMediaKey()) { if (const auto key = sharedMediaKey()) {
Assert(_history != nullptr);
_sharedMedia = std::make_unique<SharedMedia>(*key); _sharedMedia = std::make_unique<SharedMedia>(*key);
auto viewer = (key->type == SharedMediaType::ChatPhoto) auto viewer = (key->type == SharedMediaType::ChatPhoto)
? SharedMediaWithLastReversedViewer ? SharedMediaWithLastReversedViewer
: SharedMediaWithLastViewer; : SharedMediaWithLastViewer;
viewer( viewer(
&_history->session(),
*key, *key,
kIdsLimit, kIdsLimit,
kIdsLimit kIdsLimit
@ -1656,8 +1659,11 @@ bool OverlayWidget::validUserPhotos() const {
void OverlayWidget::validateUserPhotos() { void OverlayWidget::validateUserPhotos() {
if (const auto key = userPhotosKey()) { if (const auto key = userPhotosKey()) {
Assert(_user != nullptr);
_userPhotos = std::make_unique<UserPhotos>(*key); _userPhotos = std::make_unique<UserPhotos>(*key);
UserPhotosReversedViewer( UserPhotosReversedViewer(
&_user->session(),
*key, *key,
kIdsLimit, kIdsLimit,
kIdsLimit kIdsLimit

View file

@ -339,6 +339,7 @@ FormRequest::FormRequest(
} }
EditFile::EditFile( EditFile::EditFile(
not_null<Main::Session*> session,
not_null<const Value*> value, not_null<const Value*> value,
FileType type, FileType type,
const File &fields, const File &fields,
@ -346,13 +347,15 @@ EditFile::EditFile(
: value(value) : value(value)
, type(type) , type(type)
, fields(std::move(fields)) , fields(std::move(fields))
, uploadData(std::move(uploadData)) , uploadData(session, std::move(uploadData))
, guard(std::make_shared<bool>(true)) { , guard(std::make_shared<bool>(true)) {
} }
UploadScanDataPointer::UploadScanDataPointer( UploadScanDataPointer::UploadScanDataPointer(
not_null<Main::Session*> session,
std::unique_ptr<UploadScanData> &&value) std::unique_ptr<UploadScanData> &&value)
: _value(std::move(value)) { : _session(session)
, _value(std::move(value)) {
} }
UploadScanDataPointer::UploadScanDataPointer( UploadScanDataPointer::UploadScanDataPointer(
@ -364,7 +367,7 @@ UploadScanDataPointer &UploadScanDataPointer::operator=(
UploadScanDataPointer::~UploadScanDataPointer() { UploadScanDataPointer::~UploadScanDataPointer() {
if (const auto value = _value.get()) { if (const auto value = _value.get()) {
if (const auto fullId = value->fullId) { if (const auto fullId = value->fullId) {
Auth().uploader().cancel(fullId); _session->uploader().cancel(fullId);
} }
} }
} }
@ -460,12 +463,12 @@ int Value::whatNotFilled() const {
return result; return result;
} }
void Value::saveInEdit() { void Value::saveInEdit(not_null<Main::Session*> session) {
const auto saveList = [&](FileType type) { const auto saveList = [&](FileType type) {
filesInEdit(type) = ranges::view::all( filesInEdit(type) = ranges::view::all(
files(type) files(type)
) | ranges::view::transform([=](const File &file) { ) | ranges::view::transform([=](const File &file) {
return EditFile(this, type, file, nullptr); return EditFile(session, this, type, file, nullptr);
}) | ranges::to_vector; }) | ranges::to_vector;
}; };
saveList(FileType::Scan); saveList(FileType::Scan);
@ -474,6 +477,7 @@ void Value::saveInEdit() {
specialScansInEdit.clear(); specialScansInEdit.clear();
for (const auto &[type, scan] : specialScans) { for (const auto &[type, scan] : specialScans) {
specialScansInEdit.emplace(type, EditFile( specialScansInEdit.emplace(type, EditFile(
session,
this, this,
type, type,
scan, scan,
@ -627,6 +631,10 @@ FormController::FormController(
, _view(std::make_unique<PanelController>(this)) { , _view(std::make_unique<PanelController>(this)) {
} }
Main::Session &FormController::session() const {
return _controller->session();
}
void FormController::show() { void FormController::show() {
requestForm(); requestForm();
requestPassword(); requestPassword();
@ -876,7 +884,7 @@ void FormController::submitPassword(
saved.hashForAuth = base::take(_passwordCheckHash); saved.hashForAuth = base::take(_passwordCheckHash);
saved.hashForSecret = hashForSecret; saved.hashForSecret = hashForSecret;
saved.secretId = _secretId; saved.secretId = _secretId;
Auth().data().rememberPassportCredentials( session().data().rememberPassportCredentials(
std::move(saved), std::move(saved),
kRememberCredentialsDelay); kRememberCredentialsDelay);
} }
@ -963,7 +971,7 @@ void FormController::checkSavedPasswordSettings(
} }
} }
if (_secret.empty()) { if (_secret.empty()) {
Auth().data().forgetPassportCredentials(); session().data().forgetPassportCredentials();
showForm(); showForm();
} }
}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
@ -971,7 +979,7 @@ void FormController::checkSavedPasswordSettings(
if (error.type() != qstr("SRP_ID_INVALID") if (error.type() != qstr("SRP_ID_INVALID")
|| !handleSrpIdInvalid(_passwordCheckRequestId)) { || !handleSrpIdInvalid(_passwordCheckRequestId)) {
} else { } else {
Auth().data().forgetPassportCredentials(); session().data().forgetPassportCredentials();
showForm(); showForm();
} }
}).send(); }).send();
@ -1366,7 +1374,12 @@ void FormController::uploadScan(
} }
const auto nonconst = findValue(value); const auto nonconst = findValue(value);
const auto fileIndex = [&]() -> std::optional<int> { const auto fileIndex = [&]() -> std::optional<int> {
auto scanInEdit = EditFile{ nonconst, type, File(), nullptr }; auto scanInEdit = EditFile(
&session(),
nonconst,
type,
File(),
nullptr);
if (type == FileType::Scan || type == FileType::Translation) { if (type == FileType::Scan || type == FileType::Translation) {
auto &list = nonconst->filesInEdit(type); auto &list = nonconst->filesInEdit(type);
auto scanIndex = int(list.size()); auto scanIndex = int(list.size());
@ -1494,17 +1507,17 @@ void FormController::subscribeToUploader() {
using namespace Storage; using namespace Storage;
Auth().uploader().secureReady( session().uploader().secureReady(
) | rpl::start_with_next([=](const UploadSecureDone &data) { ) | rpl::start_with_next([=](const UploadSecureDone &data) {
scanUploadDone(data); scanUploadDone(data);
}, _uploaderSubscriptions); }, _uploaderSubscriptions);
Auth().uploader().secureProgress( session().uploader().secureProgress(
) | rpl::start_with_next([=](const UploadSecureProgress &data) { ) | rpl::start_with_next([=](const UploadSecureProgress &data) {
scanUploadProgress(data); scanUploadProgress(data);
}, _uploaderSubscriptions); }, _uploaderSubscriptions);
Auth().uploader().secureFailed( session().uploader().secureFailed(
) | rpl::start_with_next([=](const FullMsgId &fullId) { ) | rpl::start_with_next([=](const FullMsgId &fullId) {
scanUploadFail(fullId); scanUploadFail(fullId);
}, _uploaderSubscriptions); }, _uploaderSubscriptions);
@ -1515,7 +1528,9 @@ void FormController::uploadEncryptedFile(
UploadScanData &&data) { UploadScanData &&data) {
subscribeToUploader(); subscribeToUploader();
file.uploadData = std::make_unique<UploadScanData>(std::move(data)); file.uploadData = UploadScanDataPointer(
&session(),
std::make_unique<UploadScanData>(std::move(data)));
auto prepared = std::make_shared<FileLoadResult>( auto prepared = std::make_shared<FileLoadResult>(
TaskId(), TaskId(),
@ -1532,8 +1547,10 @@ void FormController::uploadEncryptedFile(
file.uploadData->fullId = FullMsgId( file.uploadData->fullId = FullMsgId(
0, 0,
Auth().data().nextLocalMessageId()); session().data().nextLocalMessageId());
Auth().uploader().upload(file.uploadData->fullId, std::move(prepared)); session().uploader().upload(
file.uploadData->fullId,
std::move(prepared));
} }
void FormController::scanUploadDone(const Storage::UploadSecureDone &data) { void FormController::scanUploadDone(const Storage::UploadSecureDone &data) {
@ -1583,7 +1600,7 @@ QString FormController::defaultEmail() const {
} }
QString FormController::defaultPhoneNumber() const { QString FormController::defaultPhoneNumber() const {
return Auth().user()->phone(); return session().user()->phone();
} }
auto FormController::scanUpdated() const auto FormController::scanUpdated() const
@ -1705,7 +1722,7 @@ void FormController::startValueEdit(not_null<const Value*> value) {
loadFile(scan); loadFile(scan);
} }
} }
nonconst->saveInEdit(); nonconst->saveInEdit(&session());
} }
void FormController::loadFile(File &file) { void FormController::loadFile(File &file) {
@ -1725,7 +1742,7 @@ void FormController::loadFile(File &file) {
std::make_unique<mtpFileLoader>( std::make_unique<mtpFileLoader>(
StorageFileLocation( StorageFileLocation(
file.dcId, file.dcId,
Auth().userId(), session().userId(),
MTP_inputSecureFileLocation( MTP_inputSecureFileLocation(
MTP_long(file.id), MTP_long(file.id),
MTP_long(file.accessHash))), MTP_long(file.accessHash))),
@ -2235,7 +2252,7 @@ void FormController::saveSecret(
MTP_bytes(encryptedSecret), MTP_bytes(encryptedSecret),
MTP_long(saved.secretId))) MTP_long(saved.secretId)))
)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
Auth().data().rememberPassportCredentials( session().data().rememberPassportCredentials(
std::move(saved), std::move(saved),
kRememberCredentialsDelay); kRememberCredentialsDelay);
@ -2342,7 +2359,7 @@ void FormController::fillDownloadedFile(
if (bytes.size() > Storage::kMaxFileInMemory) { if (bytes.size() > Storage::kMaxFileInMemory) {
return; return;
} }
Auth().data().cache().put( session().data().cache().put(
Data::DocumentCacheKey(destination.dcId, destination.id), Data::DocumentCacheKey(destination.dcId, destination.id),
Storage::Cache::Database::TaggedValue( Storage::Cache::Database::TaggedValue(
QByteArray( QByteArray(
@ -2495,7 +2512,7 @@ bool FormController::parseForm(const MTPaccount_AuthorizationForm &result) {
const auto &data = result.c_account_authorizationForm(); const auto &data = result.c_account_authorizationForm();
Auth().data().processUsers(data.vusers()); session().data().processUsers(data.vusers());
for (const auto &value : data.vvalues().v) { for (const auto &value : data.vvalues().v) {
auto parsed = parseValue(value); auto parsed = parseValue(value);
@ -2529,7 +2546,7 @@ bool FormController::parseForm(const MTPaccount_AuthorizationForm &result) {
if (!ValidateForm(_form)) { if (!ValidateForm(_form)) {
return false; return false;
} }
_bot = Auth().data().userLoaded(_request.botId); _bot = session().data().userLoaded(_request.botId);
_form.pendingErrors = data.verrors().v; _form.pendingErrors = data.verrors().v;
return true; return true;
} }
@ -2597,7 +2614,7 @@ void FormController::showForm() {
} else if (_password.request) { } else if (_password.request) {
if (!_savedPasswordValue.isEmpty()) { if (!_savedPasswordValue.isEmpty()) {
submitPassword(base::duplicate(_savedPasswordValue)); submitPassword(base::duplicate(_savedPasswordValue));
} else if (const auto saved = Auth().data().passportCredentials()) { } else if (const auto saved = session().data().passportCredentials()) {
checkSavedPasswordSettings(*saved); checkSavedPasswordSettings(*saved);
} else { } else {
_view->showAskPassword(); _view->showAskPassword();

View file

@ -23,6 +23,10 @@ namespace Window {
class SessionController; class SessionController;
} // namespace Window } // namespace Window
namespace Main {
class Session;
} // namespace Main
namespace Passport { namespace Passport {
struct Config { struct Config {
@ -73,7 +77,9 @@ struct UploadScanData {
class UploadScanDataPointer { class UploadScanDataPointer {
public: public:
UploadScanDataPointer(std::unique_ptr<UploadScanData> &&value); UploadScanDataPointer(
not_null<Main::Session*> session,
std::unique_ptr<UploadScanData> &&value);
UploadScanDataPointer(UploadScanDataPointer &&other); UploadScanDataPointer(UploadScanDataPointer &&other);
UploadScanDataPointer &operator=(UploadScanDataPointer &&other); UploadScanDataPointer &operator=(UploadScanDataPointer &&other);
~UploadScanDataPointer(); ~UploadScanDataPointer();
@ -84,6 +90,7 @@ public:
UploadScanData *operator->() const; UploadScanData *operator->() const;
private: private:
not_null<Main::Session*> _session;
std::unique_ptr<UploadScanData> _value; std::unique_ptr<UploadScanData> _value;
}; };
@ -115,6 +122,7 @@ struct File {
struct EditFile { struct EditFile {
EditFile( EditFile(
not_null<Main::Session*> session,
not_null<const Value*> value, not_null<const Value*> value,
FileType type, FileType type,
const File &fields, const File &fields,
@ -188,7 +196,7 @@ struct Value {
bool requiresSpecialScan(FileType type) const; bool requiresSpecialScan(FileType type) const;
bool requiresScan(FileType type) const; bool requiresScan(FileType type) const;
bool scansAreFilled() const; bool scansAreFilled() const;
void saveInEdit(); void saveInEdit(not_null<Main::Session*> session);
void clearEditData(); void clearEditData();
bool uploadingScan() const; bool uploadingScan() const;
bool saving() const; bool saving() const;
@ -324,9 +332,10 @@ public:
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
const FormRequest &request); const FormRequest &request);
not_null<Window::SessionController*> window() const { [[nodiscard]] not_null<Window::SessionController*> window() const {
return _controller; return _controller;
} }
[[nodiscard]] Main::Session &session() const;
void show(); void show();
UserData *bot() const; UserData *bot() const;

View file

@ -598,7 +598,7 @@ void ChatBackground::checkUploadWallPaper() {
LOG(("API Error: " LOG(("API Error: "
"Got wallPaperNoFile after account.UploadWallPaper.")); "Got wallPaperNoFile after account.UploadWallPaper."));
}); });
if (const auto paper = Data::WallPaper::Create(result)) { if (const auto paper = Data::WallPaper::Create(_session, result)) {
setPaper(*paper); setPaper(*paper);
writeNewBackgroundSettings(); writeNewBackgroundSettings();
notify(BackgroundUpdate(BackgroundUpdate::Type::New, tile())); notify(BackgroundUpdate(BackgroundUpdate::Type::New, tile()));

View file

@ -68,18 +68,18 @@ Main::Session &SessionNavigation::session() const {
void SessionNavigation::showPeerInfo( void SessionNavigation::showPeerInfo(
PeerId peerId, PeerId peerId,
const SectionShow &params) { const SectionShow &params) {
//if (Adaptive::ThreeColumn() showPeerInfo(_session->data().peer(peerId), params);
// && !_session->settings().thirdSectionInfoEnabled()) {
// _session->settings().setThirdSectionInfoEnabled(true);
// _session->saveSettingsDelayed();
//}
showSection(Info::Memento(peerId), params);
} }
void SessionNavigation::showPeerInfo( void SessionNavigation::showPeerInfo(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const SectionShow &params) { const SectionShow &params) {
showPeerInfo(peer->id, params); //if (Adaptive::ThreeColumn()
// && !_session->settings().thirdSectionInfoEnabled()) {
// _session->settings().setThirdSectionInfoEnabled(true);
// _session->saveSettingsDelayed();
//}
showSection(Info::Memento(peer), params);
} }
void SessionNavigation::showPeerInfo( void SessionNavigation::showPeerInfo(