2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Don't unload all media on switching between chats.

This commit is contained in:
John Preston
2018-10-23 16:57:43 +04:00
parent 959859f57c
commit 8e7117fa22
21 changed files with 61 additions and 83 deletions

View File

@@ -34,7 +34,7 @@ constexpr auto kMemoryForCache = 32 * 1024 * 1024;
Core::MediaActiveCache<DocumentData> &ActiveCache() {
static auto Instance = Core::MediaActiveCache<DocumentData>(
kMemoryForCache,
[](DocumentData *document) { document->forget(); });
[](DocumentData *document) { document->unload(); });
return Instance;
}
@@ -536,7 +536,9 @@ bool DocumentData::saveToCache() const {
|| (isVoiceMessage() && size < Storage::kMaxVoiceInMemory);
}
void DocumentData::forget() {
void DocumentData::unload() {
// Forget thumb only when image cache limit exceeds.
//thumb->unload();
if (sticker()) {
if (!sticker()->img->isNull()) {
ActiveCache().decrement(ComputeUsage(sticker()));
@@ -551,6 +553,7 @@ void DocumentData::forget() {
delete replyPreview.get();
replyPreview = ImagePtr();
}
ActiveCache().decrement(_data.size());
_data.clear();
}