mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Implement nice Cocoon about box.
This commit is contained in:
@@ -354,10 +354,37 @@ not_null<DocumentData*> GenerateLocalSticker(
|
||||
not_null<DocumentData*> GenerateLocalTgsSticker(
|
||||
not_null<Main::Session*> session,
|
||||
const QString &name) {
|
||||
const auto cache = [&] {
|
||||
struct Session {
|
||||
base::weak_ptr<Main::Session> session;
|
||||
base::flat_map<QString, not_null<DocumentData*>> cache;
|
||||
};
|
||||
static auto Map = std::vector<Session>();
|
||||
for (auto i = begin(Map); i != end(Map);) {
|
||||
if (const auto strong = i->session.get()) {
|
||||
if (strong == session) {
|
||||
return &i->cache;
|
||||
}
|
||||
++i;
|
||||
} else {
|
||||
i = Map.erase(i);
|
||||
}
|
||||
}
|
||||
Map.push_back({ .session = session });
|
||||
return &Map.back().cache;
|
||||
}();
|
||||
|
||||
const auto i = cache->find(name);
|
||||
if (i != end(*cache)) {
|
||||
return i->second;
|
||||
}
|
||||
|
||||
const auto result = GenerateLocalSticker(
|
||||
session,
|
||||
u":/animations/"_q + name + u".tgs"_q);
|
||||
|
||||
cache->emplace(name, result);
|
||||
|
||||
Ensures(result->sticker()->isLottie());
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user