| 531 | } |
| 532 | |
| 533 | void 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 |
nothing calls this directly
no test coverage detected