mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 22:55:11 +00:00
[Improvement] Allow smaller cache time limits
This commit is contained in:
committed by
Eric Kotato
parent
357cf3e0f4
commit
802035dde5
@@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
*/
|
*/
|
||||||
#include "boxes/local_storage_box.h"
|
#include "boxes/local_storage_box.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_lang.h"
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
@@ -32,7 +33,7 @@ constexpr auto kMegabyte = int64(1024 * 1024);
|
|||||||
constexpr auto kTotalSizeLimitsCount = 18;
|
constexpr auto kTotalSizeLimitsCount = 18;
|
||||||
constexpr auto kMediaSizeLimitsCount = 18;
|
constexpr auto kMediaSizeLimitsCount = 18;
|
||||||
constexpr auto kMinimalSizeLimit = 100 * kMegabyte;
|
constexpr auto kMinimalSizeLimit = 100 * kMegabyte;
|
||||||
constexpr auto kTimeLimitsCount = 16;
|
constexpr auto kTimeLimitsCount = 22;
|
||||||
constexpr auto kMaxTimeLimitValue = std::numeric_limits<size_type>::max();
|
constexpr auto kMaxTimeLimitValue = std::numeric_limits<size_type>::max();
|
||||||
constexpr auto kFakeMediaCacheTag = uint16(0xFFFF);
|
constexpr auto kFakeMediaCacheTag = uint16(0xFFFF);
|
||||||
|
|
||||||
@@ -93,8 +94,16 @@ size_type TimeLimitInDays(int index) {
|
|||||||
return 0;
|
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) {
|
size_type TimeLimit(int index) {
|
||||||
const auto days = TimeLimitInDays(index);
|
const auto days = TimeLimitInDaysKotato(index);
|
||||||
return days
|
return days
|
||||||
? (days * 24 * 60 * 60)
|
? (days * 24 * 60 * 60)
|
||||||
: kMaxTimeLimitValue;
|
: kMaxTimeLimitValue;
|
||||||
@@ -106,8 +115,10 @@ QString TimeLimitText(size_type limit) {
|
|||||||
const auto months = (days / 29);
|
const auto months = (days / 29);
|
||||||
return (months > 0)
|
return (months > 0)
|
||||||
? tr::lng_months(tr::now, lt_count, months)
|
? tr::lng_months(tr::now, lt_count, months)
|
||||||
: (limit > 0)
|
: (weeks > 0)
|
||||||
? tr::lng_weeks(tr::now, lt_count, weeks)
|
? 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);
|
: tr::lng_local_storage_limit_never(tr::now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user