mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Rebuild sets without restarting thumbnails.
This commit is contained in:
parent
38ee57f852
commit
d413080f83
1 changed files with 52 additions and 13 deletions
|
@ -247,6 +247,7 @@ private:
|
||||||
int32 _rowHeight;
|
int32 _rowHeight;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Row>> _rows;
|
std::vector<std::unique_ptr<Row>> _rows;
|
||||||
|
std::vector<std::unique_ptr<Row>> _oldRows;
|
||||||
std::vector<crl::time> _shiftingStartTimes;
|
std::vector<crl::time> _shiftingStartTimes;
|
||||||
crl::time _aboveShadowFadeStart = 0;
|
crl::time _aboveShadowFadeStart = 0;
|
||||||
anim::value _aboveShadowFadeOpacity;
|
anim::value _aboveShadowFadeOpacity;
|
||||||
|
@ -1993,6 +1994,7 @@ void StickersBox::Inner::rebuild(bool masks) {
|
||||||
|
|
||||||
auto maxNameWidth = countMaxNameWidth();
|
auto maxNameWidth = countMaxNameWidth();
|
||||||
|
|
||||||
|
_oldRows = std::move(_rows);
|
||||||
clear();
|
clear();
|
||||||
const auto &order = ([&]() -> const StickersSetsOrder & {
|
const auto &order = ([&]() -> const StickersSetsOrder & {
|
||||||
if (_section == Section::Installed) {
|
if (_section == Section::Installed) {
|
||||||
|
@ -2044,6 +2046,7 @@ void StickersBox::Inner::rebuild(bool masks) {
|
||||||
set->accessHash);
|
set->accessHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_oldRows.clear();
|
||||||
session().api().requestStickerSets();
|
session().api().requestStickerSets();
|
||||||
updateSize();
|
updateSize();
|
||||||
}
|
}
|
||||||
|
@ -2156,19 +2159,55 @@ void StickersBox::Inner::rebuildAppendSet(
|
||||||
QString title = fillSetTitle(set, maxNameWidth, &titleWidth);
|
QString title = fillSetTitle(set, maxNameWidth, &titleWidth);
|
||||||
int count = fillSetCount(set);
|
int count = fillSetCount(set);
|
||||||
|
|
||||||
_rows.push_back(std::make_unique<Row>(
|
const auto existing = [&]{
|
||||||
set,
|
const auto now = int(_rows.size());
|
||||||
sticker,
|
const auto setProj = [](const std::unique_ptr<Row> &row) {
|
||||||
count,
|
return row ? row->set.get() : nullptr;
|
||||||
title,
|
};
|
||||||
titleWidth,
|
if (_oldRows.size() > now
|
||||||
installed,
|
&& setProj(_oldRows[now]) == set.get()) {
|
||||||
official,
|
return _oldRows.begin() + now;
|
||||||
unread,
|
}
|
||||||
archived,
|
return ranges::find(_oldRows, set.get(), setProj);
|
||||||
removed,
|
}();
|
||||||
pixw,
|
if (existing != end(_oldRows)) {
|
||||||
pixh));
|
const auto raw = existing->get();
|
||||||
|
raw->sticker = sticker;
|
||||||
|
raw->count = count;
|
||||||
|
raw->title = title;
|
||||||
|
raw->titleWidth = titleWidth;
|
||||||
|
raw->installed = installed;
|
||||||
|
raw->official = official;
|
||||||
|
raw->unread = unread;
|
||||||
|
raw->archived = archived;
|
||||||
|
raw->removed = removed;
|
||||||
|
raw->pixw = pixw;
|
||||||
|
raw->pixh = pixh;
|
||||||
|
raw->yadd = {};
|
||||||
|
auto oldStickerMedia = std::move(raw->stickerMedia);
|
||||||
|
auto oldThumbnailMedia = std::move(raw->thumbnailMedia);
|
||||||
|
raw->stickerMedia = sticker->activeMediaView();
|
||||||
|
raw->thumbnailMedia = set->activeThumbnailView();
|
||||||
|
if (raw->thumbnailMedia != oldThumbnailMedia
|
||||||
|
|| (!raw->thumbnailMedia && raw->stickerMedia != oldStickerMedia)) {
|
||||||
|
raw->lottie = nullptr;
|
||||||
|
}
|
||||||
|
_rows.push_back(std::move(*existing));
|
||||||
|
} else {
|
||||||
|
_rows.push_back(std::make_unique<Row>(
|
||||||
|
set,
|
||||||
|
sticker,
|
||||||
|
count,
|
||||||
|
title,
|
||||||
|
titleWidth,
|
||||||
|
installed,
|
||||||
|
official,
|
||||||
|
unread,
|
||||||
|
archived,
|
||||||
|
removed,
|
||||||
|
pixw,
|
||||||
|
pixh));
|
||||||
|
}
|
||||||
_shiftingStartTimes.push_back(0);
|
_shiftingStartTimes.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue