Remove some activeAccount() calls.

This commit is contained in:
John Preston 2020-06-10 18:52:44 +04:00
parent 598fb67cdf
commit ea86433be5
28 changed files with 132 additions and 58 deletions

View file

@ -978,8 +978,9 @@ void ProxyBox::addLabel(
} // namespace } // namespace
ProxiesBoxController::ProxiesBoxController() ProxiesBoxController::ProxiesBoxController(not_null<Main::Account*> account)
: _saveTimer([] { Local::writeSettings(); }) { : _account(account)
, _saveTimer([] { Local::writeSettings(); }) {
_list = ranges::view::all( _list = ranges::view::all(
Global::ProxiesList() Global::ProxiesList()
) | ranges::view::transform([&](const ProxyData &proxy) { ) | ranges::view::transform([&](const ProxyData &proxy) {
@ -1058,7 +1059,9 @@ void ProxiesBoxController::refreshChecker(Item &item) {
const auto type = (item.data.type == Type::Http) const auto type = (item.data.type == Type::Http)
? Variants::Http ? Variants::Http
: Variants::Tcp; : Variants::Tcp;
const auto mtproto = Core::App().activeAccount().mtp(); const auto mtproto = _account->mtp();
Assert(mtproto != nullptr);
const auto dcId = mtproto->mainDcId(); const auto dcId = mtproto->mainDcId();
item.state = ItemState::Checking; item.state = ItemState::Checking;
@ -1142,8 +1145,9 @@ void ProxiesBoxController::setupChecker(int id, const Checker &checker) {
pointer->connect(pointer, &Connection::error, failed); pointer->connect(pointer, &Connection::error, failed);
} }
object_ptr<Ui::BoxContent> ProxiesBoxController::CreateOwningBox() { object_ptr<Ui::BoxContent> ProxiesBoxController::CreateOwningBox(
auto controller = std::make_unique<ProxiesBoxController>(); not_null<Main::Account*> account) {
auto controller = std::make_unique<ProxiesBoxController>(account);
auto box = controller->create(); auto box = controller->create();
Ui::AttachAsChild(box, std::move(controller)); Ui::AttachAsChild(box, std::move(controller));
return box; return box;

View file

@ -24,18 +24,23 @@ template <typename Enum>
class Radioenum; class Radioenum;
} // namespace Ui } // namespace Ui
namespace Main {
class Account;
} // namespace Main
class ProxiesBoxController : public base::Subscriber { class ProxiesBoxController : public base::Subscriber {
public: public:
using ProxyData = MTP::ProxyData; using ProxyData = MTP::ProxyData;
using Type = ProxyData::Type; using Type = ProxyData::Type;
ProxiesBoxController(); explicit ProxiesBoxController(not_null<Main::Account*> account);
static void ShowApplyConfirmation( static void ShowApplyConfirmation(
Type type, Type type,
const QMap<QString, QString> &fields); const QMap<QString, QString> &fields);
static object_ptr<Ui::BoxContent> CreateOwningBox(); static object_ptr<Ui::BoxContent> CreateOwningBox(
not_null<Main::Account*> account);
object_ptr<Ui::BoxContent> create(); object_ptr<Ui::BoxContent> create();
enum class ItemState { enum class ItemState {
@ -104,6 +109,7 @@ private:
const ProxyData &proxy); const ProxyData &proxy);
void addNewItem(const ProxyData &proxy); void addNewItem(const ProxyData &proxy);
const not_null<Main::Account*> _account;
int _idCounter = 0; int _idCounter = 0;
std::vector<Item> _list; std::vector<Item> _list;
rpl::event_stream<ItemView> _views; rpl::event_stream<ItemView> _views;

View file

@ -516,7 +516,7 @@ void EmojiKeywords::langPackRefreshed() {
} }
void EmojiKeywords::handleSessionChanges() { void EmojiKeywords::handleSessionChanges() {
Core::App().activeAccount().sessionValue( Core::App().activeAccount().sessionValue( // #TODO multi someSessionValue
) | rpl::map([](Main::Session *session) { ) | rpl::map([](Main::Session *session) {
return session ? &session->api() : nullptr; return session ? &session->api() : nullptr;
}) | rpl::start_with_next([=](ApiWrap *api) { }) | rpl::start_with_next([=](ApiWrap *api) {

View file

@ -113,13 +113,13 @@ Application::Application(not_null<Launcher*> launcher)
_shouldLockAt = 0; _shouldLockAt = 0;
}, _lifetime); }, _lifetime);
activeAccount().sessionChanges( activeAccount().sessionChanges( // #TODO multi activeSessionValue
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
if (_mediaView) { if (_mediaView) {
hideMediaView(); hideMediaView();
_mediaView->clearData(); _mediaView->clearData();
} }
if (session && !UpdaterDisabled()) { if (session && !UpdaterDisabled()) { // #TODO multi someSessionValue
UpdateChecker().setMtproto(session); UpdateChecker().setMtproto(session);
} }
}, _lifetime); }, _lifetime);
@ -578,7 +578,7 @@ bool Application::unreadBadgeMuted() const {
: false; : false;
} }
bool Application::offerLangPackSwitch() const { bool Application::offerLegacyLangPackSwitch() const {
// #TODO multi we offer only if we were upgraded from an old authed app. // #TODO multi we offer only if we were upgraded from an old authed app.
return activeAccount().sessionExists(); return activeAccount().sessionExists();
} }

View file

@ -169,7 +169,7 @@ public:
[[nodiscard]] Lang::CloudManager *langCloudManager() { [[nodiscard]] Lang::CloudManager *langCloudManager() {
return _langCloudManager.get(); return _langCloudManager.get();
} }
[[nodiscard]] bool offerLangPackSwitch() const; [[nodiscard]] bool offerLegacyLangPackSwitch() const;
[[nodiscard]] bool canApplyLangPackWithoutRestart() const; [[nodiscard]] bool canApplyLangPackWithoutRestart() const;
[[nodiscard]] ChatHelpers::EmojiKeywords &emojiKeywords() { [[nodiscard]] ChatHelpers::EmojiKeywords &emojiKeywords() {
return *_emojiKeywords; return *_emojiKeywords;

View file

@ -1590,7 +1590,7 @@ void UpdateApplication() {
Window::SectionShow()); Window::SectionShow());
} else { } else {
window->showSpecialLayer( window->showSpecialLayer(
Box<::Settings::LayerWidget>(), Box<::Settings::LayerWidget>(&window->controller()),
anim::type::normal); anim::type::normal);
} }
window->showFromTray(); window->showFromTray();

View file

@ -381,6 +381,7 @@ void Widget::updateScrollUpPosition() {
void Widget::setupConnectingWidget() { void Widget::setupConnectingWidget() {
_connecting = std::make_unique<Window::ConnectionState>( _connecting = std::make_unique<Window::ConnectionState>(
this, this,
&session().account(),
Window::AdaptiveIsOneColumn()); Window::AdaptiveIsOneColumn());
} }

View file

@ -8,6 +8,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/info_section_widget.h" #include "info/info_section_widget.h"
#include "window/window_connecting_widget.h" #include "window/window_connecting_widget.h"
#include "window/window_session_controller.h"
#include "main/main_session.h"
#include "info/info_content_widget.h" #include "info/info_content_widget.h"
#include "info/info_wrap_widget.h" #include "info/info_wrap_widget.h"
#include "info/info_layer_widget.h" #include "info/info_layer_widget.h"
@ -48,6 +50,7 @@ void SectionWidget::init() {
_connecting = std::make_unique<Window::ConnectionState>( _connecting = std::make_unique<Window::ConnectionState>(
_content.data(), _content.data(),
&controller()->session().account(),
Window::AdaptiveIsOneColumn()); Window::AdaptiveIsOneColumn());
_content->contentChanged( _content->contentChanged(

View file

@ -56,6 +56,7 @@ Widget::Widget(QWidget *parent, not_null<Main::Account*> account)
object_ptr<Ui::RoundButton>(this, nullptr, st::introNextButton)) object_ptr<Ui::RoundButton>(this, nullptr, st::introNextButton))
, _connecting(std::make_unique<Window::ConnectionState>( , _connecting(std::make_unique<Window::ConnectionState>(
this, this,
account,
rpl::single(true))) { rpl::single(true))) {
appendStep(new StartWidget(this, _account, getData())); appendStep(new StartWidget(this, _account, getData()));
fixOrder(); fixOrder();

View file

@ -158,7 +158,7 @@ Language ParseLanguage(const MTPLangPackLanguage &data) {
CloudManager::CloudManager(Instance &langpack) CloudManager::CloudManager(Instance &langpack)
: _langpack(langpack) { : _langpack(langpack) {
Core::App().activeAccount().mtpValue( Core::App().activeAccount().mtpValue( // #TODO multi activeAccountValue
) | rpl::start_with_next([=](MTP::Instance *instance) { ) | rpl::start_with_next([=](MTP::Instance *instance) {
if (instance) { if (instance) {
_api.emplace(instance); _api.emplace(instance);

View file

@ -182,19 +182,17 @@ rpl::producer<> Account::mtpNewSessionCreated() const {
return _mtpNewSessionCreated.events(); return _mtpNewSessionCreated.events();
} }
void Account::setMtpMainDcId(MTP::DcId mainDcId) { void Account::setLegacyMtpMainDcId(MTP::DcId mainDcId) {
Expects(!_mtp); Expects(!_mtp);
_mtpConfig.mainDcId = mainDcId; _mtpConfig.mainDcId = mainDcId;
} }
void Account::setMtpKey(MTP::DcId dcId, const MTP::AuthKey::Data &keyData) { void Account::setLegacyMtpKey(std::shared_ptr<MTP::AuthKey> key) {
Expects(!_mtp); Expects(!_mtp);
Expects(key != nullptr);
_mtpConfig.keys.push_back(std::make_shared<MTP::AuthKey>( _mtpConfig.keys.push_back(std::move(key));
MTP::AuthKey::Type::ReadFromFile,
dcId,
keyData));
} }
QByteArray Account::serializeMtpAuthorization() const { QByteArray Account::serializeMtpAuthorization() const {

View file

@ -59,8 +59,8 @@ public:
[[nodiscard]] rpl::producer<MTP::Instance*> mtpChanges() const; [[nodiscard]] rpl::producer<MTP::Instance*> mtpChanges() const;
// Set from legacy storage. // Set from legacy storage.
void setMtpMainDcId(MTP::DcId mainDcId); void setLegacyMtpMainDcId(MTP::DcId mainDcId);
void setMtpKey(MTP::DcId dcId, const MTP::AuthKey::Data &keyData); void setLegacyMtpKey(std::shared_ptr<MTP::AuthKey> key);
void setSessionUserId(UserId userId); void setSessionUserId(UserId userId);
void setSessionFromStorage( void setSessionFromStorage(
std::unique_ptr<Settings> data, std::unique_ptr<Settings> data,

View file

@ -529,6 +529,7 @@ void MainWidget::setupConnectingWidget() {
using namespace rpl::mappers; using namespace rpl::mappers;
_connecting = std::make_unique<Window::ConnectionState>( _connecting = std::make_unique<Window::ConnectionState>(
this, this,
&session().account(),
Window::AdaptiveIsOneColumn() | rpl::map(!_1)); Window::AdaptiveIsOneColumn() | rpl::map(!_1));
} }

View file

@ -305,10 +305,12 @@ void MainWindow::showSettings() {
return; return;
} }
if (const auto controller = sessionController()) { if (const auto session = sessionController()) {
controller->showSettings(); session->showSettings();
} else { } else {
showSpecialLayer(Box<Settings::LayerWidget>(), anim::type::normal); showSpecialLayer(
Box<Settings::LayerWidget>(&controller()),
anim::type::normal);
} }
} }

View file

@ -114,7 +114,7 @@ Instance::Instance()
}); });
// While we have one Media::Player::Instance for all sessions we have to do this. // While we have one Media::Player::Instance for all sessions we have to do this.
Core::App().activeAccount().sessionValue( Core::App().activeAccount().sessionValue( // #TODO multi activeSessionValue
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
if (session) { if (session) {
subscribe(session->calls().currentCallChanged(), [=](Calls::Call *call) { subscribe(session->calls().currentCallChanged(), [=](Calls::Call *call) {

View file

@ -304,6 +304,7 @@ OverlayWidget::OverlayWidget()
? Global::VideoVolume() ? Global::VideoVolume()
: Global::kDefaultVolume; : Global::kDefaultVolume;
// #TODO multi activeSessionValue change icon on show?
setWindowIcon(Window::CreateIcon(&Core::App().activeAccount())); setWindowIcon(Window::CreateIcon(&Core::App().activeAccount()));
setWindowTitle(qsl("Media viewer")); setWindowTitle(qsl("Media viewer"));
@ -320,7 +321,7 @@ OverlayWidget::OverlayWidget()
connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onScreenResized(int))); connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(onScreenResized(int)));
// While we have one mediaview for all sessions we have to do this. // While we have one mediaview for all sessions we have to do this.
Core::App().activeAccount().sessionValue( Core::App().activeAccount().sessionValue( // #TODO multi activeSessionValue
) | rpl::start_with_next([=](Main::Session *session) { ) | rpl::start_with_next([=](Main::Session *session) {
if (session) { if (session) {
subscribe(session->downloaderTaskFinished(), [=] { subscribe(session->downloaderTaskFinished(), [=] {

View file

@ -39,7 +39,7 @@ void unpause() {
} // namespace details } // namespace details
Instance *MainInstance() { Instance *MainInstance() {
return Core::IsAppLaunched() return Core::IsAppLaunched() // #TODO multi
? Core::App().activeAccount().mtp() ? Core::App().activeAccount().mtp()
: nullptr; : nullptr;
} }

View file

@ -854,7 +854,7 @@ void Instance::Private::configLoadDone(const MTPConfig &result) {
data.vlang_pack_version().value_or_empty(), data.vlang_pack_version().value_or_empty(),
data.vbase_lang_pack_version().value_or_empty()); data.vbase_lang_pack_version().value_or_empty());
Core::App().activeAccount().configUpdated(); Core::App().activeAccount().configUpdated(); // #TODO multi
if (const auto prefix = data.vautoupdate_url_prefix()) { if (const auto prefix = data.vautoupdate_url_prefix()) {
Local::writeAutoupdatePrefix(qs(*prefix)); Local::writeAutoupdatePrefix(qs(*prefix));

View file

@ -48,7 +48,9 @@ bool HasConnectionType() {
return false; return false;
} }
void SetupConnectionType(not_null<Ui::VerticalLayout*> container) { void SetupConnectionType(
not_null<Main::Account*> account,
not_null<Ui::VerticalLayout*> container) {
if (!HasConnectionType()) { if (!HasConnectionType()) {
return; return;
} }
@ -74,8 +76,8 @@ void SetupConnectionType(not_null<Ui::VerticalLayout*> container) {
Global::RefConnectionTypeChanged() Global::RefConnectionTypeChanged()
)) | rpl::map(connectionType), )) | rpl::map(connectionType),
st::settingsButton); st::settingsButton);
button->addClickHandler([] { button->addClickHandler([=] {
Ui::show(ProxiesBoxController::CreateOwningBox()); Ui::show(ProxiesBoxController::CreateOwningBox(account));
}); });
#endif // TDESKTOP_DISABLE_NETWORK_PROXY #endif // TDESKTOP_DISABLE_NETWORK_PROXY
} }
@ -563,7 +565,7 @@ void Advanced::setupContent(not_null<Window::SessionController*> controller) {
addDivider(); addDivider();
AddSkip(content); AddSkip(content);
AddSubsectionTitle(content, tr::lng_settings_network_proxy()); AddSubsectionTitle(content, tr::lng_settings_network_proxy());
SetupConnectionType(content); SetupConnectionType(&controller->session().account(), content);
AddSkip(content); AddSkip(content);
} }
SetupDataStorage(controller, content); SetupDataStorage(controller, content);

View file

@ -9,10 +9,16 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_common.h" #include "settings/settings_common.h"
namespace Main {
class Account;
} // namespace Main
namespace Settings { namespace Settings {
bool HasConnectionType(); bool HasConnectionType();
void SetupConnectionType(not_null<Ui::VerticalLayout*> container); void SetupConnectionType(
not_null<Main::Account*> account,
not_null<Ui::VerticalLayout*> container);
bool HasUpdate(); bool HasUpdate();
void SetupUpdate(not_null<Ui::VerticalLayout*> container); void SetupUpdate(not_null<Ui::VerticalLayout*> container);
bool HasTray(); bool HasTray();

View file

@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/scroll_area.h" #include "ui/widgets/scroll_area.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "window/window_controller.h"
#include "app.h" #include "app.h"
#include "styles/style_settings.h" #include "styles/style_settings.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
@ -56,14 +57,16 @@ private:
}; };
object_ptr<Ui::RpWidget> CreateIntroSettings(QWidget *parent) { object_ptr<Ui::RpWidget> CreateIntroSettings(
QWidget *parent,
not_null<Window::Controller*> window) {
auto result = object_ptr<Ui::VerticalLayout>(parent); auto result = object_ptr<Ui::VerticalLayout>(parent);
AddDivider(result); AddDivider(result);
AddSkip(result); AddSkip(result);
SetupLanguageButton(result, false); SetupLanguageButton(result, false);
if (HasConnectionType()) { if (HasConnectionType()) {
SetupConnectionType(result); SetupConnectionType(&window->account(), result);
} }
AddSkip(result); AddSkip(result);
if (HasUpdate()) { if (HasUpdate()) {
@ -162,7 +165,9 @@ void TopBar::paintEvent(QPaintEvent *e) {
class IntroWidget : public Ui::RpWidget { class IntroWidget : public Ui::RpWidget {
public: public:
IntroWidget(QWidget *parent); IntroWidget(
QWidget *parent,
not_null<Window::Controller*> window);
void forceContentRepaint(); void forceContentRepaint();
@ -184,7 +189,7 @@ private:
void updateControlsGeometry(); void updateControlsGeometry();
QRect contentGeometry() const; QRect contentGeometry() const;
void setInnerWidget(object_ptr<Ui::RpWidget> content); void setInnerWidget(object_ptr<Ui::RpWidget> content);
void showContent(); void showContent(not_null<Window::Controller*> window);
rpl::producer<bool> topShadowToggledValue() const; rpl::producer<bool> topShadowToggledValue() const;
void createTopBar(); void createTopBar();
void applyAdditionalScroll(int additionalScroll); void applyAdditionalScroll(int additionalScroll);
@ -203,7 +208,9 @@ private:
}; };
IntroWidget::IntroWidget(QWidget *parent) IntroWidget::IntroWidget(
QWidget *parent,
not_null<Window::Controller*> window)
: RpWidget(parent) : RpWidget(parent)
, _wrap(this) , _wrap(this)
, _scroll(Ui::CreateChild<Ui::ScrollArea>(_wrap.data(), st::infoScroll)) , _scroll(Ui::CreateChild<Ui::ScrollArea>(_wrap.data(), st::infoScroll))
@ -221,7 +228,7 @@ IntroWidget::IntroWidget(QWidget *parent)
}, lifetime()); }, lifetime());
createTopBar(); createTopBar();
showContent(); showContent(window);
_topShadow->toggleOn( _topShadow->toggleOn(
topShadowToggledValue( topShadowToggledValue(
) | rpl::filter([](bool shown) { ) | rpl::filter([](bool shown) {
@ -316,8 +323,8 @@ rpl::producer<bool> IntroWidget::topShadowToggledValue() const {
) | rpl::map((_1 > 0) || (_2 > 0)); ) | rpl::map((_1 > 0) || (_2 > 0));
} }
void IntroWidget::showContent() { void IntroWidget::showContent(not_null<Window::Controller*> window) {
setInnerWidget(CreateIntroSettings(_scroll)); setInnerWidget(CreateIntroSettings(_scroll, window));
_additionalScroll = 0; _additionalScroll = 0;
updateControlsGeometry(); updateControlsGeometry();
@ -393,8 +400,8 @@ rpl::producer<int> IntroWidget::scrollTillBottomChanges() const {
IntroWidget::~IntroWidget() = default; IntroWidget::~IntroWidget() = default;
LayerWidget::LayerWidget(QWidget*) LayerWidget::LayerWidget(QWidget*, not_null<Window::Controller*> window)
: _content(this) { : _content(this, window) {
setupHeightConsumers(); setupHeightConsumers();
} }

View file

@ -17,13 +17,17 @@ template <typename Widget>
class FadeWrap; class FadeWrap;
} // namespace Ui } // namespace Ui
namespace Window {
class Controller;
} // namespace Window
namespace Settings { namespace Settings {
class IntroWidget; class IntroWidget;
class LayerWidget : public Ui::LayerWidget { class LayerWidget : public Ui::LayerWidget {
public: public:
LayerWidget(QWidget*); LayerWidget(QWidget*, not_null<Window::Controller*> window);
void showFinished() override; void showFinished() override;
void parentResized() override; void parentResized() override;

View file

@ -10,7 +10,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/details/storage_file_utilities.h" #include "storage/details/storage_file_utilities.h"
#include "storage/cache/storage_cache_database.h" #include "storage/cache/storage_cache_database.h"
#include "core/application.h" #include "core/application.h"
#include "main/main_account.h"
#include "storage/serialize_common.h" #include "storage/serialize_common.h"
#include "ui/effects/animation_value.h" #include "ui/effects/animation_value.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
@ -134,8 +133,8 @@ bool ReadSetting(
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
DEBUG_LOG(("MTP Info: user found, dc %1, uid %2").arg(dcId).arg(userId)); DEBUG_LOG(("MTP Info: user found, dc %1, uid %2").arg(dcId).arg(userId));
Core::App().activeAccount().setMtpMainDcId(dcId); context.mtpLegacyMainDcId = dcId;
Core::App().activeAccount().setSessionUserId(userId); context.mtpLegacyUserId = userId;
} break; } break;
case dbiKey: { case dbiKey: {
@ -144,7 +143,10 @@ bool ReadSetting(
auto key = Serialize::read<MTP::AuthKey::Data>(stream); auto key = Serialize::read<MTP::AuthKey::Data>(stream);
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Core::App().activeAccount().setMtpKey(dcId, key); context.mtpLegacyKeys.push_back(std::make_shared<MTP::AuthKey>(
MTP::AuthKey::Type::ReadFromFile,
dcId,
key));
} break; } break;
case dbiMtpAuthorization: { case dbiMtpAuthorization: {
@ -152,7 +154,7 @@ bool ReadSetting(
stream >> serialized; stream >> serialized;
if (!CheckStreamStatus(stream)) return false; if (!CheckStreamStatus(stream)) return false;
Core::App().activeAccount().setMtpAuthorization(serialized); context.mtpAuthorization = serialized;
} break; } break;
case dbiAutoStart: { case dbiAutoStart: {

View file

@ -11,6 +11,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_settings.h" #include "main/main_settings.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
namespace MTP {
class AuthKey;
} // namespace MTP
namespace Storage { namespace Storage {
namespace details { namespace details {
@ -42,6 +46,11 @@ struct ReadSettingsContext {
FileKey languagesKey = 0; FileKey languagesKey = 0;
QByteArray callSettings; QByteArray callSettings;
QByteArray mtpAuthorization;
std::vector<std::shared_ptr<MTP::AuthKey>> mtpLegacyKeys;
qint32 mtpLegacyMainDcId = 0;
qint32 mtpLegacyUserId = 0;
}; };
[[nodiscard]] bool ReadSetting( [[nodiscard]] bool ReadSetting(

View file

@ -906,7 +906,20 @@ std::unique_ptr<Main::Settings> Account::applyReadContext(
_cacheBigFileTotalSizeLimit = context.cacheBigFileTotalSizeLimit; _cacheBigFileTotalSizeLimit = context.cacheBigFileTotalSizeLimit;
_cacheBigFileTotalTimeLimit = context.cacheBigFileTotalTimeLimit; _cacheBigFileTotalTimeLimit = context.cacheBigFileTotalTimeLimit;
deserializeCallSettings(context.callSettings); if (!context.callSettings.isEmpty()) {
deserializeCallSettings(context.callSettings);
}
if (!context.mtpAuthorization.isEmpty()) {
_owner->setMtpAuthorization(context.mtpAuthorization);
} else {
for (auto &key : context.mtpLegacyKeys) {
_owner->setLegacyMtpKey(std::move(key));
}
if (context.mtpLegacyMainDcId) {
_owner->setLegacyMtpMainDcId(context.mtpLegacyMainDcId);
_owner->setSessionUserId(context.mtpLegacyUserId);
}
}
return std::move(context.sessionSettingsStorage); return std::move(context.sessionSettingsStorage);
} }
@ -918,7 +931,7 @@ void Account::writeMtpData() {
return; return;
} }
auto mtpAuthorizationSerialized = Core::App().activeAccount().serializeMtpAuthorization(); auto mtpAuthorizationSerialized = _owner->serializeMtpAuthorization();
quint32 size = sizeof(quint32) + Serialize::bytearraySize(mtpAuthorizationSerialized); quint32 size = sizeof(quint32) + Serialize::bytearraySize(mtpAuthorizationSerialized);

View file

@ -547,7 +547,7 @@ void ChatBackground::start() {
set(Data::ThemeWallPaper()); set(Data::ThemeWallPaper());
} }
Core::App().activeAccount().sessionValue( Core::App().activeAccount().sessionValue( // #TODO multi activeSessionValue
) | rpl::filter([=](Main::Session *session) { ) | rpl::filter([=](Main::Session *session) {
return session != _session; return session != _session;
}) | rpl::start_with_next([=](Main::Session *session) { }) | rpl::start_with_next([=](Main::Session *session) {

View file

@ -74,7 +74,10 @@ void Progress::animationStep() {
class ConnectionState::Widget : public Ui::AbstractButton { class ConnectionState::Widget : public Ui::AbstractButton {
public: public:
Widget(QWidget *parent, const Layout &layout); Widget(
QWidget *parent,
not_null<Main::Account*> account,
const Layout &layout);
void refreshRetryLink(bool hasRetry); void refreshRetryLink(bool hasRetry);
void setLayout(const Layout &layout); void setLayout(const Layout &layout);
@ -201,8 +204,10 @@ bool ConnectionState::State::operator==(const State &other) const {
ConnectionState::ConnectionState( ConnectionState::ConnectionState(
not_null<Ui::RpWidget*> parent, not_null<Ui::RpWidget*> parent,
not_null<Main::Account*> account,
rpl::producer<bool> shown) rpl::producer<bool> shown)
: _parent(parent) : _account(account)
, _parent(parent)
, _refreshTimer([=] { refreshState(); }) , _refreshTimer([=] { refreshState(); })
, _currentLayout(computeLayout(_state)) { , _currentLayout(computeLayout(_state)) {
rpl::combine( rpl::combine(
@ -232,7 +237,7 @@ ConnectionState::ConnectionState(
} }
void ConnectionState::createWidget() { void ConnectionState::createWidget() {
_widget = base::make_unique_q<Widget>(_parent, _currentLayout); _widget = base::make_unique_q<Widget>(_parent, _account, _currentLayout);
_widget->setVisible(!_forceHidden); _widget->setVisible(!_forceHidden);
updateWidth(); updateWidth();
@ -469,14 +474,17 @@ void ConnectionState::updateWidth() {
refreshProgressVisibility(); refreshProgressVisibility();
} }
ConnectionState::Widget::Widget(QWidget *parent, const Layout &layout) ConnectionState::Widget::Widget(
QWidget *parent,
not_null<Main::Account*> account,
const Layout &layout)
: AbstractButton(parent) : AbstractButton(parent)
, _currentLayout(layout) { , _currentLayout(layout) {
_proxyIcon = Ui::CreateChild<ProxyIcon>(this); _proxyIcon = Ui::CreateChild<ProxyIcon>(this);
_progress = Ui::CreateChild<Progress>(this); _progress = Ui::CreateChild<Progress>(this);
addClickHandler([=] { addClickHandler([=] {
Ui::show(ProxiesBoxController::CreateOwningBox()); Ui::show(ProxiesBoxController::CreateOwningBox(account));
}); });
} }

View file

@ -15,12 +15,17 @@ namespace Ui {
class RpWidget; class RpWidget;
} // namespace Ui } // namespace Ui
namespace Main {
class Account;
} // namespace Main
namespace Window { namespace Window {
class ConnectionState : private base::Subscriber { class ConnectionState : private base::Subscriber {
public: public:
ConnectionState( ConnectionState(
not_null<Ui::RpWidget*> parent, not_null<Ui::RpWidget*> parent,
not_null<Main::Account*> account,
rpl::producer<bool> shown); rpl::producer<bool> shown);
void raise(); void raise();
@ -71,6 +76,7 @@ private:
void updateVisibility(); void updateVisibility();
void refreshProgressVisibility(); void refreshProgressVisibility();
const not_null<Main::Account*> _account;
not_null<Ui::RpWidget*> _parent; not_null<Ui::RpWidget*> _parent;
base::unique_qptr<Widget> _widget; base::unique_qptr<Widget> _widget;
bool _forceHidden = false; bool _forceHidden = false;