From 802035dde5a30f8ade51297bf47c0fc431e2acfc Mon Sep 17 00:00:00 2001 From: RadRussianRus Date: Sat, 10 Sep 2022 20:51:05 +0300 Subject: [PATCH] [Improvement] Allow smaller cache time limits --- .../SourceFiles/boxes/local_storage_box.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/boxes/local_storage_box.cpp b/Telegram/SourceFiles/boxes/local_storage_box.cpp index fcdbd8d6d..d22d81a50 100644 --- a/Telegram/SourceFiles/boxes/local_storage_box.cpp +++ b/Telegram/SourceFiles/boxes/local_storage_box.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "boxes/local_storage_box.h" +#include "kotato/kotato_lang.h" #include "boxes/abstract_box.h" #include "ui/wrap/vertical_layout.h" #include "ui/wrap/slide_wrap.h" @@ -32,7 +33,7 @@ constexpr auto kMegabyte = int64(1024 * 1024); constexpr auto kTotalSizeLimitsCount = 18; constexpr auto kMediaSizeLimitsCount = 18; constexpr auto kMinimalSizeLimit = 100 * kMegabyte; -constexpr auto kTimeLimitsCount = 16; +constexpr auto kTimeLimitsCount = 22; constexpr auto kMaxTimeLimitValue = std::numeric_limits::max(); constexpr auto kFakeMediaCacheTag = uint16(0xFFFF); @@ -93,8 +94,16 @@ size_type TimeLimitInDays(int index) { return 0; } +size_type TimeLimitInDaysKotato(int index) { + if (index < 6) { + const auto days = (index + 1); + return size_type(days); + } + return TimeLimitInDays(index - 6); +} + size_type TimeLimit(int index) { - const auto days = TimeLimitInDays(index); + const auto days = TimeLimitInDaysKotato(index); return days ? (days * 24 * 60 * 60) : kMaxTimeLimitValue; @@ -106,8 +115,10 @@ QString TimeLimitText(size_type limit) { const auto months = (days / 29); return (months > 0) ? tr::lng_months(tr::now, lt_count, months) - : (limit > 0) + : (weeks > 0) ? tr::lng_weeks(tr::now, lt_count, weeks) + : (limit > 0) + ? tr::lng_days(tr::now, lt_count, days) : tr::lng_local_storage_limit_never(tr::now); }