MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / updatePapers

Method updatePapers

Telegram/SourceFiles/boxes/background_box.cpp:533–589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

531}
532
533void BackgroundBox::Inner::updatePapers() {
534 if (forChannel()) {
535 if (_session->data().cloudThemes().chatThemes().empty()) {
536 return;
537 }
538 } else {
539 if (_session->data().wallpapers().empty()) {
540 return;
541 }
542 }
543 _over = _overDown = Selection();
544
545 const auto was = base::take(_papers);
546 if (forChannel()) {
547 const auto now = _forPeer->wallPaper();
548 const auto &list = _session->data().cloudThemes().chatThemes();
549 if (list.empty()) {
550 return;
551 }
552 using Type = Data::CloudThemeType;
553 const auto type = Window::Theme::IsNightMode()
554 ? Type::Dark
555 : Type::Light;
556 _papers.reserve(list.size() + 1);
557 const auto nowEmojiId = now ? now->emojiId() : QString();
558 if (!now || !now->emojiId().isEmpty()) {
559 _papers.push_back({ Window::Theme::Background()->paper() });
560 _currentId = _papers.back().data.id();
561 } else {
562 _papers.push_back({ *now });
563 _currentId = now->id();
564 }
565 for (const auto &theme : list) {
566 const auto i = theme.settings.find(type);
567 if (i != end(theme.settings) && i->second.paper) {
568 _papers.push_back({ *i->second.paper });
569 if (nowEmojiId == theme.emoticon) {
570 _currentId = _papers.back().data.id();
571 }
572 }
573 }
574 } else {
575 _papers = _session->data().wallpapers(
576 ) | ranges::views::filter([&](const Data::WallPaper &paper) {
577 return (!paper.isPattern() || !paper.backgroundColors().empty())
578 && (!_forPeer
579 || (!Data::IsDefaultWallPaper(paper)
580 && (Data::IsCloudWallPaper(paper)
581 || Data::IsCustomWallPaper(paper))));
582 }) | ranges::views::transform([](const Data::WallPaper &paper) {
583 return Paper{ paper };
584 }) | ranges::to_vector;
585 pushCustomPapers();
586 sortPapers();
587 }
588 resizeToContentAndPreload();
589}
590

Callers

nothing calls this directly

Calls 15

IsDefaultWallPaperFunction · 0.85
IsCloudWallPaperFunction · 0.85
IsCustomWallPaperFunction · 0.85
wallPaperMethod · 0.80
emojiIdMethod · 0.80
paperMethod · 0.80
isPatternMethod · 0.80
backgroundColorsMethod · 0.80
SelectionClass · 0.70
IsNightModeFunction · 0.50
QStringClass · 0.50
BackgroundFunction · 0.50

Tested by

no test coverage detected