SavedMusic not participating in profile sections.

This commit is contained in:
John Preston
2026-05-26 10:50:23 +04:00
parent e9a0df4715
commit 0bfd2bd0d5
3 changed files with 14 additions and 57 deletions
@@ -53,31 +53,24 @@ namespace Profile {
namespace {
[[nodiscard]] Section MakeSavedMusicSection(
not_null<QWidget*> parent,
void AddSavedMusic(
not_null<Ui::VerticalLayout*> layout,
not_null<Controller*> controller,
not_null<PeerData*> peer,
rpl::producer<std::optional<QColor>> topBarColor) {
auto wrap = object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
parent,
object_ptr<Ui::VerticalLayout>(parent));
const auto raw = wrap.data();
const auto wrap = layout->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
layout,
object_ptr<Ui::VerticalLayout>(layout)));
Info::Saved::SetupSavedMusic(
raw->entity(),
wrap->entity(),
controller,
peer,
std::move(topBarColor));
using namespace rpl::mappers;
raw->toggleOn(
raw->entity()->heightValue() | rpl::map(_1 > 0),
wrap->toggleOn(
wrap->entity()->heightValue() | rpl::map(_1 > 0),
anim::type::instant);
return Section{
.widget = std::move(wrap),
.shown = raw->toggledValue(),
.trailing = SectionSeparator::None(),
.embedsLeadingSeparator = false,
.attachesToCover = true,
};
}
[[nodiscard]] Section MakeSecurityRiskWarningSection(
@@ -243,16 +236,17 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
}
auto result = object_ptr<Ui::VerticalLayout>(parent);
auto stack = SectionStack(result.data());
const auto musicPeer = _sublist
? _sublist->sublistPeer().get()
: _peer.get();
stack.add(MakeSavedMusicSection(
AddSavedMusic(
result.data(),
_controller,
musicPeer,
_topBarColor.value()));
_topBarColor.value());
auto stack = SectionStack(result.data());
if (const auto user = _peer->asUser()) {
stack.add(MakeSecurityRiskWarningSection(result.data(), user));
}
@@ -154,33 +154,6 @@ rpl::producer<bool> SectionStack::nextVisibleIsNonEmbedding(
}) | rpl::distinct_until_changed();
}
rpl::producer<bool> SectionStack::firstVisibleAttachesToCover() const {
if (_sections.empty()) {
return rpl::single(false);
}
auto producers = std::vector<rpl::producer<bool>>();
auto attaches = std::vector<bool>();
producers.reserve(_sections.size());
attaches.reserve(_sections.size());
for (auto j = 0; j != int(_sections.size()); ++j) {
producers.push_back(_sections[j].shown
? rpl::duplicate(_sections[j].shown)
: rpl::single(true));
attaches.push_back(_sections[j].attachesToCover);
}
return rpl::combine(
std::move(producers),
[attaches = std::move(attaches)](
const std::vector<bool> &values) -> bool {
for (auto k = 0; k != int(values.size()); ++k) {
if (values[k]) {
return attaches[k];
}
}
return false;
}) | rpl::distinct_until_changed();
}
rpl::producer<bool> SectionStack::computePlainMarkerCandidate(
int position) const {
auto upper = anyShownAtOrBefore(position);
@@ -275,15 +248,7 @@ void SectionStack::finalize() {
}
}
auto leadingInner = object_ptr<Ui::VerticalLayout>(_layout);
Ui::AddSkip(leadingInner.data(), st::infoProfileSkip);
const auto leadingWrap = _layout->add(
object_ptr<Ui::SlideWrap<Ui::VerticalLayout>>(
_layout,
std::move(leadingInner)));
leadingWrap->setDuration(st::infoSlideDuration)->toggleOn(
firstVisibleAttachesToCover()
| rpl::map([](bool a) { return !a; }));
Ui::AddSkip(_layout, st::infoProfileSkip);
const auto sectionCount = int(_sections.size());
const auto markerCandidates = _layout->lifetime().make_state<
@@ -36,7 +36,6 @@ struct Section {
rpl::producer<bool> shown;
SectionSeparator trailing;
bool embedsLeadingSeparator = false;
bool attachesToCover = false;
};
class SectionStack final {
@@ -58,7 +57,6 @@ private:
[[nodiscard]] rpl::producer<bool> anyShownInRange(
int from,
int toInclusive) const;
[[nodiscard]] rpl::producer<bool> firstVisibleAttachesToCover() const;
[[nodiscard]] rpl::producer<bool> computePlainMarkerCandidate(
int position) const;
void addPlainMarkerSlot(