Remove some usages of App::main().

This commit is contained in:
John Preston 2020-06-10 22:08:17 +04:00
parent ea86433be5
commit ee43027bea
53 changed files with 518 additions and 429 deletions

View file

@ -477,7 +477,7 @@ void ApiWrap::importChatInvite(const QString &hash) {
handleChats(data.vchats()); handleChats(data.vchats());
}, [&](auto &&) { }, [&](auto &&) {
LOG(("API Error: unexpected update cons %1 " LOG(("API Error: unexpected update cons %1 "
"(MainWidget::inviteImportDone)").arg(result.type())); "(ApiWrap::importChatInvite)").arg(result.type()));
}); });
}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
const auto &type = error.type(); const auto &type = error.type();

View file

@ -207,16 +207,16 @@ namespace App {
if (update.paletteChanged()) { if (update.paletteChanged()) {
createPaletteCorners(); createPaletteCorners();
if (App::main()) { if (const auto m = App::main()) { // multi good
App::main()->updateScrollColors(); m->updateScrollColors();
} }
HistoryView::serviceColorsUpdated(); HistoryView::serviceColorsUpdated();
} else if (update.type == Update::Type::New) { } else if (update.type == Update::Type::New) {
prepareCorners(StickerCorners, st::dateRadius, st::msgServiceBg); prepareCorners(StickerCorners, st::dateRadius, st::msgServiceBg);
prepareCorners(StickerSelectedCorners, st::dateRadius, st::msgServiceBgSelected); prepareCorners(StickerSelectedCorners, st::dateRadius, st::msgServiceBgSelected);
if (App::main()) { if (const auto m = App::main()) { // multi good
App::main()->updateScrollColors(); m->updateScrollColors();
} }
HistoryView::serviceColorsUpdated(); HistoryView::serviceColorsUpdated();
} }

View file

@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_document_media.h" #include "data/data_document_media.h"
#include "boxes/background_preview_box.h" #include "boxes/background_preview_box.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "window/window_session_controller.h"
#include "app.h" #include "app.h"
#include "styles/style_overview.h" #include "styles/style_overview.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
@ -131,8 +132,10 @@ private:
}; };
BackgroundBox::BackgroundBox(QWidget*, not_null<Main::Session*> session) BackgroundBox::BackgroundBox(
: _session(session) { QWidget*,
not_null<Window::SessionController*> controller)
: _controller(controller) {
} }
void BackgroundBox::prepare() { void BackgroundBox::prepare() {
@ -143,13 +146,13 @@ void BackgroundBox::prepare() {
setDimensions(st::boxWideWidth, st::boxMaxListHeight); setDimensions(st::boxWideWidth, st::boxMaxListHeight);
_inner = setInnerWidget( _inner = setInnerWidget(
object_ptr<Inner>(this, _session), object_ptr<Inner>(this, &_controller->session()),
st::backgroundScroll); st::backgroundScroll);
_inner->chooseEvents( _inner->chooseEvents(
) | rpl::start_with_next([=](const Data::WallPaper &paper) { ) | rpl::start_with_next([=](const Data::WallPaper &paper) {
Ui::show( Ui::show(
Box<BackgroundPreviewBox>(_session, paper), Box<BackgroundPreviewBox>(_controller, paper),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
}, _inner->lifetime()); }, _inner->lifetime());
@ -161,7 +164,7 @@ void BackgroundBox::prepare() {
void BackgroundBox::removePaper(const Data::WallPaper &paper) { void BackgroundBox::removePaper(const Data::WallPaper &paper) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
const auto session = _session; const auto session = &_controller->session();
const auto remove = [=, weak = Ui::MakeWeak(this)]{ const auto remove = [=, weak = Ui::MakeWeak(this)]{
if (*box) { if (*box) {
(*box)->closeBox(); (*box)->closeBox();

View file

@ -9,9 +9,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
namespace Main { namespace Window {
class Session; class SessionController;
} // namespace Main } // namespace Window
namespace Data { namespace Data {
class WallPaper; class WallPaper;
@ -19,7 +19,7 @@ class WallPaper;
class BackgroundBox : public Ui::BoxContent { class BackgroundBox : public Ui::BoxContent {
public: public:
BackgroundBox(QWidget*, not_null<Main::Session*> session); BackgroundBox(QWidget*, not_null<Window::SessionController*> controller);
protected: protected:
void prepare() override; void prepare() override;
@ -29,7 +29,7 @@ private:
void removePaper(const Data::WallPaper &paper); void removePaper(const Data::WallPaper &paper);
const not_null<Main::Session*> _session; const not_null<Window::SessionController*> _controller;
QPointer<Inner> _inner; QPointer<Inner> _inner;

View file

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unixtime.h" #include "base/unixtime.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
#include "boxes/background_preview_box.h" #include "boxes/background_preview_box.h"
#include "window/window_session_controller.h"
#include "app.h" #include "app.h"
#include "styles/style_history.h" #include "styles/style_history.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
@ -396,18 +397,18 @@ QImage PrepareScaledFromFull(
BackgroundPreviewBox::BackgroundPreviewBox( BackgroundPreviewBox::BackgroundPreviewBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const Data::WallPaper &paper) const Data::WallPaper &paper)
: _session(session) : _controller(controller)
, _text1(GenerateTextItem( , _text1(GenerateTextItem(
delegate(), delegate(),
_session->data().history( _controller->session().data().history(
peerFromUser(PeerData::kServiceNotificationsId)), peerFromUser(PeerData::kServiceNotificationsId)),
tr::lng_background_text1(tr::now), tr::lng_background_text1(tr::now),
false)) false))
, _text2(GenerateTextItem( , _text2(GenerateTextItem(
delegate(), delegate(),
_session->data().history( _controller->session().data().history(
peerFromUser(PeerData::kServiceNotificationsId)), peerFromUser(PeerData::kServiceNotificationsId)),
tr::lng_background_text2(tr::now), tr::lng_background_text2(tr::now),
true)) true))
@ -417,7 +418,9 @@ BackgroundPreviewBox::BackgroundPreviewBox(
if (_media) { if (_media) {
_media->thumbnailWanted(_paper.fileOrigin()); _media->thumbnailWanted(_paper.fileOrigin());
} }
subscribe(_session->downloaderTaskFinished(), [=] { update(); }); subscribe(_controller->session().downloaderTaskFinished(), [=] {
update();
});
} }
not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() { not_null<HistoryView::ElementDelegate*> BackgroundPreviewBox::delegate() {
@ -500,9 +503,9 @@ void BackgroundPreviewBox::createBlurCheckbox() {
void BackgroundPreviewBox::apply() { void BackgroundPreviewBox::apply() {
const auto install = (_paper.id() != Window::Theme::Background()->id()) const auto install = (_paper.id() != Window::Theme::Background()->id())
&& Data::IsCloudWallPaper(_paper); && Data::IsCloudWallPaper(_paper);
App::main()->setChatBackground(_paper, std::move(_full)); _controller->content()->setChatBackground(_paper, std::move(_full));
if (install) { if (install) {
_session->api().request(MTPaccount_InstallWallPaper( _controller->session().api().request(MTPaccount_InstallWallPaper(
_paper.mtpInput(), _paper.mtpInput(),
_paper.mtpSettings() _paper.mtpSettings()
)).send(); )).send();
@ -763,12 +766,12 @@ void BackgroundPreviewBox::checkLoadedDocument() {
} }
bool BackgroundPreviewBox::Start( bool BackgroundPreviewBox::Start(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const QString &slug, const QString &slug,
const QMap<QString, QString> &params) { const QMap<QString, QString> &params) {
if (const auto paper = Data::WallPaper::FromColorSlug(slug)) { if (const auto paper = Data::WallPaper::FromColorSlug(slug)) {
Ui::show(Box<BackgroundPreviewBox>( Ui::show(Box<BackgroundPreviewBox>(
session, controller,
paper->withUrlParams(params))); paper->withUrlParams(params)));
return true; return true;
} }
@ -776,9 +779,10 @@ bool BackgroundPreviewBox::Start(
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now))); Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));
return false; return false;
} }
session->api().requestWallPaper(slug, [=](const Data::WallPaper &result) { controller->session().api().requestWallPaper(slug, [=](
const Data::WallPaper &result) {
Ui::show(Box<BackgroundPreviewBox>( Ui::show(Box<BackgroundPreviewBox>(
session, controller,
result.withUrlParams(params))); result.withUrlParams(params)));
}, [](const RPCError &error) { }, [](const RPCError &error) {
Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now))); Ui::show(Box<InformBox>(tr::lng_background_bad_link(tr::now)));

View file

@ -19,9 +19,9 @@ namespace Data {
class DocumentMedia; class DocumentMedia;
} // namespace Data } // namespace Data
namespace Main { namespace Window {
class Session; class SessionController;
} // namespace Main } // namespace Window
namespace Ui { namespace Ui {
class Checkbox; class Checkbox;
@ -34,11 +34,11 @@ class BackgroundPreviewBox
public: public:
BackgroundPreviewBox( BackgroundPreviewBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const Data::WallPaper &paper); const Data::WallPaper &paper);
static bool Start( static bool Start(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const QString &slug, const QString &slug,
const QMap<QString, QString> &params); const QMap<QString, QString> &params);
@ -71,7 +71,7 @@ private:
void startFadeInFrom(QPixmap previous); void startFadeInFrom(QPixmap previous);
void checkBlurAnimationStart(); void checkBlurAnimationStart();
const not_null<Main::Session*> _session; const not_null<Window::SessionController*> _controller;
AdminLog::OwnedItem _text1; AdminLog::OwnedItem _text1;
AdminLog::OwnedItem _text2; AdminLog::OwnedItem _text2;
Data::WallPaper _paper; Data::WallPaper _paper;

View file

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/unique_qptr.h" #include "base/unique_qptr.h"
#include "base/event_filter.h" #include "base/event_filter.h"
#include "base/call_delayed.h" #include "base/call_delayed.h"
#include "window/window_session_controller.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
@ -748,11 +749,11 @@ void Options::checkLastOption() {
CreatePollBox::CreatePollBox( CreatePollBox::CreatePollBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
PollData::Flags chosen, PollData::Flags chosen,
PollData::Flags disabled, PollData::Flags disabled,
Api::SendType sendType) Api::SendType sendType)
: _session(session) : _controller(controller)
, _chosen(chosen) , _chosen(chosen)
, _disabled(disabled) , _disabled(disabled)
, _sendType(sendType) { , _sendType(sendType) {
@ -774,6 +775,7 @@ not_null<Ui::InputField*> CreatePollBox::setupQuestion(
not_null<Ui::VerticalLayout*> container) { not_null<Ui::VerticalLayout*> container) {
using namespace Settings; using namespace Settings;
const auto session = &_controller->session();
AddSubsectionTitle(container, tr::lng_polls_create_question()); AddSubsectionTitle(container, tr::lng_polls_create_question());
const auto question = container->add( const auto question = container->add(
object_ptr<Ui::InputField>( object_ptr<Ui::InputField>(
@ -782,7 +784,7 @@ not_null<Ui::InputField*> CreatePollBox::setupQuestion(
Ui::InputField::Mode::MultiLine, Ui::InputField::Mode::MultiLine,
tr::lng_polls_create_question_placeholder()), tr::lng_polls_create_question_placeholder()),
st::createPollFieldPadding); st::createPollFieldPadding);
InitField(getDelegate()->outerContainer(), question, _session); InitField(getDelegate()->outerContainer(), question, session);
question->setMaxLength(kQuestionLimit + kErrorLimit); question->setMaxLength(kQuestionLimit + kErrorLimit);
question->setSubmitSettings(Ui::InputField::SubmitSettings::Both); question->setSubmitSettings(Ui::InputField::SubmitSettings::Both);
question->customTab(true); question->customTab(true);
@ -824,6 +826,7 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
)->setDuration(0)->toggleOn(std::move(shown)); )->setDuration(0)->toggleOn(std::move(shown));
const auto inner = outer->entity(); const auto inner = outer->entity();
const auto session = &_controller->session();
AddSkip(inner); AddSkip(inner);
AddSubsectionTitle(inner, tr::lng_polls_solution_title()); AddSubsectionTitle(inner, tr::lng_polls_solution_title());
const auto solution = inner->add( const auto solution = inner->add(
@ -833,14 +836,14 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
Ui::InputField::Mode::MultiLine, Ui::InputField::Mode::MultiLine,
tr::lng_polls_solution_placeholder()), tr::lng_polls_solution_placeholder()),
st::createPollFieldPadding); st::createPollFieldPadding);
InitField(getDelegate()->outerContainer(), solution, _session); InitField(getDelegate()->outerContainer(), solution, session);
solution->setMaxLength(kSolutionLimit + kErrorLimit); solution->setMaxLength(kSolutionLimit + kErrorLimit);
solution->setInstantReplaces(Ui::InstantReplaces::Default()); solution->setInstantReplaces(Ui::InstantReplaces::Default());
solution->setInstantReplacesEnabled( solution->setInstantReplacesEnabled(
_session->settings().replaceEmojiValue()); session->settings().replaceEmojiValue());
solution->setMarkdownReplacesEnabled(rpl::single(true)); solution->setMarkdownReplacesEnabled(rpl::single(true));
solution->setEditLinkCallback( solution->setEditLinkCallback(
DefaultEditLinkCallback(_session, solution)); DefaultEditLinkCallback(_controller, solution));
solution->customTab(true); solution->customTab(true);
const auto warning = CreateWarningLabel( const auto warning = CreateWarningLabel(
@ -896,7 +899,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
const auto options = lifetime().make_state<Options>( const auto options = lifetime().make_state<Options>(
getDelegate()->outerContainer(), getDelegate()->outerContainer(),
container, container,
_session, &_controller->session(),
(_chosen & PollData::Flag::Quiz)); (_chosen & PollData::Flag::Quiz));
auto limit = options->usedCount() | rpl::after_next([=](int count) { auto limit = options->usedCount() | rpl::after_next([=](int count) {
setCloseByEscape(!count); setCloseByEscape(!count);
@ -1011,7 +1014,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
const auto collectResult = [=] { const auto collectResult = [=] {
using Flag = PollData::Flag; using Flag = PollData::Flag;
auto result = PollData(&_session->data(), id); auto result = PollData(&_controller->session().data(), id);
result.question = question->getLastText().trimmed(); result.question = question->getLastText().trimmed();
result.answers = options->toPollAnswers(); result.answers = options->toPollAnswers();
const auto solutionWithTags = quiz->checked() const auto solutionWithTags = quiz->checked()

View file

@ -18,9 +18,9 @@ namespace Ui {
class VerticalLayout; class VerticalLayout;
} // namespace Ui } // namespace Ui
namespace Main { namespace Window {
class Session; class SessionController;
} // namespace Main } // namespace Window
class CreatePollBox : public Ui::BoxContent { class CreatePollBox : public Ui::BoxContent {
public: public:
@ -31,7 +31,7 @@ public:
CreatePollBox( CreatePollBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
PollData::Flags chosen, PollData::Flags chosen,
PollData::Flags disabled, PollData::Flags disabled,
Api::SendType sendType); Api::SendType sendType);
@ -62,7 +62,7 @@ private:
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
rpl::producer<bool> shown); rpl::producer<bool> shown);
const not_null<Main::Session*> _session; const not_null<Window::SessionController*> _controller;
const PollData::Flags _chosen = PollData::Flags(); const PollData::Flags _chosen = PollData::Flags();
const PollData::Flags _disabled = PollData::Flags(); const PollData::Flags _disabled = PollData::Flags();
const Api::SendType _sendType = Api::SendType(); const Api::SendType _sendType = Api::SendType();

View file

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/wrap/slide_wrap.h" #include "ui/wrap/slide_wrap.h"
#include "ui/effects/animations.h" #include "ui/effects/animations.h"
#include "window/window_session_controller.h"
namespace Ui { namespace Ui {
namespace { namespace {
@ -48,7 +49,7 @@ class Inner : public Ui::RpWidget {
public: public:
Inner( Inner(
QWidget *parent, QWidget *parent,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries); Dictionaries enabledDictionaries);
Dictionaries enabledRows() const; Dictionaries enabledRows() const;
@ -56,7 +57,7 @@ public:
private: private:
void setupContent( void setupContent(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries); Dictionaries enabledDictionaries);
Dictionaries _enabledRows; Dictionaries _enabledRows;
@ -101,10 +102,10 @@ auto CreateMultiSelect(QWidget *parent) {
Inner::Inner( Inner::Inner(
QWidget *parent, QWidget *parent,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries) Dictionaries enabledDictionaries)
: RpWidget(parent) { : RpWidget(parent) {
setupContent(session, std::move(enabledDictionaries)); setupContent(controller, std::move(enabledDictionaries));
} }
QueryCallback Inner::queryCallback() const { QueryCallback Inner::queryCallback() const {
@ -117,7 +118,7 @@ Dictionaries Inner::enabledRows() const {
auto AddButtonWithLoader( auto AddButtonWithLoader(
not_null<Ui::VerticalLayout*> content, not_null<Ui::VerticalLayout*> content,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const Spellchecker::Dict &dict, const Spellchecker::Dict &dict,
bool buttonEnabled, bool buttonEnabled,
rpl::producer<QStringView> query) { rpl::producer<QStringView> query) {
@ -295,8 +296,8 @@ auto AddButtonWithLoader(
if (toggled && (state.is<Available>() || state.is<Failed>())) { if (toggled && (state.is<Available>() || state.is<Failed>())) {
const auto weak = Ui::MakeWeak(button); const auto weak = Ui::MakeWeak(button);
setLocalLoader(base::make_unique_q<Loader>( setLocalLoader(base::make_unique_q<Loader>(
App::main(), controller->content(),
session, &controller->session(),
id, id,
Spellchecker::GetDownloadLocation(id), Spellchecker::GetDownloadLocation(id),
Spellchecker::DictPathByLangId(id), Spellchecker::DictPathByLangId(id),
@ -346,7 +347,7 @@ auto AddButtonWithLoader(
} }
void Inner::setupContent( void Inner::setupContent(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
Dictionaries enabledDictionaries) { Dictionaries enabledDictionaries) {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this); const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
@ -357,7 +358,7 @@ void Inner::setupContent(
const auto id = dict.id; const auto id = dict.id;
const auto row = AddButtonWithLoader( const auto row = AddButtonWithLoader(
content, content,
session, controller,
dict, dict,
ranges::contains(enabledDictionaries, id), ranges::contains(enabledDictionaries, id),
queryStream->events()); queryStream->events());
@ -387,8 +388,8 @@ void Inner::setupContent(
ManageDictionariesBox::ManageDictionariesBox( ManageDictionariesBox::ManageDictionariesBox(
QWidget*, QWidget*,
not_null<Main::Session*> session) not_null<Window::SessionController*> controller)
: _session(session) { : _controller(controller) {
} }
void ManageDictionariesBox::setInnerFocus() { void ManageDictionariesBox::setInnerFocus() {
@ -398,11 +399,12 @@ void ManageDictionariesBox::setInnerFocus() {
void ManageDictionariesBox::prepare() { void ManageDictionariesBox::prepare() {
const auto multiSelect = CreateMultiSelect(this); const auto multiSelect = CreateMultiSelect(this);
const auto session = &_controller->session();
const auto inner = setInnerWidget( const auto inner = setInnerWidget(
object_ptr<Inner>( object_ptr<Inner>(
this, this,
_session, _controller,
_session->settings().dictionariesEnabled()), session->settings().dictionariesEnabled()),
st::boxScroll, st::boxScroll,
multiSelect->height() multiSelect->height()
); );
@ -420,9 +422,9 @@ void ManageDictionariesBox::prepare() {
setTitle(tr::lng_settings_manage_dictionaries()); setTitle(tr::lng_settings_manage_dictionaries());
addButton(tr::lng_settings_save(), [=] { addButton(tr::lng_settings_save(), [=] {
_session->settings().setDictionariesEnabled( session->settings().setDictionariesEnabled(
FilterEnabledDict(inner->enabledRows())); FilterEnabledDict(inner->enabledRows()));
_session->saveSettingsDelayed(); session->saveSettingsDelayed();
// Ignore boxClosing() when the Save button was pressed. // Ignore boxClosing() when the Save button was pressed.
lifetime().destroy(); lifetime().destroy();
closeBox(); closeBox();
@ -430,9 +432,9 @@ void ManageDictionariesBox::prepare() {
addButton(tr::lng_close(), [=] { closeBox(); }); addButton(tr::lng_close(), [=] { closeBox(); });
boxClosing() | rpl::start_with_next([=] { boxClosing() | rpl::start_with_next([=] {
_session->settings().setDictionariesEnabled( session->settings().setDictionariesEnabled(
FilterEnabledDict(initialEnabledRows)); FilterEnabledDict(initialEnabledRows));
_session->saveSettingsDelayed(); session->saveSettingsDelayed();
}, lifetime()); }, lifetime());
setDimensionsToContent(st::boxWidth, inner); setDimensionsToContent(st::boxWidth, inner);

View file

@ -11,9 +11,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
namespace Main { namespace Window {
class Session; class SessionController;
} // namespace Main } // namespace Window
namespace Ui { namespace Ui {
@ -21,14 +21,14 @@ class ManageDictionariesBox : public Ui::BoxContent {
public: public:
ManageDictionariesBox( ManageDictionariesBox(
QWidget*, QWidget*,
not_null<Main::Session*> session); not_null<Window::SessionController*> controller);
protected: protected:
void prepare() override; void prepare() override;
void setInnerFocus() override; void setInnerFocus() override;
private: private:
const not_null<Main::Session*> _session; const not_null<Window::SessionController*> _controller;
Fn<void()> _setInnerFocus; Fn<void()> _setInnerFocus;
}; };

View file

@ -309,9 +309,9 @@ EditCaptionBox::EditCaptionBox(
_controller->session().settings().replaceEmojiValue()); _controller->session().settings().replaceEmojiValue());
_field->setMarkdownReplacesEnabled(rpl::single(true)); _field->setMarkdownReplacesEnabled(rpl::single(true));
_field->setEditLinkCallback( _field->setEditLinkCallback(
DefaultEditLinkCallback(&_controller->session(), _field)); DefaultEditLinkCallback(_controller, _field));
InitSpellchecker(&_controller->session(), _field); InitSpellchecker(_controller, _field);
auto r = object_ptr<Ui::SlideWrap<Ui::Checkbox>>( auto r = object_ptr<Ui::SlideWrap<Ui::Checkbox>>(
this, this,

View file

@ -1440,15 +1440,22 @@ void Controller::deleteChannel() {
const auto channel = _peer->asChannel(); const auto channel = _peer->asChannel();
const auto chat = channel->migrateFrom(); const auto chat = channel->migrateFrom();
const auto session = &_peer->session();
Ui::hideLayer(); Ui::hideLayer();
Ui::showChatsList(); Ui::showChatsList();
if (chat) { if (chat) {
chat->session().api().deleteConversation(chat, false); session->api().deleteConversation(chat, false);
} }
MTP::send( session->api().request(MTPchannels_DeleteChannel(
MTPchannels_DeleteChannel(channel->inputChannel), channel->inputChannel
App::main()->rpcDone(&MainWidget::sentUpdatesReceived), )).done([=](const MTPUpdates &result) {
App::main()->rpcFail(&MainWidget::deleteChannelFailed)); session->api().applyUpdates(result);
//}).fail([=](const RPCError &error) {
// if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
// Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now)));
// }
}).send();
} }
} // namespace } // namespace

View file

@ -2069,13 +2069,13 @@ void SendFilesBox::setupCaption() {
_controller->session().settings().replaceEmojiValue()); _controller->session().settings().replaceEmojiValue());
_caption->setMarkdownReplacesEnabled(rpl::single(true)); _caption->setMarkdownReplacesEnabled(rpl::single(true));
_caption->setEditLinkCallback( _caption->setEditLinkCallback(
DefaultEditLinkCallback(&_controller->session(), _caption)); DefaultEditLinkCallback(_controller, _caption));
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(), getDelegate()->outerContainer(),
_caption, _caption,
&_controller->session()); &_controller->session());
InitSpellchecker(&_controller->session(), _caption); InitSpellchecker(_controller, _caption);
updateCaptionPlaceholder(); updateCaptionPlaceholder();
setupEmojiPanel(); setupEmojiPanel();

View file

@ -205,10 +205,10 @@ void ShareBox::prepareCommentField() {
_navigation->session().settings().replaceEmojiValue()); _navigation->session().settings().replaceEmojiValue());
field->setMarkdownReplacesEnabled(rpl::single(true)); field->setMarkdownReplacesEnabled(rpl::single(true));
field->setEditLinkCallback( field->setEditLinkCallback(
DefaultEditLinkCallback(&_navigation->session(), field)); DefaultEditLinkCallback(_navigation->parentController(), field));
field->setSubmitSettings(_navigation->session().settings().sendSubmitWay()); field->setSubmitSettings(_navigation->session().settings().sendSubmitWay());
InitSpellchecker(&_navigation->session(), field); InitSpellchecker(_navigation->parentController(), field);
Ui::SendPendingMoveResizeEvents(_comment); Ui::SendPendingMoveResizeEvents(_comment);
} }

View file

@ -62,7 +62,7 @@ class EditLinkBox : public Ui::BoxContent {
public: public:
EditLinkBox( EditLinkBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const QString &text, const QString &text,
const QString &link, const QString &link,
Fn<void(QString, QString)> callback); Fn<void(QString, QString)> callback);
@ -73,7 +73,7 @@ protected:
void prepare() override; void prepare() override;
private: private:
const not_null<Main::Session*> _session; const not_null<Window::SessionController*> _controller;
QString _startText; QString _startText;
QString _startLink; QString _startLink;
Fn<void(QString, QString)> _callback; Fn<void(QString, QString)> _callback;
@ -111,11 +111,11 @@ QString FieldTagMimeProcessor::tagFromMimeTag(const QString &mimeTag) {
EditLinkBox::EditLinkBox( EditLinkBox::EditLinkBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const QString &text, const QString &text,
const QString &link, const QString &link,
Fn<void(QString, QString)> callback) Fn<void(QString, QString)> callback)
: _session(session) : _controller(controller)
, _startText(text) , _startText(text)
, _startLink(link) , _startLink(link)
, _callback(std::move(callback)) { , _callback(std::move(callback)) {
@ -131,6 +131,7 @@ void EditLinkBox::setInnerFocus() {
void EditLinkBox::prepare() { void EditLinkBox::prepare() {
const auto content = Ui::CreateChild<Ui::VerticalLayout>(this); const auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
const auto session = &_controller->session();
const auto text = content->add( const auto text = content->add(
object_ptr<Ui::InputField>( object_ptr<Ui::InputField>(
content, content,
@ -140,12 +141,12 @@ void EditLinkBox::prepare() {
st::markdownLinkFieldPadding); st::markdownLinkFieldPadding);
text->setInstantReplaces(Ui::InstantReplaces::Default()); text->setInstantReplaces(Ui::InstantReplaces::Default());
text->setInstantReplacesEnabled( text->setInstantReplacesEnabled(
_session->settings().replaceEmojiValue()); session->settings().replaceEmojiValue());
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(), getDelegate()->outerContainer(),
text, text,
_session); session);
InitSpellchecker(_session, text); InitSpellchecker(_controller, text);
const auto url = content->add( const auto url = content->add(
object_ptr<Ui::InputField>( object_ptr<Ui::InputField>(
@ -249,7 +250,7 @@ Fn<bool(
QString text, QString text,
QString link, QString link,
EditLinkAction action)> DefaultEditLinkCallback( EditLinkAction action)> DefaultEditLinkCallback(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field) { not_null<Ui::InputField*> field) {
const auto weak = Ui::MakeWeak(field); const auto weak = Ui::MakeWeak(field);
return [=]( return [=](
@ -261,7 +262,7 @@ Fn<bool(
return Ui::InputField::IsValidMarkdownLink(link) return Ui::InputField::IsValidMarkdownLink(link)
&& !TextUtilities::IsMentionLink(link); && !TextUtilities::IsMentionLink(link);
} }
Ui::show(Box<EditLinkBox>(session, text, link, [=]( Ui::show(Box<EditLinkBox>(controller, text, link, [=](
const QString &text, const QString &text,
const QString &link) { const QString &link) {
if (const auto strong = weak.data()) { if (const auto strong = weak.data()) {
@ -289,20 +290,19 @@ void InitMessageField(
field->setInstantReplacesEnabled( field->setInstantReplacesEnabled(
controller->session().settings().replaceEmojiValue()); controller->session().settings().replaceEmojiValue());
field->setMarkdownReplacesEnabled(rpl::single(true)); field->setMarkdownReplacesEnabled(rpl::single(true));
field->setEditLinkCallback( field->setEditLinkCallback(DefaultEditLinkCallback(controller, field));
DefaultEditLinkCallback(&controller->session(), field));
} }
void InitSpellchecker( void InitSpellchecker(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field) { not_null<Ui::InputField*> field) {
#ifndef TDESKTOP_DISABLE_SPELLCHECK #ifndef TDESKTOP_DISABLE_SPELLCHECK
const auto s = Ui::CreateChild<Spellchecker::SpellingHighlighter>( const auto s = Ui::CreateChild<Spellchecker::SpellingHighlighter>(
field.get(), field.get(),
session->settings().spellcheckerEnabledValue(), controller->session().settings().spellcheckerEnabledValue(),
Spellchecker::SpellingHighlighter::CustomContextMenuItem{ Spellchecker::SpellingHighlighter::CustomContextMenuItem{
tr::lng_settings_manage_dictionaries(tr::now), tr::lng_settings_manage_dictionaries(tr::now),
[=] { Ui::show(Box<Ui::ManageDictionariesBox>(session)); } [=] { Ui::show(Box<Ui::ManageDictionariesBox>(controller)); }
}); });
field->setExtendedContextMenu(s->contextMenuCreated()); field->setExtendedContextMenu(s->contextMenuCreated());
#endif // TDESKTOP_DISABLE_SPELLCHECK #endif // TDESKTOP_DISABLE_SPELLCHECK

View file

@ -34,14 +34,14 @@ Fn<bool(
QString text, QString text,
QString link, QString link,
Ui::InputField::EditLinkAction action)> DefaultEditLinkCallback( Ui::InputField::EditLinkAction action)> DefaultEditLinkCallback(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field); not_null<Ui::InputField*> field);
void InitMessageField( void InitMessageField(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field); not_null<Ui::InputField*> field);
void InitSpellchecker( void InitSpellchecker(
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field); not_null<Ui::InputField*> field);
bool HasSendText(not_null<const Ui::InputField*> field); bool HasSendText(not_null<const Ui::InputField*> field);

View file

@ -241,7 +241,7 @@ bool ShowWallPaper(
match->captured(1), match->captured(1),
qthelp::UrlParamNameTransform::ToLower); qthelp::UrlParamNameTransform::ToLower);
return BackgroundPreviewBox::Start( return BackgroundPreviewBox::Start(
session, App::wnd()->sessionController(),
params.value(qsl("slug")), params.value(qsl("slug")),
params); params);
} }

View file

@ -94,6 +94,7 @@ void CheckForSwitchInlineButton(not_null<HistoryItem*> item) {
using ButtonType = HistoryMessageMarkupButton::Type; using ButtonType = HistoryMessageMarkupButton::Type;
if (button.type == ButtonType::SwitchInline) { if (button.type == ButtonType::SwitchInline) {
Notify::switchInlineBotButtonReceived( Notify::switchInlineBotButtonReceived(
&item->history()->session(),
QString::fromUtf8(button.data)); QString::fromUtf8(button.data));
return; return;
} }
@ -889,6 +890,25 @@ void Session::chatsListDone(Data::Folder *folder) {
_chatsListLoadedEvents.fire_copy(folder); _chatsListLoadedEvents.fire_copy(folder);
} }
void Session::userIsBotChanged(not_null<UserData*> user) {
if (const auto history = this->history(user)) {
chatsFilters().refreshHistory(history);
}
_userIsBotChanges.fire_copy(user);
}
rpl::producer<not_null<UserData*>> Session::userIsBotChanges() const {
return _userIsBotChanges.events();
}
void Session::botCommandsChanged(not_null<UserData*> user) {
_botCommandsChanges.fire_copy(user);
}
rpl::producer<not_null<UserData*>> Session::botCommandsChanges() const {
return _botCommandsChanges.events();
}
Storage::Cache::Database &Session::cache() { Storage::Cache::Database &Session::cache() {
return *_cache; return *_cache;
} }

View file

@ -200,6 +200,11 @@ public:
void chatsListChanged(Data::Folder *folder); void chatsListChanged(Data::Folder *folder);
void chatsListDone(Data::Folder *folder); void chatsListDone(Data::Folder *folder);
void userIsBotChanged(not_null<UserData*> user);
[[nodiscard]] rpl::producer<not_null<UserData*>> userIsBotChanges() const;
void botCommandsChanged(not_null<UserData*> user);
[[nodiscard]] rpl::producer<not_null<UserData*>> botCommandsChanges() const;
struct ItemVisibilityQuery { struct ItemVisibilityQuery {
not_null<HistoryItem*> item; not_null<HistoryItem*> item;
not_null<bool*> isVisible; not_null<bool*> isVisible;
@ -771,6 +776,8 @@ private:
rpl::variable<bool> _contactsLoaded = false; rpl::variable<bool> _contactsLoaded = false;
rpl::event_stream<Data::Folder*> _chatsListLoadedEvents; rpl::event_stream<Data::Folder*> _chatsListLoadedEvents;
rpl::event_stream<Data::Folder*> _chatsListChanged; rpl::event_stream<Data::Folder*> _chatsListChanged;
rpl::event_stream<not_null<UserData*>> _userIsBotChanges;
rpl::event_stream<not_null<UserData*>> _botCommandsChanges;
base::Observable<ItemVisibilityQuery> _queryItemVisibility; base::Observable<ItemVisibilityQuery> _queryItemVisibility;
rpl::event_stream<IdChange> _itemIdChanges; rpl::event_stream<IdChange> _itemIdChanges;
rpl::event_stream<not_null<const HistoryItem*>> _itemLayoutChanges; rpl::event_stream<not_null<const HistoryItem*>> _itemLayoutChanges;

View file

@ -131,22 +131,15 @@ void UserData::setPhone(const QString &newPhone) {
void UserData::setBotInfoVersion(int version) { void UserData::setBotInfoVersion(int version) {
if (version < 0) { if (version < 0) {
if (botInfo) { // We don't support bots becoming non-bots.
if (!botInfo->commands.isEmpty()) {
botInfo->commands.clear();
Notify::botCommandsChanged(this);
}
botInfo = nullptr;
Notify::userIsBotChanged(this);
}
} else if (!botInfo) { } else if (!botInfo) {
botInfo = std::make_unique<BotInfo>(); botInfo = std::make_unique<BotInfo>();
botInfo->version = version; botInfo->version = version;
Notify::userIsBotChanged(this); owner().userIsBotChanged(this);
} else if (botInfo->version < version) { } else if (botInfo->version < version) {
if (!botInfo->commands.isEmpty()) { if (!botInfo->commands.isEmpty()) {
botInfo->commands.clear(); botInfo->commands.clear();
Notify::botCommandsChanged(this); owner().botCommandsChanged(this);
} }
botInfo->description.clear(); botInfo->description.clear();
botInfo->version = version; botInfo->version = version;
@ -199,7 +192,7 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
botInfo->inited = true; botInfo->inited = true;
if (changedCommands) { if (changedCommands) {
Notify::botCommandsChanged(this); owner().botCommandsChanged(this);
} }
} break; } break;
} }

View file

@ -239,7 +239,7 @@ InnerWidget::InnerWidget(
} }
if (update.flags & (UpdateFlag::PhotoChanged | UpdateFlag::UserOccupiedChanged)) { if (update.flags & (UpdateFlag::PhotoChanged | UpdateFlag::UserOccupiedChanged)) {
this->update(); this->update();
emit App::main()->dialogsUpdated(); emit controller->content()->dialogsUpdated();
} }
if (update.flags & UpdateFlag::UserIsContact) { if (update.flags & UpdateFlag::UserIsContact) {
if (update.peer->isUser()) { if (update.peer->isUser()) {
@ -1498,7 +1498,7 @@ void InnerWidget::removeDialog(Key key) {
refresh(); refresh();
} }
emit App::main()->dialogsUpdated(); emit _controller->content()->dialogsUpdated();
refresh(); refresh();
} }
@ -3019,7 +3019,7 @@ void InnerWidget::setupShortcuts() {
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) { }) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
using Command = Shortcuts::Command; using Command = Shortcuts::Command;
if (App::main()->selectingPeer()) { if (_controller->content()->selectingPeer()) {
return; return;
} }
const auto row = _controller->activeChatEntryCurrent(); const auto row = _controller->activeChatEntryCurrent();
@ -3059,7 +3059,9 @@ void InnerWidget::setupShortcuts() {
return jumpToDialogRow(last); return jumpToDialogRow(last);
}); });
request->check(Command::ChatSelf) && request->handle([=] { request->check(Command::ChatSelf) && request->handle([=] {
App::main()->choosePeer(session().userPeerId(), ShowAtUnreadMsgId); _controller->content()->choosePeer(
session().userPeerId(),
ShowAtUnreadMsgId);
return true; return true;
}); });
request->check(Command::ShowArchive) && request->handle([=] { request->check(Command::ShowArchive) && request->handle([=] {

View file

@ -199,10 +199,10 @@ Widget::Widget(
}); });
_inner->chosenRow( _inner->chosenRow(
) | rpl::start_with_next([=](const ChosenRow &row) { ) | rpl::start_with_next([=](const ChosenRow &row) {
const auto openSearchResult = !App::main()->selectingPeer() const auto openSearchResult = !controller->content()->selectingPeer()
&& row.filteredRow; && row.filteredRow;
if (const auto history = row.key.history()) { if (const auto history = row.key.history()) {
App::main()->choosePeer( controller->content()->choosePeer(
history->peer->id, history->peer->id,
(controller->uniqueChatsInSearchResults() (controller->uniqueChatsInSearchResults()
? ShowAtUnreadMsgId ? ShowAtUnreadMsgId
@ -642,7 +642,7 @@ void Widget::showAnimated(Window::SlideDirection direction, const Window::Sectio
_cacheUnder = params.oldContentCache; _cacheUnder = params.oldContentCache;
showFast(); showFast();
_cacheOver = App::main()->grabForShowAnimation(params); _cacheOver = controller()->content()->grabForShowAnimation(params);
if (_updateTelegram) { if (_updateTelegram) {
_updateTelegram->hide(); _updateTelegram->hide();
@ -698,7 +698,7 @@ void Widget::escape() {
} else if (controller()->activeChatsFilterCurrent()) { } else if (controller()->activeChatsFilterCurrent()) {
controller()->setActiveChatsFilter(FilterId(0)); controller()->setActiveChatsFilter(FilterId(0));
} }
} else if (!_searchInChat && !App::main()->selectingPeer()) { } else if (!_searchInChat && !controller()->content()->selectingPeer()) {
if (controller()->activeChatEntryCurrent().key) { if (controller()->activeChatEntryCurrent().key) {
emit cancelled(); emit cancelled();
} }
@ -1243,7 +1243,9 @@ bool Widget::peopleFailed(const RPCError &error, mtpRequestId req) {
void Widget::dragEnterEvent(QDragEnterEvent *e) { void Widget::dragEnterEvent(QDragEnterEvent *e) {
using namespace Storage; using namespace Storage;
if (App::main()->selectingPeer()) return; if (controller()->content()->selectingPeer()) {
return;
}
const auto data = e->mimeData(); const auto data = e->mimeData();
_dragInScroll = false; _dragInScroll = false;
@ -1295,9 +1297,9 @@ void Widget::updateDragInScroll(bool inScroll) {
if (_dragInScroll != inScroll) { if (_dragInScroll != inScroll) {
_dragInScroll = inScroll; _dragInScroll = inScroll;
if (_dragInScroll) { if (_dragInScroll) {
App::main()->showForwardLayer({}); controller()->content()->showForwardLayer({});
} else { } else {
App::main()->dialogsCancelled(); controller()->content()->dialogsCancelled();
} }
} }
} }
@ -1307,7 +1309,9 @@ void Widget::dropEvent(QDropEvent *e) {
if (_scroll->geometry().contains(e->pos())) { if (_scroll->geometry().contains(e->pos())) {
if (auto peer = _inner->updateFromParentDrag(mapToGlobal(e->pos()))) { if (auto peer = _inner->updateFromParentDrag(mapToGlobal(e->pos()))) {
e->acceptProposedAction(); e->acceptProposedAction();
App::main()->onFilesOrForwardDrop(peer->id, e->mimeData()); controller()->content()->onFilesOrForwardDrop(
peer->id,
e->mimeData());
controller()->widget()->activateWindow(); controller()->widget()->activateWindow();
} }
} }
@ -1556,7 +1560,7 @@ void Widget::updateControlsGeometry() {
right -= _chooseFromUser->width(); _chooseFromUser->moveToLeft(right, _filter->y()); right -= _chooseFromUser->width(); _chooseFromUser->moveToLeft(right, _filter->y());
auto scrollTop = filterAreaTop + filterAreaHeight; auto scrollTop = filterAreaTop + filterAreaHeight;
auto addToScroll = App::main() ? App::main()->contentScrollAddToY() : 0; auto addToScroll = controller()->content()->contentScrollAddToY();
auto newScrollTop = _scroll->scrollTop() + addToScroll; auto newScrollTop = _scroll->scrollTop() + addToScroll;
auto scrollHeight = height() - scrollTop; auto scrollHeight = height() - scrollTop;
const auto putBottomButton = [&](object_ptr<BottomButton> &button) { const auto putBottomButton = [&](object_ptr<BottomButton> &button) {
@ -1589,14 +1593,16 @@ void Widget::updateControlsGeometry() {
} }
void Widget::updateForwardBar() { void Widget::updateForwardBar() {
auto selecting = App::main()->selectingPeer(); auto selecting = controller()->content()->selectingPeer();
auto oneColumnSelecting = (Adaptive::OneColumn() && selecting); auto oneColumnSelecting = (Adaptive::OneColumn() && selecting);
if (!oneColumnSelecting == !_forwardCancel) { if (!oneColumnSelecting == !_forwardCancel) {
return; return;
} }
if (oneColumnSelecting) { if (oneColumnSelecting) {
_forwardCancel.create(this, st::dialogsForwardCancel); _forwardCancel.create(this, st::dialogsForwardCancel);
_forwardCancel->setClickedCallback([] { Global::RefPeerChooseCancel().notify(true); }); _forwardCancel->setClickedCallback([] {
Global::RefPeerChooseCancel().notify(true);
});
if (!_a_show.animating()) _forwardCancel->show(); if (!_a_show.animating()) _forwardCancel->show();
} else { } else {
_forwardCancel.destroyDelayed(); _forwardCancel.destroyDelayed();
@ -1737,7 +1743,7 @@ bool Widget::onCancelSearch() {
void Widget::onCancelSearchInChat() { void Widget::onCancelSearchInChat() {
cancelSearchRequest(); cancelSearchRequest();
if (_searchInChat) { if (_searchInChat) {
if (Adaptive::OneColumn() && !App::main()->selectingPeer()) { if (Adaptive::OneColumn() && !controller()->content()->selectingPeer()) {
if (const auto peer = _searchInChat.peer()) { if (const auto peer = _searchInChat.peer()) {
Ui::showPeerHistory(peer, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
//} else if (const auto feed = _searchInChat.feed()) { // #feed //} else if (const auto feed = _searchInChat.feed()) { // #feed
@ -1752,7 +1758,7 @@ void Widget::onCancelSearchInChat() {
_filter->clear(); _filter->clear();
_filter->updatePlaceholder(); _filter->updatePlaceholder();
applyFilterUpdate(); applyFilterUpdate();
if (!Adaptive::OneColumn() && !App::main()->selectingPeer()) { if (!Adaptive::OneColumn() && !controller()->content()->selectingPeer()) {
emit cancelled(); emit cancelled();
} }
} }

View file

@ -35,20 +35,27 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace App { namespace App {
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) { void sendBotCommand(
if (auto m = App::main()) { not_null<PeerData*> peer,
m->sendBotCommand(peer, bot, cmd, replyTo); UserData *bot,
const QString &cmd, MsgId replyTo) {
if (const auto m = App::main()) { // multi good
if (&m->session() == &peer->session()) {
m->sendBotCommand(peer, bot, cmd, replyTo);
}
} }
} }
void hideSingleUseKeyboard(const HistoryItem *msg) { void hideSingleUseKeyboard(not_null<const HistoryItem*> message) {
if (auto m = App::main()) { if (const auto m = App::main()) { // multi good
m->hideSingleUseKeyboard(msg->history()->peer, msg->id); if (&m->session() == &message->history()->session()) {
m->hideSingleUseKeyboard(message->history()->peer, message->id);
}
} }
} }
bool insertBotCommand(const QString &cmd) { bool insertBotCommand(const QString &cmd) {
if (auto m = App::main()) { if (const auto m = App::main()) { // multi good
return m->insertBotCommand(cmd); return m->insertBotCommand(cmd);
} }
return false; return false;
@ -82,8 +89,10 @@ void activateBotCommand(
case ButtonType::Callback: case ButtonType::Callback:
case ButtonType::Game: { case ButtonType::Game: {
if (auto m = App::main()) { if (const auto m = App::main()) { // multi good
m->app_sendBotCallback(button, msg, row, column); if (&m->session() == &msg->history()->session()) {
m->app_sendBotCallback(button, msg, row, column);
}
} }
} break; } break;
@ -94,7 +103,7 @@ void activateBotCommand(
case ButtonType::Url: { case ButtonType::Url: {
auto url = QString::fromUtf8(button->data); auto url = QString::fromUtf8(button->data);
auto skipConfirmation = false; auto skipConfirmation = false;
if (auto bot = msg->getMessageBot()) { if (const auto bot = msg->getMessageBot()) {
if (bot->isVerified()) { if (bot->isVerified()) {
skipConfirmation = true; skipConfirmation = true;
} }
@ -137,27 +146,34 @@ void activateBotCommand(
chosen |= PollData::Flag::Quiz; chosen |= PollData::Flag::Quiz;
} }
} }
Window::PeerMenuCreatePoll(msg->history()->peer, chosen, disabled); if (const auto m = App::main()) { // multi good
if (&m->session() == &msg->history()->session()) {
Window::PeerMenuCreatePoll(m->controller(), msg->history()->peer, chosen, disabled);
}
}
} break; } break;
case ButtonType::SwitchInlineSame: case ButtonType::SwitchInlineSame:
case ButtonType::SwitchInline: { case ButtonType::SwitchInline: {
if (auto m = App::main()) { const auto session = &msg->history()->session();
if (auto bot = msg->getMessageBot()) { if (const auto m = App::main()) { // multi good
auto tryFastSwitch = [bot, &button, msgId = msg->id]() -> bool { if (&m->session() == session) {
auto samePeer = (button->type == ButtonType::SwitchInlineSame); if (const auto bot = msg->getMessageBot()) {
if (samePeer) { const auto fastSwitchDone = [&] {
Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data), bot, msgId); auto samePeer = (button->type == ButtonType::SwitchInlineSame);
return true; if (samePeer) {
} else if (bot->isBot() && bot->botInfo->inlineReturnPeerId) { Notify::switchInlineBotButtonReceived(session, QString::fromUtf8(button->data), bot, msg->id);
if (Notify::switchInlineBotButtonReceived(QString::fromUtf8(button->data))) {
return true; return true;
} else if (bot->isBot() && bot->botInfo->inlineReturnPeerId) {
if (Notify::switchInlineBotButtonReceived(session, QString::fromUtf8(button->data))) {
return true;
}
} }
return false;
}();
if (!fastSwitchDone) {
m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data));
} }
return false;
};
if (!tryFastSwitch()) {
m->inlineSwitchLayer('@' + bot->username + ' ' + QString::fromUtf8(button->data));
} }
} }
} }
@ -170,20 +186,18 @@ void activateBotCommand(
} }
void searchByHashtag(const QString &tag, PeerData *inPeer) { void searchByHashtag(const QString &tag, PeerData *inPeer) {
if (const auto window = App::wnd()) { if (const auto m = App::main()) { // multi good
if (const auto controller = window->sessionController()) { if (!inPeer || &m->session() == &inPeer->session()) {
if (controller->openedFolder().current()) { if (m->controller()->openedFolder().current()) {
controller->closeFolder(); m->controller()->closeFolder();
} }
} Ui::hideSettingsAndLayer();
Ui::hideSettingsAndLayer(); Core::App().hideMediaView();
Core::App().hideMediaView();
if (const auto m = window->mainWidget()) {
m->searchMessages( m->searchMessages(
tag + ' ', tag + ' ',
(inPeer && !inPeer->isUser()) (inPeer && !inPeer->isUser())
? inPeer->owner().history(inPeer).get() ? inPeer->owner().history(inPeer).get()
: Dialogs::Key()); : Dialogs::Key());
} }
} }
} }
@ -216,8 +230,7 @@ void showPeerProfile(not_null<const History*> history) {
void showPeerHistory( void showPeerHistory(
const PeerId &peer, const PeerId &peer,
MsgId msgId) { MsgId msgId) {
auto ms = crl::now(); if (const auto m = App::main()) { // multi good
if (auto m = App::main()) {
m->ui_showPeerHistory( m->ui_showPeerHistory(
peer, peer,
Window::SectionShow::Way::ClearStack, Window::SectionShow::Way::ClearStack,
@ -226,15 +239,22 @@ void showPeerHistory(
} }
void showPeerHistoryAtItem(not_null<const HistoryItem*> item) { void showPeerHistoryAtItem(not_null<const HistoryItem*> item) {
showPeerHistory(item->history()->peer->id, item->id); showPeerHistory(item->history()->peer, item->id);
} }
void showPeerHistory(not_null<const History*> history, MsgId msgId) { void showPeerHistory(not_null<const History*> history, MsgId msgId) {
showPeerHistory(history->peer->id, msgId); showPeerHistory(history->peer, msgId);
} }
void showPeerHistory(const PeerData *peer, MsgId msgId) { void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId) {
showPeerHistory(peer->id, msgId); if (const auto m = App::main()) { // multi good
if (&m->session() == &peer->session()) {
m->ui_showPeerHistory(
peer->id,
Window::SectionShow::Way::ClearStack,
msgId);
}
}
} }
PeerData *getPeerForMouseAction() { PeerData *getPeerForMouseAction() {
@ -254,36 +274,40 @@ bool skipPaintEvent(QWidget *widget, QPaintEvent *event) {
namespace Notify { namespace Notify {
void userIsBotChanged(UserData *user) { void replyMarkupUpdated(not_null<const HistoryItem*> item) {
if (MainWidget *m = App::main()) m->notify_userIsBotChanged(user); if (const auto m = App::main()) { // multi good
} if (&m->session() == &item->history()->session()) {
m->notify_replyMarkupUpdated(item);
void botCommandsChanged(UserData *user) { }
if (MainWidget *m = App::main()) {
m->notify_botCommandsChanged(user);
}
peerUpdatedDelayed(user, PeerUpdate::Flag::BotCommandsChanged);
}
void inlineBotRequesting(bool requesting) {
if (MainWidget *m = App::main()) m->notify_inlineBotRequesting(requesting);
}
void replyMarkupUpdated(const HistoryItem *item) {
if (MainWidget *m = App::main()) {
m->notify_replyMarkupUpdated(item);
} }
} }
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) { void inlineKeyboardMoved(
if (MainWidget *m = App::main()) { not_null<const HistoryItem*> item,
m->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop); int oldKeyboardTop,
int newKeyboardTop) {
if (const auto m = App::main()) { // multi good
if (&m->session() == &item->history()->session()) {
m->notify_inlineKeyboardMoved(
item,
oldKeyboardTop,
newKeyboardTop);
}
} }
} }
bool switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) { bool switchInlineBotButtonReceived(
if (auto main = App::main()) { not_null<Main::Session*> session,
return main->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo); const QString &query,
UserData *samePeerBot,
MsgId samePeerReplyTo) {
if (const auto m = App::main()) { // multi good
if (session == &m->session()) {
return m->notify_switchInlineBotButtonReceived(
query,
samePeerBot,
samePeerReplyTo);
}
} }
return false; return false;
} }

View file

@ -38,7 +38,7 @@ template <typename Guard, typename Lambda>
} }
void sendBotCommand( void sendBotCommand(
PeerData *peer, not_null<PeerData*> peer,
UserData *bot, UserData *bot,
const QString &cmd, const QString &cmd,
MsgId replyTo = 0); MsgId replyTo = 0);
@ -63,7 +63,7 @@ void showPeerProfile(not_null<const History*> history);
void showPeerHistory(const PeerId &peer, MsgId msgId); void showPeerHistory(const PeerId &peer, MsgId msgId);
void showPeerHistoryAtItem(not_null<const HistoryItem*> item); void showPeerHistoryAtItem(not_null<const HistoryItem*> item);
void showPeerHistory(const PeerData *peer, MsgId msgId); void showPeerHistory(not_null<const PeerData*> peer, MsgId msgId);
void showPeerHistory(not_null<const History*> history, MsgId msgId); void showPeerHistory(not_null<const History*> history, MsgId msgId);
inline void showChatsList() { inline void showChatsList() {
showPeerHistory(PeerId(0), 0); showPeerHistory(PeerId(0), 0);
@ -81,13 +81,16 @@ enum ClipStopperType {
namespace Notify { namespace Notify {
void userIsBotChanged(UserData *user); void replyMarkupUpdated(not_null<const HistoryItem*> item);
void botCommandsChanged(UserData *user); void inlineKeyboardMoved(
not_null<const HistoryItem*> item,
void inlineBotRequesting(bool requesting); int oldKeyboardTop,
void replyMarkupUpdated(const HistoryItem *item); int newKeyboardTop);
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop); bool switchInlineBotButtonReceived(
bool switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot = nullptr, MsgId samePeerReplyTo = 0); not_null<Main::Session*> session,
const QString &query,
UserData *samePeerBot = nullptr,
MsgId samePeerReplyTo = 0);
void unreadCounterUpdated(); void unreadCounterUpdated();

View file

@ -432,7 +432,7 @@ void Widget::paintEvent(QPaintEvent *e) {
//auto ms = crl::now(); //auto ms = crl::now();
//_historyDownShown.step(ms); //_historyDownShown.step(ms);
SectionWidget::PaintBackground(this, e->rect()); SectionWidget::PaintBackground(controller(), this, e->rect());
} }
void Widget::onScroll() { void Widget::onScroll() {

View file

@ -633,7 +633,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
view->draw(p, clip.translated(0, -y), selection, ms); view->draw(p, clip.translated(0, -y), selection, ms);
if (item->hasViews()) { if (item->hasViews()) {
App::main()->scheduleViewIncrement(item); _controller->content()->scheduleViewIncrement(item);
} }
if (item->isUnreadMention() && !item->isUnreadMedia()) { if (item->isUnreadMention() && !item->isUnreadMedia()) {
readMentions.insert(item); readMentions.insert(item);
@ -689,7 +689,7 @@ void HistoryInner::paintEvent(QPaintEvent *e) {
if (_visibleAreaBottom >= middle if (_visibleAreaBottom >= middle
&& _visibleAreaTop <= middle) { && _visibleAreaTop <= middle) {
if (item->hasViews()) { if (item->hasViews()) {
App::main()->scheduleViewIncrement(item); _controller->content()->scheduleViewIncrement(item);
} }
if (item->isUnreadMention() && !item->isUnreadMedia()) { if (item->isUnreadMention() && !item->isUnreadMedia()) {
readMentions.insert(item); readMentions.insert(item);
@ -1279,9 +1279,6 @@ void HistoryInner::itemRemoved(not_null<const HistoryItem*> item) {
if (_history != item->history() && _migrated != item->history()) { if (_history != item->history() && _migrated != item->history()) {
return; return;
} }
if (!App::main()) {
return;
}
_animatedStickersPlayed.remove(item); _animatedStickersPlayed.remove(item);
@ -2495,6 +2492,18 @@ void HistoryInner::elementStartStickerLoop(
_animatedStickersPlayed.emplace(view->data()); _animatedStickersPlayed.emplace(view->data());
} }
crl::time HistoryInner::elementHighlightTime(not_null<const Element*> view) {
const auto fullAnimMs = _controller->content()->highlightStartTime(
view->data());
if (fullAnimMs > 0) {
const auto now = crl::now();
if (fullAnimMs < now) {
return now - fullAnimMs;
}
}
return 0;
}
void HistoryInner::elementShowPollResults( void HistoryInner::elementShowPollResults(
not_null<PollData*> poll, not_null<PollData*> poll,
FullMsgId context) { FullMsgId context) {
@ -3117,7 +3126,7 @@ void HistoryInner::deleteItem(FullMsgId itemId) {
void HistoryInner::deleteItem(not_null<HistoryItem*> item) { void HistoryInner::deleteItem(not_null<HistoryItem*> item) {
if (auto message = item->toHistoryMessage()) { if (auto message = item->toHistoryMessage()) {
if (message->uploading()) { if (message->uploading()) {
App::main()->cancelUploadLayer(item); _controller->content()->cancelUploadLayer(item);
return; return;
} }
} }
@ -3331,20 +3340,12 @@ not_null<HistoryView::ElementDelegate*> HistoryInner::ElementDelegate() {
replacing); replacing);
} }
bool elementUnderCursor( bool elementUnderCursor(
not_null<const HistoryView::Element*> view) override { not_null<const Element*> view) override {
return (App::hoveredItem() == view); return (App::hoveredItem() == view);
} }
crl::time elementHighlightTime( crl::time elementHighlightTime(
not_null<const HistoryView::Element*> view) override { not_null<const Element*> view) override {
const auto fullAnimMs = App::main()->highlightStartTime( return Instance ? Instance->elementHighlightTime(view) : 0;
view->data());
if (fullAnimMs > 0) {
const auto now = crl::now();
if (fullAnimMs < now) {
return now - fullAnimMs;
}
}
return crl::time(0);
} }
bool elementInSelectionMode() override { bool elementInSelectionMode() override {
return Instance ? Instance->inSelectionMode() : false; return Instance ? Instance->inSelectionMode() : false;

View file

@ -83,6 +83,8 @@ public:
int from, int from,
int till) const; int till) const;
void elementStartStickerLoop(not_null<const Element*> view); void elementStartStickerLoop(not_null<const Element*> view);
[[nodiscard]] crl::time elementHighlightTime(
not_null<const Element*> view);
void elementShowPollResults( void elementShowPollResults(
not_null<PollData*> poll, not_null<PollData*> poll,
FullMsgId context); FullMsgId context);

View file

@ -134,14 +134,6 @@ constexpr auto kCommonModifiers = 0
| Qt::ControlModifier; | Qt::ControlModifier;
const auto kPsaAboutPrefix = "cloud_lng_about_psa_"; const auto kPsaAboutPrefix = "cloud_lng_about_psa_";
ApiWrap::RequestMessageDataCallback replyEditMessageDataCallback() {
return [](ChannelData *channel, MsgId msgId) {
if (App::main()) {
App::main()->messageDataReceived(channel, msgId);
}
};
}
void ActivateWindow(not_null<Window::SessionController*> controller) { void ActivateWindow(not_null<Window::SessionController*> controller) {
const auto window = controller->widget(); const auto window = controller->widget();
window->activateWindow(); window->activateWindow();
@ -416,7 +408,7 @@ HistoryWidget::HistoryWidget(
} }
Unexpected("action in MimeData hook."); Unexpected("action in MimeData hook.");
}); });
InitSpellchecker(&controller->session(), _field); InitSpellchecker(controller, _field);
const auto suggestions = Ui::Emoji::SuggestionsController::Init( const auto suggestions = Ui::Emoji::SuggestionsController::Init(
this, this,
@ -520,6 +512,25 @@ HistoryWidget::HistoryWidget(
} }
}, lifetime()); }, lifetime());
session().data().userIsBotChanges(
) | rpl::filter([=](not_null<UserData*> user) {
return (_peer == user.get());
}) | rpl::start_with_next([=](not_null<UserData*> user) {
_list->notifyIsBotChanged();
_list->updateBotInfo();
updateControlsVisibility();
updateControlsGeometry();
}, lifetime());
session().data().botCommandsChanges(
) | rpl::filter([=](not_null<UserData*> user) {
return _peer && (_peer == user || !_peer->isUser());
}) | rpl::start_with_next([=](not_null<UserData*> user) {
if (_fieldAutocomplete->clearFilteredBotCommands()) {
onCheckFieldAutocomplete();
}
}, lifetime());
subscribe(Media::Player::instance()->switchToNextNotifier(), [this](const Media::Player::Instance::Switch &pair) { subscribe(Media::Player::instance()->switchToNextNotifier(), [this](const Media::Player::Instance::Switch &pair) {
if (pair.from.type() == AudioMsgId::Type::Voice) { if (pair.from.type() == AudioMsgId::Type::Voice) {
scrollToCurrentVoiceMessage(pair.from.contextId(), pair.to); scrollToCurrentVoiceMessage(pair.from.contextId(), pair.to);
@ -1030,7 +1041,7 @@ void HistoryWidget::onHashtagOrBotCommandInsert(
// Send bot command at once, if it was not inserted by pressing Tab. // Send bot command at once, if it was not inserted by pressing Tab.
if (str.at(0) == '/' && method != FieldAutocomplete::ChooseMethod::ByTab) { if (str.at(0) == '/' && method != FieldAutocomplete::ChooseMethod::ByTab) {
App::sendBotCommand(_peer, nullptr, str, replyToId()); App::sendBotCommand(_peer, nullptr, str, replyToId());
App::main()->finishForwarding(Api::SendAction(_history)); controller()->content()->finishForwarding(Api::SendAction(_history));
setFieldText(_field->getTextWithTagsPart(_field->textCursor().position())); setFieldText(_field->getTextWithTagsPart(_field->textCursor().position()));
} else { } else {
_field->insertTag(str); _field->insertTag(str);
@ -1045,14 +1056,12 @@ void HistoryWidget::updateInlineBotQuery() {
if (_inlineBotUsername != query.username) { if (_inlineBotUsername != query.username) {
_inlineBotUsername = query.username; _inlineBotUsername = query.username;
if (_inlineBotResolveRequestId) { if (_inlineBotResolveRequestId) {
// Notify::inlineBotRequesting(false);
MTP::cancel(_inlineBotResolveRequestId); MTP::cancel(_inlineBotResolveRequestId);
_inlineBotResolveRequestId = 0; _inlineBotResolveRequestId = 0;
} }
if (query.lookingUpBot) { if (query.lookingUpBot) {
_inlineBot = nullptr; _inlineBot = nullptr;
_inlineLookingUpBot = true; _inlineLookingUpBot = true;
// Notify::inlineBotRequesting(true);
_inlineBotResolveRequestId = MTP::send( _inlineBotResolveRequestId = MTP::send(
MTPcontacts_ResolveUsername(MTP_string(_inlineBotUsername)), MTPcontacts_ResolveUsername(MTP_string(_inlineBotUsername)),
rpcDone(&HistoryWidget::inlineBotResolveDone), rpcDone(&HistoryWidget::inlineBotResolveDone),
@ -1085,6 +1094,10 @@ void HistoryWidget::applyInlineBotQuery(UserData *bot, const QString &query) {
UserData *bot) { UserData *bot) {
sendInlineResult(result, bot); sendInlineResult(result, bot);
}); });
_inlineResults->requesting(
) | rpl::start_with_next([=](bool requesting) {
_tabbedSelectorToggle->setLoading(requesting);
}, _inlineResults->lifetime());
updateControlsGeometry(); updateControlsGeometry();
orderWidgets(); orderWidgets();
} }
@ -1217,9 +1230,7 @@ void HistoryWidget::saveFieldToHistoryLocalDraft() {
} }
void HistoryWidget::onCloudDraftSave() { void HistoryWidget::onCloudDraftSave() {
if (App::main()) { controller()->content()->saveDraftToCloud();
App::main()->saveDraftToCloud();
}
} }
void HistoryWidget::writeDrafts(Data::Draft **localDraft, Data::Draft **editDraft) { void HistoryWidget::writeDrafts(Data::Draft **localDraft, Data::Draft **editDraft) {
@ -1423,27 +1434,15 @@ void HistoryWidget::onRecordUpdate(quint16 level, qint32 samples) {
} }
} }
void HistoryWidget::notify_botCommandsChanged(UserData *user) { void HistoryWidget::notify_replyMarkupUpdated(not_null<const HistoryItem*> item) {
if (_peer && (_peer == user || !_peer->isUser())) {
if (_fieldAutocomplete->clearFilteredBotCommands()) {
onCheckFieldAutocomplete();
}
}
}
void HistoryWidget::notify_inlineBotRequesting(bool requesting) {
_tabbedSelectorToggle->setLoading(requesting);
}
void HistoryWidget::notify_replyMarkupUpdated(const HistoryItem *item) {
if (_keyboard->forMsgId() == item->fullId()) { if (_keyboard->forMsgId() == item->fullId()) {
updateBotKeyboard(item->history(), true); updateBotKeyboard(item->history(), true);
} }
} }
void HistoryWidget::notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) { void HistoryWidget::notify_inlineKeyboardMoved(not_null<const HistoryItem*> item, int oldKeyboardTop, int newKeyboardTop) {
if (_history == item->history() || _migrated == item->history()) { if (_history == item->history() || _migrated == item->history()) {
if (int move = _list->moveScrollFollowingInlineKeyboard(item, oldKeyboardTop, newKeyboardTop)) { if (const auto move = _list->moveScrollFollowingInlineKeyboard(item, oldKeyboardTop, newKeyboardTop)) {
_addToScroll = move; _addToScroll = move;
} }
} }
@ -1480,18 +1479,6 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
return false; return false;
} }
void HistoryWidget::notify_userIsBotChanged(UserData *user) {
if (const auto history = session().data().history(user)) {
session().data().chatsFilters().refreshHistory(history);
}
if (_peer && _peer == user) {
_list->notifyIsBotChanged();
_list->updateBotInfo();
updateControlsVisibility();
updateControlsGeometry();
}
}
void HistoryWidget::setupShortcuts() { void HistoryWidget::setupShortcuts() {
Shortcuts::Requests( Shortcuts::Requests(
) | rpl::filter([=] { ) | rpl::filter([=] {
@ -1502,7 +1489,7 @@ void HistoryWidget::setupShortcuts() {
using Command = Shortcuts::Command; using Command = Shortcuts::Command;
if (_history) { if (_history) {
request->check(Command::Search, 1) && request->handle([=] { request->check(Command::Search, 1) && request->handle([=] {
App::main()->searchInChat(_history); controller()->content()->searchInChat(_history);
return true; return true;
}); });
if (session().supportMode()) { if (session().supportMode()) {
@ -1631,10 +1618,7 @@ void HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
if (_editMsgId || _replyToId) { if (_editMsgId || _replyToId) {
updateReplyEditTexts(); updateReplyEditTexts();
if (!_replyEditMsg) { if (!_replyEditMsg) {
session().api().requestMessageData( requestMessageData(_editMsgId ? _editMsgId : _replyToId);
_peer->asChannel(),
_editMsgId ? _editMsgId : _replyToId,
replyEditMessageDataCallback());
} }
} }
} }
@ -1751,9 +1735,7 @@ void HistoryWidget::showHistory(
// Removing focus from list clears selected and updates top bar. // Removing focus from list clears selected and updates top bar.
setFocus(); setFocus();
} }
if (App::main()) { controller()->content()->saveDraftToCloud();
App::main()->saveDraftToCloud();
}
if (_migrated) { if (_migrated) {
_migrated->clearLocalDraft(); // use migrated draft only once _migrated->clearLocalDraft(); // use migrated draft only once
_migrated->clearEditDraft(); _migrated->clearEditDraft();
@ -3040,7 +3022,7 @@ void HistoryWidget::saveEditMsgDone(History *history, const MTPUpdates &updates,
if (auto editDraft = history->editDraft()) { if (auto editDraft = history->editDraft()) {
if (editDraft->saveRequestId == req) { if (editDraft->saveRequestId == req) {
history->clearEditDraft(); history->clearEditDraft();
if (App::main()) App::main()->writeDrafts(history); controller()->content()->writeDrafts(history);
} }
} }
} }
@ -3135,8 +3117,8 @@ void HistoryWidget::send(Api::SendOptions options) {
if (!_keyboard->hasMarkup() && _keyboard->forceReply() && !_kbReplyTo) { if (!_keyboard->hasMarkup() && _keyboard->forceReply() && !_kbReplyTo) {
toggleKeyboard(); toggleKeyboard();
} }
App::main()->historyToDown(_history); controller()->content()->historyToDown(_history);
App::main()->dialogsToUp(); controller()->content()->dialogsToUp();
} }
void HistoryWidget::sendWithModifiers(Qt::KeyboardModifiers modifiers) { void HistoryWidget::sendWithModifiers(Qt::KeyboardModifiers modifiers) {
@ -3284,7 +3266,7 @@ void HistoryWidget::showAnimated(
historyDownAnimationFinish(); historyDownAnimationFinish();
unreadMentionsAnimationFinish(); unreadMentionsAnimationFinish();
_topShadow->setVisible(params.withTopBarShadow ? false : true); _topShadow->setVisible(params.withTopBarShadow ? false : true);
_cacheOver = App::main()->grabForShowAnimation(params); _cacheOver = controller()->content()->grabForShowAnimation(params);
if (_tabbedPanel) { if (_tabbedPanel) {
_tabbedPanel->hideFast(); _tabbedPanel->hideFast();
@ -3550,8 +3532,12 @@ void HistoryWidget::stopRecording(bool send) {
_send->setRecordActive(false); _send->setRecordActive(false);
} }
void HistoryWidget::sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) { // replyTo != 0 from ReplyKeyboardMarkup, == 0 from cmd links void HistoryWidget::sendBotCommand(
if (!_peer || _peer != peer) { not_null<PeerData*> peer,
UserData *bot,
const QString &cmd,
MsgId replyTo) { // replyTo != 0 from ReplyKeyboardMarkup, == 0 from cmd links
if (_peer != peer.get()) {
return; return;
} else if (showSlowmodeError()) { } else if (showSlowmodeError()) {
return; return;
@ -3853,7 +3839,6 @@ void HistoryWidget::inlineBotResolveDone(
_inlineBotResolveRequestId = 0; _inlineBotResolveRequestId = 0;
const auto &data = result.c_contacts_resolvedPeer(); const auto &data = result.c_contacts_resolvedPeer();
// Notify::inlineBotRequesting(false);
const auto resolvedBot = [&]() -> UserData* { const auto resolvedBot = [&]() -> UserData* {
if (const auto result = session().data().processUsers(data.vusers())) { if (const auto result = session().data().processUsers(data.vusers())) {
if (result->isBot() if (result->isBot()
@ -3881,7 +3866,6 @@ bool HistoryWidget::inlineBotResolveFail(QString name, const RPCError &error) {
} }
_inlineBotResolveRequestId = 0; _inlineBotResolveRequestId = 0;
// Notify::inlineBotRequesting(false);
if (name == _inlineBotUsername) { if (name == _inlineBotUsername) {
clearInlineBot(); clearInlineBot();
} }
@ -4840,9 +4824,9 @@ void HistoryWidget::sendFileConfirmed(
session().data().sendHistoryChangeNotifications(); session().data().sendHistoryChangeNotifications();
if (_peer && file->to.peer == _peer->id) { if (_peer && file->to.peer == _peer->id) {
App::main()->historyToDown(_history); controller()->content()->historyToDown(_history);
} }
App::main()->dialogsToUp(); controller()->content()->dialogsToUp();
} }
void HistoryWidget::photoUploaded( void HistoryWidget::photoUploaded(
@ -5044,7 +5028,7 @@ void HistoryWidget::updateControlsGeometry() {
} }
} }
updateHistoryGeometry(false, false, { ScrollChangeAdd, App::main() ? App::main()->contentScrollAddToY() : 0 }); updateHistoryGeometry(false, false, { ScrollChangeAdd, controller()->content()->contentScrollAddToY() });
updateFieldSize(); updateFieldSize();
@ -5574,7 +5558,7 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) {
} else if (_inReplyEditForward) { } else if (_inReplyEditForward) {
if (readyToForward()) { if (readyToForward()) {
const auto items = std::move(_toForward); const auto items = std::move(_toForward);
App::main()->cancelForwarding(_history); controller()->content()->cancelForwarding(_history);
auto list = ranges::view::all( auto list = ranges::view::all(
items items
) | ranges::view::transform( ) | ranges::view::transform(
@ -5872,10 +5856,7 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
updatePinnedBar(); updatePinnedBar();
} }
if (!_pinnedBar->msg) { if (!_pinnedBar->msg) {
session().api().requestMessageData( requestMessageData(_pinnedBar->msgId);
_peer->asChannel(),
_pinnedBar->msgId,
replyEditMessageDataCallback());
} }
} else if (_pinnedBar) { } else if (_pinnedBar) {
destroyPinnedBar(); destroyPinnedBar();
@ -5889,6 +5870,16 @@ bool HistoryWidget::pinnedMsgVisibilityUpdated() {
return result; return result;
} }
void HistoryWidget::requestMessageData(MsgId msgId) {
const auto callback = [=](ChannelData *channel, MsgId msgId) {
messageDataReceived(channel, msgId);
};
session().api().requestMessageData(
_peer->asChannel(),
msgId,
crl::guard(this, callback));
}
void HistoryWidget::destroyPinnedBar() { void HistoryWidget::destroyPinnedBar() {
_pinnedBar.reset(); _pinnedBar.reset();
_inPinnedMsg = false; _inPinnedMsg = false;
@ -6017,7 +6008,7 @@ void HistoryWidget::replyToMessage(not_null<HistoryItem*> item) {
} else { } else {
const auto itemId = item->fullId(); const auto itemId = item->fullId();
Ui::show(Box<ConfirmBox>(tr::lng_reply_cant_forward(tr::now), tr::lng_selected_forward(tr::now), crl::guard(this, [=] { Ui::show(Box<ConfirmBox>(tr::lng_reply_cant_forward(tr::now), tr::lng_selected_forward(tr::now), crl::guard(this, [=] {
App::main()->setForwardDraft( controller()->content()->setForwardDraft(
_peer->id, _peer->id,
{ 1, itemId }); { 1, itemId });
}))); })));
@ -6025,7 +6016,7 @@ void HistoryWidget::replyToMessage(not_null<HistoryItem*> item) {
return; return;
} }
App::main()->cancelForwarding(_history); controller()->content()->cancelForwarding(_history);
if (_editMsgId) { if (_editMsgId) {
if (auto localDraft = _history->localDraft()) { if (auto localDraft = _history->localDraft()) {
@ -6296,7 +6287,7 @@ void HistoryWidget::cancelFieldAreaState() {
} else if (_editMsgId) { } else if (_editMsgId) {
cancelEdit(); cancelEdit();
} else if (readyToForward()) { } else if (readyToForward()) {
App::main()->cancelForwarding(_history); controller()->content()->cancelForwarding(_history);
} else if (_replyToId) { } else if (_replyToId) {
cancelReply(); cancelReply();
} else if (_kbReplyTo) { } else if (_kbReplyTo) {
@ -7030,7 +7021,7 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
updateListSize(); updateListSize();
} }
Window::SectionWidget::PaintBackground(this, e->rect()); Window::SectionWidget::PaintBackground(controller(), this, e->rect());
Painter p(this); Painter p(this);
const auto clip = e->rect(); const auto clip = e->rect();

View file

@ -182,7 +182,6 @@ public:
void unpinMessage(FullMsgId itemId); void unpinMessage(FullMsgId itemId);
MsgId replyToId() const; MsgId replyToId() const;
void messageDataReceived(ChannelData *channel, MsgId msgId);
bool lastForceReplyReplied(const FullMsgId &replyTo) const; bool lastForceReplyReplied(const FullMsgId &replyTo) const;
bool lastForceReplyReplied() const; bool lastForceReplyReplied() const;
bool cancelReply(bool lastKeyboardUsed = false); bool cancelReply(bool lastKeyboardUsed = false);
@ -204,7 +203,11 @@ public:
void escape(); void escape();
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo); void sendBotCommand(
not_null<PeerData*> peer,
UserData *bot,
const QString &cmd,
MsgId replyTo);
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo); void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
bool insertBotCommand(const QString &cmd); bool insertBotCommand(const QString &cmd);
@ -270,12 +273,10 @@ public:
PeerData *ui_getPeerForMouseAction(); PeerData *ui_getPeerForMouseAction();
void notify_botCommandsChanged(UserData *user);
void notify_inlineBotRequesting(bool requesting); void notify_inlineBotRequesting(bool requesting);
void notify_replyMarkupUpdated(const HistoryItem *item); void notify_replyMarkupUpdated(not_null<const HistoryItem*> item);
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop); void notify_inlineKeyboardMoved(not_null<const HistoryItem*> item, int oldKeyboardTop, int newKeyboardTop);
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo); bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);
void notify_userIsBotChanged(UserData *user);
~HistoryWidget(); ~HistoryWidget();
@ -376,6 +377,9 @@ private:
void setTabbedPanel(std::unique_ptr<TabbedPanel> panel); void setTabbedPanel(std::unique_ptr<TabbedPanel> panel);
void updateField(); void updateField();
void requestMessageData(MsgId msgId);
void messageDataReceived(ChannelData *channel, MsgId msgId);
void send(Api::SendOptions options); void send(Api::SendOptions options);
void sendWithModifiers(Qt::KeyboardModifiers modifiers); void sendWithModifiers(Qt::KeyboardModifiers modifiers);
void sendSilent(); void sendSilent();

View file

@ -852,7 +852,7 @@ void ScheduledWidget::paintEvent(QPaintEvent *e) {
//auto ms = crl::now(); //auto ms = crl::now();
//_historyDownShown.step(ms); //_historyDownShown.step(ms);
SectionWidget::PaintBackground(this, e->rect()); SectionWidget::PaintBackground(controller(), this, e->rect());
} }
void ScheduledWidget::onScroll() { void ScheduledWidget::onScroll() {

View file

@ -145,7 +145,6 @@ TopBarWidget::TopBarWidget(
lifetime()); lifetime());
setCursor(style::cur_pointer); setCursor(style::cur_pointer);
updateControlsVisibility();
} }
TopBarWidget::~TopBarWidget() = default; TopBarWidget::~TopBarWidget() = default;
@ -182,7 +181,7 @@ void TopBarWidget::refreshLang() {
void TopBarWidget::onSearch() { void TopBarWidget::onSearch() {
if (_activeChat) { if (_activeChat) {
App::main()->searchInChat(_activeChat); _controller->content()->searchInChat(_activeChat);
} }
} }
@ -620,7 +619,7 @@ void TopBarWidget::updateControlsVisibility() {
_sendNow->setVisible(_canSendNow); _sendNow->setVisible(_canSendNow);
auto backVisible = Adaptive::OneColumn() auto backVisible = Adaptive::OneColumn()
|| (App::main() && !App::main()->stackIsEmpty()) || !_controller->content()->stackIsEmpty()
|| _activeChat.folder(); || _activeChat.folder();
_back->setVisible(backVisible); _back->setVisible(backVisible);
if (_info) { if (_info) {
@ -653,11 +652,8 @@ void TopBarWidget::updateControlsVisibility() {
} }
void TopBarWidget::updateMembersShowArea() { void TopBarWidget::updateMembersShowArea() {
if (!App::main()) { const auto membersShowAreaNeeded = [&] {
return; auto peer = _controller->content()->peer();
}
auto membersShowAreaNeeded = [this]() {
auto peer = App::main()->peer();
if ((_selectedCount > 0) || !peer) { if ((_selectedCount > 0) || !peer) {
return false; return false;
} }
@ -668,8 +664,8 @@ void TopBarWidget::updateMembersShowArea() {
return megagroup->canViewMembers() && (megagroup->membersCount() < Global::ChatSizeMax()); return megagroup->canViewMembers() && (megagroup->membersCount() < Global::ChatSizeMax());
} }
return false; return false;
}; }();
if (!membersShowAreaNeeded()) { if (!membersShowAreaNeeded) {
if (_membersShowArea) { if (_membersShowArea) {
_membersShowAreaActive.fire(false); _membersShowAreaActive.fire(false);
_membersShowArea.destroy(); _membersShowArea.destroy();

View file

@ -51,7 +51,7 @@ public:
not_null<Window::SessionController*> controller); not_null<Window::SessionController*> controller);
~TopBarWidget(); ~TopBarWidget();
Main::Session &session() const; [[nodiscard]] Main::Session &session() const;
void updateControlsVisibility(); void updateControlsVisibility();
void finishAnimating(); void finishAnimating();

View file

@ -1019,7 +1019,9 @@ bool Widget::overlaps(const QRect &globalRect) const {
} }
void Widget::inlineBotChanged() { void Widget::inlineBotChanged() {
if (!_inlineBot) return; if (!_inlineBot) {
return;
}
if (!isHidden() && !_hiding) { if (!isHidden() && !_hiding) {
hideAnimated(); hideAnimated();
@ -1033,12 +1035,12 @@ void Widget::inlineBotChanged() {
_inner->inlineBotChanged(); _inner->inlineBotChanged();
_inner->hideInlineRowsPanel(); _inner->hideInlineRowsPanel();
Notify::inlineBotRequesting(false); _requesting.fire(false);
} }
void Widget::inlineResultsDone(const MTPmessages_BotResults &result) { void Widget::inlineResultsDone(const MTPmessages_BotResults &result) {
_inlineRequestId = 0; _inlineRequestId = 0;
Notify::inlineBotRequesting(false); _requesting.fire(false);
auto it = _inlineCache.find(_inlineQuery); auto it = _inlineCache.find(_inlineQuery);
auto adding = (it != _inlineCache.cend()); auto adding = (it != _inlineCache.cend());
@ -1104,7 +1106,7 @@ void Widget::queryInlineBot(UserData *bot, PeerData *peer, QString query) {
if (_inlineRequestId) { if (_inlineRequestId) {
MTP::cancel(_inlineRequestId); MTP::cancel(_inlineRequestId);
_inlineRequestId = 0; _inlineRequestId = 0;
Notify::inlineBotRequesting(false); _requesting.fire(false);
} }
if (_inlineCache.find(query) != _inlineCache.cend()) { if (_inlineCache.find(query) != _inlineCache.cend()) {
_inlineRequestTimer.stop(); _inlineRequestTimer.stop();
@ -1129,7 +1131,7 @@ void Widget::onInlineRequest() {
return; return;
} }
} }
Notify::inlineBotRequesting(true); _requesting.fire(true);
_inlineRequestId = _api.request(MTPmessages_GetInlineBotResults( _inlineRequestId = _api.request(MTPmessages_GetInlineBotResults(
MTP_flags(0), MTP_flags(0),
_inlineBot->inputUser, _inlineBot->inputUser,
@ -1141,7 +1143,7 @@ void Widget::onInlineRequest() {
inlineResultsDone(result); inlineResultsDone(result);
}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
// show error? // show error?
Notify::inlineBotRequesting(false); _requesting.fire(false);
_inlineRequestId = 0; _inlineRequestId = 0;
}).handleAllErrors().send(); }).handleAllErrors().send();
} }

View file

@ -199,6 +199,10 @@ public:
_inner->setResultSelectedCallback(std::move(callback)); _inner->setResultSelectedCallback(std::move(callback));
} }
[[nodiscard]] rpl::producer<bool> requesting() const {
return _requesting.events();
}
~Widget(); ~Widget();
protected: protected:
@ -276,6 +280,8 @@ private:
QString _inlineQuery, _inlineNextQuery, _inlineNextOffset; QString _inlineQuery, _inlineNextQuery, _inlineNextOffset;
mtpRequestId _inlineRequestId = 0; mtpRequestId _inlineRequestId = 0;
rpl::event_stream<bool> _requesting;
}; };
} // namespace Layout } // namespace Layout

View file

@ -525,6 +525,10 @@ Main::Session &MainWidget::session() const {
return _controller->session(); return _controller->session();
} }
not_null<Window::SessionController*> MainWidget::controller() const {
return _controller;
}
void MainWidget::setupConnectingWidget() { void MainWidget::setupConnectingWidget() {
using namespace rpl::mappers; using namespace rpl::mappers;
_connecting = std::make_unique<Window::ConnectionState>( _connecting = std::make_unique<Window::ConnectionState>(
@ -772,19 +776,11 @@ void MainWidget::onFilesOrForwardDrop(
} }
} }
void MainWidget::notify_botCommandsChanged(UserData *bot) { void MainWidget::notify_replyMarkupUpdated(not_null<const HistoryItem*> item) {
_history->notify_botCommandsChanged(bot);
}
void MainWidget::notify_inlineBotRequesting(bool requesting) {
_history->notify_inlineBotRequesting(requesting);
}
void MainWidget::notify_replyMarkupUpdated(const HistoryItem *item) {
_history->notify_replyMarkupUpdated(item); _history->notify_replyMarkupUpdated(item);
} }
void MainWidget::notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) { void MainWidget::notify_inlineKeyboardMoved(not_null<const HistoryItem*> item, int oldKeyboardTop, int newKeyboardTop) {
_history->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop); _history->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop);
} }
@ -792,10 +788,6 @@ bool MainWidget::notify_switchInlineBotButtonReceived(const QString &query, User
return _history->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo); return _history->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo);
} }
void MainWidget::notify_userIsBotChanged(UserData *bot) {
_history->notify_userIsBotChanged(bot);
}
void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) { void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
if (_hider != instance) { if (_hider != instance) {
return; return;
@ -1010,7 +1002,11 @@ MsgId MainWidget::currentReplyToIdFor(not_null<History*> history) const {
return 0; return 0;
} }
void MainWidget::sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo) { void MainWidget::sendBotCommand(
not_null<PeerData*> peer,
UserData *bot,
const QString &cmd,
MsgId replyTo) {
_history->sendBotCommand(peer, bot, cmd, replyTo); _history->sendBotCommand(peer, bot, cmd, replyTo);
} }
@ -1435,10 +1431,6 @@ Image *MainWidget::newBackgroundThumb() {
: nullptr; : nullptr;
} }
void MainWidget::messageDataReceived(ChannelData *channel, MsgId msgId) {
_history->messageDataReceived(channel, msgId);
}
void MainWidget::updateBotKeyboard(History *h) { void MainWidget::updateBotKeyboard(History *h) {
_history->updateBotKeyboard(h); _history->updateBotKeyboard(h);
} }
@ -2180,16 +2172,6 @@ void MainWidget::sentUpdatesReceived(uint64 randomId, const MTPUpdates &result)
feedUpdates(result, randomId); feedUpdates(result, randomId);
} }
bool MainWidget::deleteChannelFailed(const RPCError &error) {
if (MTP::isDefaultHandledError(error)) return false;
//if (error.type() == qstr("CHANNEL_TOO_LARGE")) {
// Ui::show(Box<InformBox>(tr::lng_cant_delete_channel(tr::now)));
//}
return true;
}
void MainWidget::historyToDown(History *history) { void MainWidget::historyToDown(History *history) {
_history->historyToDown(history); _history->historyToDown(history);
} }
@ -2984,7 +2966,11 @@ void MainWidget::gotDifference(const MTPupdates_Difference &difference) {
}; };
} }
bool MainWidget::getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, crl::time &curTime) { bool MainWidget::getDifferenceTimeChanged(
ChannelData *channel,
int32 ms,
ChannelGetDifferenceTime &channelCurTime,
crl::time &curTime) {
if (channel) { if (channel) {
if (ms <= 0) { if (ms <= 0) {
ChannelGetDifferenceTime::iterator i = channelCurTime.find(channel); ChannelGetDifferenceTime::iterator i = channelCurTime.find(channel);
@ -3133,11 +3119,11 @@ void MainWidget::getDifferenceAfterFail() {
} }
void MainWidget::getDifference() { void MainWidget::getDifference() {
if (this != App::main()) return;
_getDifferenceTimeByPts = 0; _getDifferenceTimeByPts = 0;
if (requestingDifference()) return; if (requestingDifference()) {
return;
}
_bySeqUpdates.clear(); _bySeqUpdates.clear();
_bySeqTimer.cancel(); _bySeqTimer.cancel();
@ -3158,9 +3144,9 @@ void MainWidget::getDifference() {
rpcFail(&MainWidget::failDifference)); rpcFail(&MainWidget::failDifference));
} }
void MainWidget::getChannelDifference(ChannelData *channel, ChannelDifferenceRequest from) { void MainWidget::getChannelDifference(
if (this != App::main() || !channel) return; not_null<ChannelData*> channel,
ChannelDifferenceRequest from) {
if (from != ChannelDifferenceRequest::PtsGapOrShortPoll) { if (from != ChannelDifferenceRequest::PtsGapOrShortPoll) {
_channelGetDifferenceTimeByPts.remove(channel); _channelGetDifferenceTimeByPts.remove(channel);
} }
@ -3187,8 +3173,8 @@ void MainWidget::getChannelDifference(ChannelData *channel, ChannelDifferenceReq
filter, filter,
MTP_int(channel->pts()), MTP_int(channel->pts()),
MTP_int(kChannelGetDifferenceLimit)), MTP_int(kChannelGetDifferenceLimit)),
rpcDone(&MainWidget::gotChannelDifference, channel), rpcDone(&MainWidget::gotChannelDifference, channel.get()),
rpcFail(&MainWidget::failChannelDifference, channel)); rpcFail(&MainWidget::failChannelDifference, channel.get()));
} }
void MainWidget::sendPing() { void MainWidget::sendPing() {
@ -4628,7 +4614,7 @@ namespace App {
MainWidget *main() { MainWidget *main() {
if (const auto window = wnd()) { if (const auto window = wnd()) {
return window->mainWidget(); return window->sessionContent();
} }
return nullptr; return nullptr;
} }

View file

@ -113,6 +113,7 @@ public:
not_null<Window::SessionController*> controller); not_null<Window::SessionController*> controller);
[[nodiscard]] Main::Session &session() const; [[nodiscard]] Main::Session &session() const;
[[nodiscard]] not_null<Window::SessionController*> controller() const;
[[nodiscard]] bool isMainSectionShown() const; [[nodiscard]] bool isMainSectionShown() const;
[[nodiscard]] bool isThirdSectionShown() const; [[nodiscard]] bool isThirdSectionShown() const;
@ -149,7 +150,6 @@ public:
void sentUpdatesReceived(const MTPUpdates &updates) { void sentUpdatesReceived(const MTPUpdates &updates) {
return sentUpdatesReceived(0, updates); return sentUpdatesReceived(0, updates);
} }
bool deleteChannelFailed(const RPCError &error);
void historyToDown(History *hist); void historyToDown(History *hist);
void dialogsToUp(); void dialogsToUp();
void checkHistoryActivation(); void checkHistoryActivation();
@ -211,7 +211,11 @@ public:
MsgId currentReplyToIdFor(not_null<History*> history) const; MsgId currentReplyToIdFor(not_null<History*> history) const;
void sendBotCommand(PeerData *peer, UserData *bot, const QString &cmd, MsgId replyTo); void sendBotCommand(
not_null<PeerData*> peer,
UserData *bot,
const QString &cmd,
MsgId replyTo);
void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo); void hideSingleUseKeyboard(PeerData *peer, MsgId replyTo);
bool insertBotCommand(const QString &cmd); bool insertBotCommand(const QString &cmd);
@ -233,7 +237,6 @@ public:
void checkChatBackground(); void checkChatBackground();
Image *newBackgroundThumb(); Image *newBackgroundThumb();
void messageDataReceived(ChannelData *channel, MsgId msgId);
void updateBotKeyboard(History *h); void updateBotKeyboard(History *h);
void pushReplyReturn(not_null<HistoryItem*> item); void pushReplyReturn(not_null<HistoryItem*> item);
@ -284,12 +287,9 @@ public:
MsgId msgId); MsgId msgId);
PeerData *ui_getPeerForMouseAction(); PeerData *ui_getPeerForMouseAction();
void notify_botCommandsChanged(UserData *bot); void notify_replyMarkupUpdated(not_null<const HistoryItem*> item);
void notify_inlineBotRequesting(bool requesting); void notify_inlineKeyboardMoved(not_null<const HistoryItem*> item, int oldKeyboardTop, int newKeyboardTop);
void notify_replyMarkupUpdated(const HistoryItem *item);
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo); bool notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo);
void notify_userIsBotChanged(UserData *bot);
void closeBothPlayers(); void closeBothPlayers();
@ -381,7 +381,9 @@ private:
void saveSectionInStack(); void saveSectionInStack();
void getChannelDifference(ChannelData *channel, ChannelDifferenceRequest from = ChannelDifferenceRequest::Unknown); void getChannelDifference(
not_null<ChannelData*> channel,
ChannelDifferenceRequest from = ChannelDifferenceRequest::Unknown);
void gotDifference(const MTPupdates_Difference &diff); void gotDifference(const MTPupdates_Difference &diff);
bool failDifference(const RPCError &e); bool failDifference(const RPCError &e);
void feedDifference(const MTPVector<MTPUser> &users, const MTPVector<MTPChat> &chats, const MTPVector<MTPMessage> &msgs, const MTPVector<MTPUpdate> &other); void feedDifference(const MTPVector<MTPUser> &users, const MTPVector<MTPChat> &chats, const MTPVector<MTPMessage> &msgs, const MTPVector<MTPUpdate> &other);

View file

@ -405,8 +405,8 @@ void MainWindow::ui_removeLayerBlackout() {
} }
} }
MainWidget *MainWindow::mainWidget() { MainWidget *MainWindow::sessionContent() const {
return _main; return _main.data();
} }
void MainWindow::ui_showBox( void MainWindow::ui_showBox(

View file

@ -56,11 +56,7 @@ public:
void setupIntro(); void setupIntro();
void setupMain(); void setupMain();
MainWidget *chatsWidget() { MainWidget *sessionContent() const;
return mainWidget();
}
MainWidget *mainWidget();
[[nodiscard]] bool doWeMarkAsRead(); [[nodiscard]] bool doWeMarkAsRead();

View file

@ -62,6 +62,7 @@ struct PeerUpdate {
UserHasCalls = (1 << 27), UserHasCalls = (1 << 27),
UserOccupiedChanged = (1 << 28), UserOccupiedChanged = (1 << 28),
UserSupportInfoChanged = (1 << 29), UserSupportInfoChanged = (1 << 29),
UserIsBotChanged = (1 << 30),
// For channels // For channels
ChannelAmIn = (1 << 19), ChannelAmIn = (1 << 19),

View file

@ -313,7 +313,7 @@ void SetupSpellchecker(
Spellchecker::ButtonManageDictsState(session), Spellchecker::ButtonManageDictsState(session),
st::settingsButton st::settingsButton
)->addClickHandler([=] { )->addClickHandler([=] {
Ui::show(Box<Ui::ManageDictionariesBox>(session)); Ui::show(Box<Ui::ManageDictionariesBox>(controller));
}); });
button->toggledValue( button->toggledValue(

View file

@ -393,7 +393,7 @@ private:
}; };
void ChooseFromFile( void ChooseFromFile(
not_null<::Main::Session*> session, not_null<Window::SessionController*> controller,
not_null<QWidget*> parent); not_null<QWidget*> parent);
BackgroundRow::BackgroundRow( BackgroundRow::BackgroundRow(
@ -409,10 +409,10 @@ BackgroundRow::BackgroundRow(
updateImage(); updateImage();
_chooseFromGallery->addClickHandler([=] { _chooseFromGallery->addClickHandler([=] {
Ui::show(Box<BackgroundBox>(&controller->session())); Ui::show(Box<BackgroundBox>(controller));
}); });
_chooseFromFile->addClickHandler([=] { _chooseFromFile->addClickHandler([=] {
ChooseFromFile(&controller->session(), this); ChooseFromFile(controller, this);
}); });
using Update = const Window::Theme::BackgroundUpdate; using Update = const Window::Theme::BackgroundUpdate;
@ -594,7 +594,7 @@ void BackgroundRow::updateImage() {
} }
void ChooseFromFile( void ChooseFromFile(
not_null<::Main::Session*> session, not_null<Window::SessionController*> controller,
not_null<QWidget*> parent) { not_null<QWidget*> parent) {
const auto &imgExtensions = cImgExtensions(); const auto &imgExtensions = cImgExtensions();
auto filters = QStringList( auto filters = QStringList(
@ -602,7 +602,7 @@ void ChooseFromFile(
+ imgExtensions.join(qsl(" *")) + imgExtensions.join(qsl(" *"))
+ qsl(")")); + qsl(")"));
filters.push_back(FileDialog::AllFilesFilter()); filters.push_back(FileDialog::AllFilesFilter());
const auto callback = crl::guard(session, [=]( const auto callback = crl::guard(controller, [=](
const FileDialog::OpenResult &result) { const FileDialog::OpenResult &result) {
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) { if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
return; return;
@ -629,7 +629,7 @@ void ChooseFromFile(
auto local = Data::CustomWallPaper(); auto local = Data::CustomWallPaper();
local.setLocalImageAsThumbnail(std::make_shared<Image>( local.setLocalImageAsThumbnail(std::make_shared<Image>(
std::move(image))); std::move(image)));
Ui::show(Box<BackgroundPreviewBox>(session, local)); Ui::show(Box<BackgroundPreviewBox>(controller, local));
}); });
FileDialog::GetOpenPath( FileDialog::GetOpenPath(
parent.get(), parent.get(),

View file

@ -681,8 +681,8 @@ rpl::producer<QString> CallsPeer2PeerPrivacyController::exceptionsDescription()
} }
ForwardsPrivacyController::ForwardsPrivacyController( ForwardsPrivacyController::ForwardsPrivacyController(
not_null<::Main::Session*> session) not_null<Window::SessionController*> controller)
: _session(session) { : _controller(controller) {
} }
ApiWrap::Privacy::Key ForwardsPrivacyController::key() { ApiWrap::Privacy::Key ForwardsPrivacyController::key() {
@ -735,7 +735,7 @@ object_ptr<Ui::RpWidget> ForwardsPrivacyController::setupAboveWidget(
auto message = GenerateForwardedItem( auto message = GenerateForwardedItem(
delegate(), delegate(),
_session->data().history( _controller->session().data().history(
peerFromUser(PeerData::kServiceNotificationsId)), peerFromUser(PeerData::kServiceNotificationsId)),
tr::lng_edit_privacy_forwards_sample_message(tr::now)); tr::lng_edit_privacy_forwards_sample_message(tr::now));
const auto view = message.get(); const auto view = message.get();
@ -760,7 +760,7 @@ object_ptr<Ui::RpWidget> ForwardsPrivacyController::setupAboveWidget(
widget->paintRequest( widget->paintRequest(
) | rpl::start_with_next([=](QRect rect) { ) | rpl::start_with_next([=](QRect rect) {
Window::SectionWidget::PaintBackground(widget, rect); Window::SectionWidget::PaintBackground(_controller, widget, rect);
Painter p(widget); Painter p(widget);
p.translate(0, padding + view->marginBottom()); p.translate(0, padding + view->marginBottom());

View file

@ -12,6 +12,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "mtproto/sender.h" #include "mtproto/sender.h"
namespace Window {
class SessionController;
} // namespace Window
namespace Settings { namespace Settings {
class BlockedBoxController class BlockedBoxController
@ -168,7 +172,8 @@ public:
using Option = EditPrivacyBox::Option; using Option = EditPrivacyBox::Option;
using Exception = EditPrivacyBox::Exception; using Exception = EditPrivacyBox::Exception;
explicit ForwardsPrivacyController(not_null<::Main::Session*> session); explicit ForwardsPrivacyController(
not_null<Window::SessionController*> controller);
Key key() override; Key key() override;
MTPInputPrivacyKey apiKey() override; MTPInputPrivacyKey apiKey() override;
@ -195,7 +200,7 @@ private:
not_null<HistoryView::Element*> view, not_null<HistoryView::Element*> view,
Option value); Option value);
const not_null<::Main::Session*> _session; const not_null<Window::SessionController*> _controller;
}; };

View file

@ -164,7 +164,7 @@ void SetupPrivacy(
add( add(
tr::lng_settings_forwards_privacy(), tr::lng_settings_forwards_privacy(),
Key::Forwards, Key::Forwards,
[=] { return std::make_unique<ForwardsPrivacyController>(session); }); [=] { return std::make_unique<ForwardsPrivacyController>(controller); });
add( add(
tr::lng_settings_profile_photo_privacy(), tr::lng_settings_profile_photo_privacy(),
Key::ProfilePhoto, Key::ProfilePhoto,

View file

@ -48,7 +48,7 @@ class EditInfoBox : public Ui::BoxContent {
public: public:
EditInfoBox( EditInfoBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const TextWithTags &text, const TextWithTags &text,
Fn<void(TextWithTags, Fn<void(bool success)>)> submit); Fn<void(TextWithTags, Fn<void(bool success)>)> submit);
@ -57,7 +57,7 @@ protected:
void setInnerFocus() override; void setInnerFocus() override;
private: private:
not_null<Main::Session*> _session; const not_null<Window::SessionController*> _controller;
object_ptr<Ui::InputField> _field = { nullptr }; object_ptr<Ui::InputField> _field = { nullptr };
Fn<void(TextWithTags, Fn<void(bool success)>)> _submit; Fn<void(TextWithTags, Fn<void(bool success)>)> _submit;
@ -65,10 +65,10 @@ private:
EditInfoBox::EditInfoBox( EditInfoBox::EditInfoBox(
QWidget*, QWidget*,
not_null<Main::Session*> session, not_null<Window::SessionController*> controller,
const TextWithTags &text, const TextWithTags &text,
Fn<void(TextWithTags, Fn<void(bool success)>)> submit) Fn<void(TextWithTags, Fn<void(bool success)>)> submit)
: _session(session) : _controller(controller)
, _field( , _field(
this, this,
st::supportInfoField, st::supportInfoField,
@ -77,12 +77,13 @@ EditInfoBox::EditInfoBox(
text) text)
, _submit(std::move(submit)) { , _submit(std::move(submit)) {
_field->setMaxLength(kMaxSupportInfoLength); _field->setMaxLength(kMaxSupportInfoLength);
_field->setSubmitSettings(session->settings().sendSubmitWay()); _field->setSubmitSettings(
controller->session().settings().sendSubmitWay());
_field->setInstantReplaces(Ui::InstantReplaces::Default()); _field->setInstantReplaces(Ui::InstantReplaces::Default());
_field->setInstantReplacesEnabled( _field->setInstantReplacesEnabled(
session->settings().replaceEmojiValue()); controller->session().settings().replaceEmojiValue());
_field->setMarkdownReplacesEnabled(rpl::single(true)); _field->setMarkdownReplacesEnabled(rpl::single(true));
_field->setEditLinkCallback(DefaultEditLinkCallback(session, _field)); _field->setEditLinkCallback(DefaultEditLinkCallback(controller, _field));
} }
void EditInfoBox::prepare() { void EditInfoBox::prepare() {
@ -106,7 +107,7 @@ void EditInfoBox::prepare() {
Ui::Emoji::SuggestionsController::Init( Ui::Emoji::SuggestionsController::Init(
getDelegate()->outerContainer(), getDelegate()->outerContainer(),
_field, _field,
_session); &_controller->session());
auto cursor = _field->textCursor(); auto cursor = _field->textCursor();
cursor.movePosition(QTextCursor::End); cursor.movePosition(QTextCursor::End);
@ -427,9 +428,10 @@ void Helper::refreshInfo(not_null<UserData*> user) {
user->inputUser user->inputUser
)).done([=](const MTPhelp_UserInfo &result) { )).done([=](const MTPhelp_UserInfo &result) {
applyInfo(user, result); applyInfo(user, result);
if (_userInfoEditPending.contains(user)) { if (const auto controller = _userInfoEditPending.take(user)) {
_userInfoEditPending.erase(user); if (const auto strong = controller->get()) {
showEditInfoBox(user); showEditInfoBox(strong, user);
}
} }
}).send(); }).send();
} }
@ -497,14 +499,18 @@ UserInfo Helper::infoCurrent(not_null<UserData*> user) const {
return (i != end(_userInformation)) ? i->second : UserInfo(); return (i != end(_userInformation)) ? i->second : UserInfo();
} }
void Helper::editInfo(not_null<UserData*> user) { void Helper::editInfo(
not_null<Window::SessionController*> controller,
not_null<UserData*> user) {
if (!_userInfoEditPending.contains(user)) { if (!_userInfoEditPending.contains(user)) {
_userInfoEditPending.emplace(user); _userInfoEditPending.emplace(user, controller.get());
refreshInfo(user); refreshInfo(user);
} }
} }
void Helper::showEditInfoBox(not_null<UserData*> user) { void Helper::showEditInfoBox(
not_null<Window::SessionController*> controller,
not_null<UserData*> user) {
const auto info = infoCurrent(user); const auto info = infoCurrent(user);
const auto editData = TextWithTags{ const auto editData = TextWithTags{
info.text.text, info.text.text,
@ -518,7 +524,7 @@ void Helper::showEditInfoBox(not_null<UserData*> user) {
}, done); }, done);
}; };
Ui::show( Ui::show(
Box<EditInfoBox>(&user->session(), editData, save), Box<EditInfoBox>(controller, editData, save),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
} }

View file

@ -59,7 +59,9 @@ public:
rpl::producer<TextWithEntities> infoTextValue( rpl::producer<TextWithEntities> infoTextValue(
not_null<UserData*> user) const; not_null<UserData*> user) const;
UserInfo infoCurrent(not_null<UserData*> user) const; UserInfo infoCurrent(not_null<UserData*> user) const;
void editInfo(not_null<UserData*> user); void editInfo(
not_null<Window::SessionController*> controller,
not_null<UserData*> user);
Templates &templates(); Templates &templates();
@ -80,7 +82,9 @@ private:
void applyInfo( void applyInfo(
not_null<UserData*> user, not_null<UserData*> user,
const MTPhelp_UserInfo &result); const MTPhelp_UserInfo &result);
void showEditInfoBox(not_null<UserData*> user); void showEditInfoBox(
not_null<Window::SessionController*> controller,
not_null<UserData*> user);
void saveInfo( void saveInfo(
not_null<UserData*> user, not_null<UserData*> user,
TextWithEntities text, TextWithEntities text,
@ -98,7 +102,9 @@ private:
base::flat_map<not_null<History*>, TimeId> _occupiedChats; base::flat_map<not_null<History*>, TimeId> _occupiedChats;
base::flat_map<not_null<UserData*>, UserInfo> _userInformation; base::flat_map<not_null<UserData*>, UserInfo> _userInformation;
base::flat_set<not_null<UserData*>> _userInfoEditPending; base::flat_map<
not_null<UserData*>,
base::weak_ptr<Window::SessionController>> _userInfoEditPending;
base::flat_map<not_null<UserData*>, SavingInfo> _userInfoSaving; base::flat_map<not_null<UserData*>, SavingInfo> _userInfoSaving;
rpl::lifetime _lifetime; rpl::lifetime _lifetime;

View file

@ -84,17 +84,20 @@ QPixmap SectionWidget::grabForShowAnimation(
return Ui::GrabWidget(this); return Ui::GrabWidget(this);
} }
void SectionWidget::PaintBackground(not_null<QWidget*> widget, QRect clip) { void SectionWidget::PaintBackground(
not_null<Window::SessionController*> controller,
not_null<QWidget*> widget,
QRect clip) {
Painter p(widget); Painter p(widget);
auto fill = QRect(0, 0, widget->width(), App::main()->height()); auto fill = QRect(0, 0, widget->width(), controller->content()->height());
if (const auto color = Window::Theme::Background()->colorForFill()) { if (const auto color = Window::Theme::Background()->colorForFill()) {
p.fillRect(fill, *color); p.fillRect(fill, *color);
return; return;
} }
auto fromy = App::main()->backgroundFromY(); auto fromy = controller->content()->backgroundFromY();
auto x = 0, y = 0; auto x = 0, y = 0;
auto cached = App::main()->cachedBackground(fill, x, y); auto cached = controller->content()->cachedBackground(fill, x, y);
if (cached.isNull()) { if (cached.isNull()) {
if (Window::Theme::Background()->tile()) { if (Window::Theme::Background()->tile()) {
auto &pix = Window::Theme::Background()->pixmapForTiled(); auto &pix = Window::Theme::Background()->pixmapForTiled();

View file

@ -44,6 +44,9 @@ public:
} }
[[nodiscard]] Main::Session &session() const; [[nodiscard]] Main::Session &session() const;
[[nodiscard]] not_null<Window::SessionController*> controller() const {
return _controller;
}
// Tabbed selector management. // Tabbed selector management.
virtual bool pushTabbedSelectorToThirdSection( virtual bool pushTabbedSelectorToThirdSection(
@ -63,11 +66,6 @@ public:
return mapToGlobal(rect()); return mapToGlobal(rect());
} }
protected:
[[nodiscard]] not_null<Window::SessionController*> controller() const {
return _controller;
}
private: private:
const not_null<Window::SessionController*> _controller; const not_null<Window::SessionController*> _controller;
@ -88,7 +86,9 @@ struct SectionSlideParams {
class SectionWidget : public AbstractSectionWidget { class SectionWidget : public AbstractSectionWidget {
public: public:
SectionWidget(QWidget *parent, not_null<Window::SessionController*> controller); SectionWidget(
QWidget *parent,
not_null<Window::SessionController*> controller);
virtual Dialogs::RowDescriptor activeChat() const { virtual Dialogs::RowDescriptor activeChat() const {
return {}; return {};
@ -140,7 +140,10 @@ public:
return nullptr; return nullptr;
} }
static void PaintBackground(not_null<QWidget*> widget, QRect clip); static void PaintBackground(
not_null<Window::SessionController*> controller,
not_null<QWidget*> widget,
QRect clip);
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;

View file

@ -135,7 +135,7 @@ MainMenu::MainMenu(
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
const auto showSelfChat = [=] { const auto showSelfChat = [=] {
App::main()->choosePeer( controller->content()->choosePeer(
_controller->session().userPeerId(), _controller->session().userPeerId(),
ShowAtUnreadMsgId); ShowAtUnreadMsgId);
}; };
@ -143,7 +143,7 @@ MainMenu::MainMenu(
const auto folder = _controller->session().data().folderLoaded( const auto folder = _controller->session().data().folderLoaded(
Data::Folder::kId); Data::Folder::kId);
if (folder) { if (folder) {
App::wnd()->sessionController()->openFolder(folder); controller->openFolder(folder);
Ui::hideSettingsAndLayer(); Ui::hideSettingsAndLayer();
} }
}; };

View file

@ -460,7 +460,7 @@ void Filler::addUserActions(not_null<UserData*> user) {
if (_source != PeerMenuSource::ChatsList) { if (_source != PeerMenuSource::ChatsList) {
if (user->session().supportMode()) { if (user->session().supportMode()) {
_addAction("Edit support info", [=] { _addAction("Edit support info", [=] {
user->session().supportHelper().editInfo(user); user->session().supportHelper().editInfo(controller, user);
}); });
} }
if (!user->isContact() && !user->isSelf() && !user->isBot()) { if (!user->isContact() && !user->isSelf() && !user->isBot()) {
@ -490,7 +490,7 @@ void Filler::addUserActions(not_null<UserData*> user) {
if (user->canSendPolls()) { if (user->canSendPolls()) {
_addAction( _addAction(
tr::lng_polls_create(tr::now), tr::lng_polls_create(tr::now),
[=] { PeerMenuCreatePoll(user); }); [=] { PeerMenuCreatePoll(controller, user); });
} }
if (user->canExportChatHistory()) { if (user->canExportChatHistory()) {
_addAction( _addAction(
@ -528,7 +528,7 @@ void Filler::addChatActions(not_null<ChatData*> chat) {
if (chat->canSendPolls()) { if (chat->canSendPolls()) {
_addAction( _addAction(
tr::lng_polls_create(tr::now), tr::lng_polls_create(tr::now),
[=] { PeerMenuCreatePoll(chat); }); [=] { PeerMenuCreatePoll(controller, chat); });
} }
if (chat->canExportChatHistory()) { if (chat->canExportChatHistory()) {
_addAction( _addAction(
@ -574,7 +574,7 @@ void Filler::addChannelActions(not_null<ChannelData*> channel) {
if (channel->canSendPolls()) { if (channel->canSendPolls()) {
_addAction( _addAction(
tr::lng_polls_create(tr::now), tr::lng_polls_create(tr::now),
[=] { PeerMenuCreatePoll(channel); }); [=] { PeerMenuCreatePoll(navigation, channel); });
} }
if (channel->canExportChatHistory()) { if (channel->canExportChatHistory()) {
_addAction( _addAction(
@ -790,6 +790,7 @@ void PeerMenuShareContactBox(
} }
void PeerMenuCreatePoll( void PeerMenuCreatePoll(
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer, not_null<PeerData*> peer,
PollData::Flags chosen, PollData::Flags chosen,
PollData::Flags disabled) { PollData::Flags disabled) {
@ -798,7 +799,7 @@ void PeerMenuCreatePoll(
disabled |= PollData::Flag::PublicVotes; disabled |= PollData::Flag::PublicVotes;
} }
const auto box = Ui::show(Box<CreatePollBox>( const auto box = Ui::show(Box<CreatePollBox>(
&peer->session(), controller,
chosen, chosen,
disabled, disabled,
Api::SendType::Normal)); Api::SendType::Normal));
@ -811,7 +812,7 @@ void PeerMenuCreatePoll(
auto action = Api::SendAction(peer->owner().history(peer)); auto action = Api::SendAction(peer->owner().history(peer));
action.clearDraft = false; action.clearDraft = false;
action.options = result.options; action.options = result.options;
if (const auto id = App::main()->currentReplyToIdFor(action.history)) { if (const auto id = controller->content()->currentReplyToIdFor(action.history)) {
action.replyTo = id; action.replyTo = id;
} }
if (const auto localDraft = action.history->localDraft()) { if (const auto localDraft = action.history->localDraft()) {
@ -919,7 +920,8 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
auto callback = [ auto callback = [
ids = std::move(items), ids = std::move(items),
callback = std::move(successCallback), callback = std::move(successCallback),
weak weak,
navigation
](not_null<PeerData*> peer) mutable { ](not_null<PeerData*> peer) mutable {
if (peer->isSelf()) { if (peer->isSelf()) {
auto items = peer->owner().idsToItems(ids); auto items = peer->owner().idsToItems(ids);
@ -932,7 +934,7 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
Ui::Toast::Show(tr::lng_share_done(tr::now)); Ui::Toast::Show(tr::lng_share_done(tr::now));
}); });
} }
} else if (!App::main()->setForwardDraft(peer->id, std::move(ids))) { } else if (!navigation->parentController()->content()->setForwardDraft(peer->id, std::move(ids))) {
return; return;
} }
if (const auto strong = *weak) { if (const auto strong = *weak) {

View file

@ -62,6 +62,7 @@ void PeerMenuAddChannelMembers(
not_null<ChannelData*> channel); not_null<ChannelData*> channel);
//void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); // #feed //void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); // #feed
void PeerMenuCreatePoll( void PeerMenuCreatePoll(
not_null<Window::SessionController*> controller,
not_null<PeerData*> peer, not_null<PeerData*> peer,
PollData::Flags chosen = PollData::Flags(), PollData::Flags chosen = PollData::Flags(),
PollData::Flags disabled = PollData::Flags()); PollData::Flags disabled = PollData::Flags());

View file

@ -158,7 +158,7 @@ auto SessionController::tabbedSelector() const
void SessionController::takeTabbedSelectorOwnershipFrom( void SessionController::takeTabbedSelectorOwnershipFrom(
not_null<QWidget*> parent) { not_null<QWidget*> parent) {
if (_tabbedSelector->parent() == parent) { if (_tabbedSelector->parent() == parent) {
if (const auto chats = widget()->chatsWidget()) { if (const auto chats = widget()->sessionContent()) {
chats->returnTabbedSelector(); chats->returnTabbedSelector();
} }
if (_tabbedSelector->parent() == parent) { if (_tabbedSelector->parent() == parent) {
@ -395,7 +395,7 @@ bool SessionController::forceWideDialogs() const {
} else if (dialogsListFocused().value()) { } else if (dialogsListFocused().value()) {
return true; return true;
} }
return !App::main()->isMainSectionShown(); return !content()->isMainSectionShown();
} }
auto SessionController::computeColumnLayout() const -> ColumnLayout { auto SessionController::computeColumnLayout() const -> ColumnLayout {
@ -499,7 +499,7 @@ bool SessionController::canShowThirdSectionWithoutResize() const {
} }
bool SessionController::takeThirdSectionFromLayer() { bool SessionController::takeThirdSectionFromLayer() {
return App::wnd()->takeThirdSectionFromLayer(); return widget()->takeThirdSectionFromLayer();
} }
void SessionController::resizeForThirdSection() { void SessionController::resizeForThirdSection() {
@ -682,14 +682,14 @@ void SessionController::clearPassportForm() {
} }
void SessionController::updateColumnLayout() { void SessionController::updateColumnLayout() {
App::main()->updateColumnLayout(); content()->updateColumnLayout();
} }
void SessionController::showPeerHistory( void SessionController::showPeerHistory(
PeerId peerId, PeerId peerId,
const SectionShow &params, const SectionShow &params,
MsgId msgId) { MsgId msgId) {
App::main()->ui_showPeerHistory( content()->ui_showPeerHistory(
peerId, peerId,
params, params,
msgId); msgId);
@ -718,30 +718,30 @@ void SessionController::showPeerHistory(
void SessionController::showSection( void SessionController::showSection(
SectionMemento &&memento, SectionMemento &&memento,
const SectionShow &params) { const SectionShow &params) {
if (!params.thirdColumn && App::wnd()->showSectionInExistingLayer( if (!params.thirdColumn && widget()->showSectionInExistingLayer(
&memento, &memento,
params)) { params)) {
return; return;
} }
App::main()->showSection(std::move(memento), params); content()->showSection(std::move(memento), params);
} }
void SessionController::showBackFromStack(const SectionShow &params) { void SessionController::showBackFromStack(const SectionShow &params) {
chats()->showBackFromStack(params); content()->showBackFromStack(params);
} }
void SessionController::showSpecialLayer( void SessionController::showSpecialLayer(
object_ptr<Ui::LayerWidget> &&layer, object_ptr<Ui::LayerWidget> &&layer,
anim::type animated) { anim::type animated) {
App::wnd()->showSpecialLayer(std::move(layer), animated); widget()->showSpecialLayer(std::move(layer), animated);
} }
void SessionController::removeLayerBlackout() { void SessionController::removeLayerBlackout() {
App::wnd()->ui_removeLayerBlackout(); widget()->ui_removeLayerBlackout();
} }
not_null<MainWidget*> SessionController::chats() const { not_null<MainWidget*> SessionController::content() const {
return App::wnd()->chatsWidget(); return widget()->sessionContent();
} }
void SessionController::setDefaultFloatPlayerDelegate( void SessionController::setDefaultFloatPlayerDelegate(

View file

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/flags.h" #include "base/flags.h"
#include "base/observer.h" #include "base/observer.h"
#include "base/object_ptr.h" #include "base/object_ptr.h"
#include "base/weak_ptr.h"
#include "dialogs/dialogs_key.h" #include "dialogs/dialogs_key.h"
#include "ui/effects/animation_value.h" #include "ui/effects/animation_value.h"
@ -163,6 +164,7 @@ private:
class SessionController class SessionController
: public SessionNavigation : public SessionNavigation
, public base::has_weak_ptr
, private base::Subscriber { , private base::Subscriber {
public: public:
SessionController( SessionController(
@ -173,6 +175,7 @@ public:
return *_window; return *_window;
} }
[[nodiscard]] not_null<::MainWindow*> widget() const; [[nodiscard]] not_null<::MainWindow*> widget() const;
[[nodiscard]] not_null<MainWidget*> content() const;
[[nodiscard]] auto tabbedSelector() const [[nodiscard]] auto tabbedSelector() const
-> not_null<ChatHelpers::TabbedSelector*>; -> not_null<ChatHelpers::TabbedSelector*>;
@ -314,7 +317,6 @@ private:
void checkOpenedFilter(); void checkOpenedFilter();
int minimalThreeColumnWidth() const; int minimalThreeColumnWidth() const;
not_null<MainWidget*> chats() const;
int countDialogsWidthFromRatio(int bodyWidth) const; int countDialogsWidthFromRatio(int bodyWidth) const;
int countThirdColumnWidthFromRatio(int bodyWidth) const; int countThirdColumnWidthFromRatio(int bodyWidth) const;
struct ShrinkResult { struct ShrinkResult {