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( auto linkText = LinkValue(
_peer, _peer,
true true
) | rpl::map([=](const QString &link) { ) | rpl::map([=](const LinkWithUrl &link) {
return link.isEmpty() const auto text = link.text;
return text.isEmpty()
? TextWithEntities() ? TextWithEntities()
: Ui::Text::Link( : Ui::Text::Link(
(link.startsWith(u"https://"_q) (text.startsWith(u"https://"_q)
? link.mid(u"https://"_q.size()) ? text.mid(u"https://"_q.size())
: link) + addToLink, : text) + addToLink,
link + addToLink); (addToLink.isEmpty() ? link.url : (text + addToLink)));
}); });
auto linkLine = addInfoOneLine( auto linkLine = addInfoOneLine(
(topicRootId (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 return (primary
? PlainPrimaryUsernameValue(peer) ? PlainPrimaryUsernameValue(peer)
: PlainUsernameValue(peer) | rpl::type_erased() : PlainUsernameValue(peer) | rpl::type_erased()
) | rpl::map([=](QString &&username) { ) | 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); const QString &value);
[[nodiscard]] rpl::producer<TextWithEntities> AboutValue( [[nodiscard]] rpl::producer<TextWithEntities> AboutValue(
not_null<PeerData*> peer); not_null<PeerData*> peer);
[[nodiscard]] rpl::producer<QString> LinkValue(
struct LinkWithUrl {
QString text;
QString url;
};
[[nodiscard]] rpl::producer<LinkWithUrl> LinkValue(
not_null<PeerData*> peer, not_null<PeerData*> peer,
bool primary = false); bool primary = false);
[[nodiscard]] rpl::producer<const ChannelLocation*> LocationValue( [[nodiscard]] rpl::producer<const ChannelLocation*> LocationValue(
not_null<ChannelData*> channel); not_null<ChannelData*> channel);
[[nodiscard]] rpl::producer<bool> NotificationsEnabledValue( [[nodiscard]] rpl::producer<bool> NotificationsEnabledValue(