Fix collectible channel links.

This commit is contained in:
John Preston 2024-04-04 17:45:15 +04:00
parent b31d43cbed
commit 9464f4b095
3 changed files with 23 additions and 9 deletions

View file

@ -1147,14 +1147,15 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
auto linkText = LinkValue(
_peer,
true
) | rpl::map([=](const QString &link) {
return link.isEmpty()
) | rpl::map([=](const LinkWithUrl &link) {
const auto text = link.text;
return text.isEmpty()
? TextWithEntities()
: Ui::Text::Link(
(link.startsWith(u"https://"_q)
? link.mid(u"https://"_q.size())
: link) + addToLink,
link + addToLink);
(text.startsWith(u"https://"_q)
? text.mid(u"https://"_q.size())
: text) + addToLink,
(addToLink.isEmpty() ? link.url : (text + addToLink)));
});
auto linkLine = addInfoOneLine(
(topicRootId

View file

@ -232,12 +232,19 @@ rpl::producer<TextWithEntities> AboutValue(not_null<PeerData*> peer) {
});
}
rpl::producer<QString> LinkValue(not_null<PeerData*> peer, bool primary) {
rpl::producer<LinkWithUrl> LinkValue(not_null<PeerData*> peer, bool primary) {
return (primary
? PlainPrimaryUsernameValue(peer)
: PlainUsernameValue(peer) | rpl::type_erased()
) | rpl::map([=](QString &&username) {
return username.isEmpty() ? QString() : UsernameUrl(peer, username);
return LinkWithUrl{
.text = (username.isEmpty()
? QString()
: peer->session().createInternalLinkFull(username)),
.url = (username.isEmpty()
? QString()
: UsernameUrl(peer, username)),
};
});
}

View file

@ -69,9 +69,15 @@ rpl::producer<not_null<PeerData*>> MigratedOrMeValue(
const QString &value);
[[nodiscard]] rpl::producer<TextWithEntities> AboutValue(
not_null<PeerData*> peer);
[[nodiscard]] rpl::producer<QString> LinkValue(
struct LinkWithUrl {
QString text;
QString url;
};
[[nodiscard]] rpl::producer<LinkWithUrl> LinkValue(
not_null<PeerData*> peer,
bool primary = false);
[[nodiscard]] rpl::producer<const ChannelLocation*> LocationValue(
not_null<ChannelData*> channel);
[[nodiscard]] rpl::producer<bool> NotificationsEnabledValue(