Remove autodownload for GIFs and video messages.

This commit is contained in:
John Preston 2019-12-20 15:56:39 +03:00
parent 7f033c1cc4
commit a8935178a2
4 changed files with 12 additions and 14 deletions

View File

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "data/data_auto_download.h"
#include "ui/widgets/continuous_sliders.h"
#include "ui/widgets/buttons.h"
#include "ui/wrap/vertical_layout.h"
@ -59,15 +60,9 @@ void AutoDownloadBox::setupContent() {
this,
std::move(wrap)));
static const auto kHidden = {
Type::Video,
Type::Music,
Type::VoiceMessage
};
const auto values = Ui::CreateChild<base::flat_map<Type, int>>(content);
const auto add = [&](Type type, rpl::producer<QString> label) {
if (ranges::find(kHidden, type) != end(kHidden)) {
if (ranges::find(kStreamedTypes, type) != end(kStreamedTypes)) {
return;
}
const auto value = settings->bytesLimit(_source, type);
@ -146,6 +141,7 @@ void AutoDownloadBox::setupContent() {
return settings->bytesLimit(_source, type) != value;
}) != end(*values);
const auto &kHidden = kStreamedTypes;
const auto hiddenChanged = ranges::find_if(kHidden, [&](Type type) {
const auto now = settings->bytesLimit(_source, type);
return (now > 0) && (now != *limit);

View File

@ -183,9 +183,7 @@ void Full::setBytesLimit(Source source, Type type, int bytesLimit) {
}
bool Full::shouldDownload(Source source, Type type, int fileSize) const {
if (type == Type::Video
|| type == Type::Music
|| type == Type::VoiceMessage) {
if (ranges::find(kStreamedTypes, type) != end(kStreamedTypes)) {
// With streaming we disable autodownload and hide them in Settings.
return false;
}

View File

@ -36,6 +36,14 @@ enum class Type {
File = 0x06,
};
inline constexpr auto kStreamedTypes = {
Type::Video,
Type::Music,
Type::VoiceMessage,
Type::VideoMessage,
Type::GIF,
};
constexpr auto kTypesCount = 7;
class Single {

View File

@ -247,8 +247,6 @@ void Gif::draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms
if (width() < st::msgPadding.left() + st::msgPadding.right() + 1) return;
const auto item = _parent->data();
//_data->automaticLoad(_realParent->fullId(), item);
//auto loaded = _data->loaded();
auto displayLoading = (item->id < 0) || _data->displayLoading();
auto selected = (selection == FullSelection);
const auto autoPaused = App::wnd()->sessionController()->isGifPausedAtLeastFor(Window::GifPauseReason::Any);
@ -833,8 +831,6 @@ void Gif::drawGrouped(
RectParts corners,
not_null<uint64*> cacheKey,
not_null<QPixmap*> cache) const {
_data->automaticLoad(_realParent->fullId(), _parent->data());
validateGroupedCache(geometry, corners, cacheKey, cache);
const auto selected = (selection == FullSelection);