Watch for network availability changes
This commit is contained in:
parent
df73bda1ff
commit
3343880ed0
|
@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
#include "base/network_reachability.h"
|
||||||
#include "facades.h" // Proxies list.
|
#include "facades.h" // Proxies list.
|
||||||
|
|
||||||
namespace MTP {
|
namespace MTP {
|
||||||
|
@ -216,6 +217,7 @@ private:
|
||||||
const not_null<Instance*> _instance;
|
const not_null<Instance*> _instance;
|
||||||
const Instance::Mode _mode = Instance::Mode::Normal;
|
const Instance::Mode _mode = Instance::Mode::Normal;
|
||||||
const std::unique_ptr<Config> _config;
|
const std::unique_ptr<Config> _config;
|
||||||
|
const std::shared_ptr<base::NetworkReachability> _networkReachability;
|
||||||
|
|
||||||
std::unique_ptr<QThread> _mainSessionThread;
|
std::unique_ptr<QThread> _mainSessionThread;
|
||||||
std::unique_ptr<QThread> _otherSessionsThread;
|
std::unique_ptr<QThread> _otherSessionsThread;
|
||||||
|
@ -296,7 +298,8 @@ Instance::Private::Private(
|
||||||
: Sender(instance)
|
: Sender(instance)
|
||||||
, _instance(instance)
|
, _instance(instance)
|
||||||
, _mode(mode)
|
, _mode(mode)
|
||||||
, _config(std::move(fields.config)) {
|
, _config(std::move(fields.config))
|
||||||
|
, _networkReachability(base::NetworkReachability::Instance()) {
|
||||||
Expects(_config != nullptr);
|
Expects(_config != nullptr);
|
||||||
|
|
||||||
const auto idealThreadPoolSize = QThread::idealThreadCount();
|
const auto idealThreadPoolSize = QThread::idealThreadCount();
|
||||||
|
@ -307,6 +310,11 @@ Instance::Private::Private(
|
||||||
unpaused();
|
unpaused();
|
||||||
}, _lifetime);
|
}, _lifetime);
|
||||||
|
|
||||||
|
_networkReachability->availableChanges(
|
||||||
|
) | rpl::start_with_next([=](bool available) {
|
||||||
|
restart();
|
||||||
|
}, _lifetime);
|
||||||
|
|
||||||
_deviceModel = std::move(fields.deviceModel);
|
_deviceModel = std::move(fields.deviceModel);
|
||||||
_systemVersion = std::move(fields.systemVersion);
|
_systemVersion = std::move(fields.systemVersion);
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2d51534213cf14fc816eca84f06765704a3b45d7
|
Subproject commit 8f0c0164cdce6bcbc7bcfe531963e2a552f6290d
|
Loading…
Reference in New Issue