mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-03 16:15:13 +00:00
Moved proxy global variables from facades to core settings.
This commit is contained in:
@@ -20,13 +20,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_account.h" // Account::configUpdated.
|
||||
#include "apiwrap.h"
|
||||
#include "core/application.h"
|
||||
#include "core/core_settings.h"
|
||||
#include "lang/lang_instance.h"
|
||||
#include "lang/lang_cloud_manager.h"
|
||||
#include "base/unixtime.h"
|
||||
#include "base/call_delayed.h"
|
||||
#include "base/timer.h"
|
||||
#include "base/network_reachability.h"
|
||||
#include "facades.h" // Proxies list.
|
||||
|
||||
namespace MTP {
|
||||
namespace {
|
||||
@@ -279,6 +279,8 @@ private:
|
||||
|
||||
base::Timer _checkDelayedTimer;
|
||||
|
||||
Core::SettingsProxy &_proxySettings;
|
||||
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
};
|
||||
@@ -299,7 +301,8 @@ Instance::Private::Private(
|
||||
, _instance(instance)
|
||||
, _mode(mode)
|
||||
, _config(std::move(fields.config))
|
||||
, _networkReachability(base::NetworkReachability::Instance()) {
|
||||
, _networkReachability(base::NetworkReachability::Instance())
|
||||
, _proxySettings(Core::App().settings().proxy()) {
|
||||
Expects(_config != nullptr);
|
||||
|
||||
const auto idealThreadPoolSize = QThread::idealThreadCount();
|
||||
@@ -338,6 +341,13 @@ Instance::Private::Private(
|
||||
_mainDcId = fields.mainDcId;
|
||||
_mainDcIdForced = true;
|
||||
}
|
||||
|
||||
_proxySettings.connectionTypeChanges(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (_configLoader) {
|
||||
_configLoader->setProxyEnabled(_proxySettings.isEnabled());
|
||||
}
|
||||
}, _lifetime);
|
||||
}
|
||||
|
||||
void Instance::Private::start() {
|
||||
@@ -397,11 +407,12 @@ void Instance::Private::applyDomainIps(
|
||||
}
|
||||
return true;
|
||||
};
|
||||
for (auto &proxy : Global::RefProxiesList()) {
|
||||
for (auto &proxy : _proxySettings.list()) {
|
||||
applyToProxy(proxy);
|
||||
}
|
||||
if (applyToProxy(Global::RefSelectedProxy())
|
||||
&& (Global::ProxySettings() == ProxyData::Settings::Enabled)) {
|
||||
auto selected = _proxySettings.selected();
|
||||
if (applyToProxy(selected) && _proxySettings.isEnabled()) {
|
||||
_proxySettings.setSelected(selected);
|
||||
for (const auto &[shiftedDcId, session] : _sessions) {
|
||||
session->refreshOptions();
|
||||
}
|
||||
@@ -427,11 +438,13 @@ void Instance::Private::setGoodProxyDomain(
|
||||
}
|
||||
return true;
|
||||
};
|
||||
for (auto &proxy : Global::RefProxiesList()) {
|
||||
for (auto &proxy : _proxySettings.list()) {
|
||||
applyToProxy(proxy);
|
||||
}
|
||||
if (applyToProxy(Global::RefSelectedProxy())
|
||||
&& (Global::ProxySettings() == ProxyData::Settings::Enabled)) {
|
||||
|
||||
auto selected = _proxySettings.selected();
|
||||
if (applyToProxy(selected) && _proxySettings.isEnabled()) {
|
||||
_proxySettings.setSelected(selected);
|
||||
Core::App().refreshGlobalProxy();
|
||||
}
|
||||
}
|
||||
@@ -473,7 +486,8 @@ void Instance::Private::requestConfig() {
|
||||
[=](const MTPConfig &result) { configLoadDone(result); },
|
||||
[=](const Error &error, const Response &) {
|
||||
return configLoadFail(error);
|
||||
});
|
||||
},
|
||||
_proxySettings.isEnabled());
|
||||
_configLoader->load();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user