Files
AyuGramDesktop/Telegram/SourceFiles/ui/rows_scroll_cache.cpp
T
2026-07-15 13:11:47 +04:00

43 lines
864 B
C++

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "ui/rows_scroll_cache.h"
namespace Ui {
namespace {
constexpr auto kStopTimeout = crl::time(120);
} // namespace
RowsScrollCache::RowsScrollCache(Fn<void()> stopped) {
_stopTimer.setCallback([=] {
_scrolling = false;
clear();
stopped();
});
}
void RowsScrollCache::markScrolling() {
_scrolling = true;
_stopTimer.callOnce(kStopTimeout);
}
void RowsScrollCache::invalidate(uint64 rowId) {
if (const auto i = _images.find(rowId); i != end(_images)) {
_memory -= i->second.sizeInBytes();
_images.erase(i);
}
}
void RowsScrollCache::clear() {
_images.clear();
_memory = 0;
}
} // namespace Ui