Make links clickable in channel descriptions.

This commit is contained in:
John Preston 2017-11-17 11:42:53 +04:00
parent 41873412e7
commit 747ebd2136
1 changed files with 21 additions and 14 deletions

View File

@ -80,29 +80,36 @@ rpl::producer<TextWithEntities> UsernameValue(
| WithEmptyEntities(); | WithEmptyEntities();
} }
rpl::producer<TextWithEntities> AboutValue( rpl::producer<QString> PlainAboutValue(
not_null<PeerData*> peer) { not_null<PeerData*> peer) {
if (auto channel = peer->asChannel()) { if (auto channel = peer->asChannel()) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Notify::PeerUpdate::Flag::AboutChanged) Notify::PeerUpdate::Flag::AboutChanged)
| rpl::map([channel] { return channel->about(); }) | rpl::map([channel] { return channel->about(); });
| WithEmptyEntities();
} else if (auto user = peer->asUser()) { } else if (auto user = peer->asUser()) {
if (user->botInfo) { if (user->botInfo) {
return PlainBioValue(user) return PlainBioValue(user);
| WithEmptyEntities()
| rpl::map([](TextWithEntities &&text) {
auto flags = TextParseLinks
| TextParseMentions
| TextParseHashtags
| TextParseBotCommands;
TextUtilities::ParseEntities(text, flags);
return std::move(text);
});
} }
} }
return rpl::single(TextWithEntities{}); return rpl::single(QString());
}
rpl::producer<TextWithEntities> AboutValue(
not_null<PeerData*> peer) {
auto flags = TextParseLinks
| TextParseMentions
| TextParseHashtags;
if (peer->isUser()) {
flags |= TextParseBotCommands;
}
return PlainAboutValue(peer)
| WithEmptyEntities()
| rpl::map([=](TextWithEntities &&text) {
TextUtilities::ParseEntities(text, flags);
return std::move(text);
});
} }
rpl::producer<QString> LinkValue( rpl::producer<QString> LinkValue(