mirror of
https://github.com/vale981/tdesktop
synced 2025-03-05 17:51:41 -05:00
Change default autodownload settings.
This commit is contained in:
parent
a0c6104fae
commit
71cf4a4885
3 changed files with 16 additions and 22 deletions
|
@ -43,8 +43,6 @@ void AutoDownloadBox::setupContent() {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
using Type = Data::AutoDownload::Type;
|
using Type = Data::AutoDownload::Type;
|
||||||
|
|
||||||
constexpr auto kLegacyLimit = 10 * 1024 * 1024;
|
|
||||||
|
|
||||||
setTitle(langFactory(lng_media_auto_title));
|
setTitle(langFactory(lng_media_auto_title));
|
||||||
|
|
||||||
const auto settings = &Auth().settings().autoDownload();
|
const auto settings = &Auth().settings().autoDownload();
|
||||||
|
|
|
@ -17,8 +17,7 @@ namespace Data {
|
||||||
namespace AutoDownload {
|
namespace AutoDownload {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr auto kDefaultMaxSize = 10 * 1024 * 1024;
|
constexpr auto kDefaultMaxSize = 2 * 1024 * 1024;
|
||||||
constexpr auto kNonCacheMaxSize = 2 * 1024 * 1024;
|
|
||||||
constexpr auto kVersion = char(1);
|
constexpr auto kVersion = char(1);
|
||||||
|
|
||||||
template <typename Enum>
|
template <typename Enum>
|
||||||
|
@ -39,9 +38,12 @@ void SetDefaultsForSource(Full &data, Source source) {
|
||||||
data.setBytesLimit(source, Type::VoiceMessage, kDefaultMaxSize);
|
data.setBytesLimit(source, Type::VoiceMessage, kDefaultMaxSize);
|
||||||
data.setBytesLimit(source, Type::VideoMessage, kDefaultMaxSize);
|
data.setBytesLimit(source, Type::VideoMessage, kDefaultMaxSize);
|
||||||
data.setBytesLimit(source, Type::GIF, kDefaultMaxSize);
|
data.setBytesLimit(source, Type::GIF, kDefaultMaxSize);
|
||||||
data.setBytesLimit(source, Type::File, kNonCacheMaxSize);
|
const auto channelsFileLimit = (source == Source::Channel)
|
||||||
data.setBytesLimit(source, Type::Video, kNonCacheMaxSize);
|
? 0
|
||||||
data.setBytesLimit(source, Type::Music, kNonCacheMaxSize);
|
: kDefaultMaxSize;
|
||||||
|
data.setBytesLimit(source, Type::File, channelsFileLimit);
|
||||||
|
data.setBytesLimit(source, Type::Video, channelsFileLimit);
|
||||||
|
data.setBytesLimit(source, Type::Music, channelsFileLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Full &Defaults() {
|
const Full &Defaults() {
|
||||||
|
|
|
@ -1064,25 +1064,19 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||||
|
|
||||||
using namespace Data::AutoDownload;
|
using namespace Data::AutoDownload;
|
||||||
auto &settings = GetStoredAuthSessionCache().autoDownload();
|
auto &settings = GetStoredAuthSessionCache().autoDownload();
|
||||||
const auto limit = [](qint32 value, qint32 mask) {
|
const auto disabled = [](qint32 value, qint32 mask) {
|
||||||
constexpr auto kLegacyLimit = 10 * 1024 * 1024;
|
return (value & mask) != 0;
|
||||||
return (value & mask) ? 0 : kLegacyLimit;
|
|
||||||
};
|
};
|
||||||
const auto set = [&](Type type, qint32 value) {
|
const auto set = [&](Type type, qint32 value) {
|
||||||
constexpr auto kNoPrivate = qint32(0x01);
|
constexpr auto kNoPrivate = qint32(0x01);
|
||||||
constexpr auto kNoGroups = qint32(0x02);
|
constexpr auto kNoGroups = qint32(0x02);
|
||||||
settings.setBytesLimit(
|
if (disabled(value, kNoPrivate)) {
|
||||||
Source::User,
|
settings.setBytesLimit(Source::User, type, 0);
|
||||||
type,
|
}
|
||||||
limit(value, kNoPrivate));
|
if (disabled(value, kNoGroups)) {
|
||||||
settings.setBytesLimit(
|
settings.setBytesLimit(Source::Group, type, 0);
|
||||||
Source::Group,
|
settings.setBytesLimit(Source::Channel, type, 0);
|
||||||
type,
|
}
|
||||||
limit(value, kNoGroups));
|
|
||||||
settings.setBytesLimit(
|
|
||||||
Source::Channel,
|
|
||||||
type,
|
|
||||||
limit(value, kNoGroups));
|
|
||||||
};
|
};
|
||||||
set(Type::Photo, photo);
|
set(Type::Photo, photo);
|
||||||
set(Type::VoiceMessage, audio);
|
set(Type::VoiceMessage, audio);
|
||||||
|
|
Loading…
Add table
Reference in a new issue