mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add personal channel to ShortInfoBox.
This commit is contained in:
parent
fabdd89c4a
commit
4001899bdf
3 changed files with 27 additions and 0 deletions
|
@ -775,6 +775,10 @@ void PeerShortInfoBox::prepareRows() {
|
||||||
result->setContextCopyText(contextCopyText);
|
result->setContextCopyText(contextCopyText);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
addInfoOneLine(
|
||||||
|
tr::lng_settings_channel_label(),
|
||||||
|
channelValue(),
|
||||||
|
tr::lng_context_copy_link(tr::now));
|
||||||
addInfoOneLine(
|
addInfoOneLine(
|
||||||
tr::lng_info_link_label(),
|
tr::lng_info_link_label(),
|
||||||
linkValue(),
|
linkValue(),
|
||||||
|
@ -836,6 +840,13 @@ rpl::producer<QString> PeerShortInfoBox::nameValue() const {
|
||||||
}) | rpl::distinct_until_changed();
|
}) | rpl::distinct_until_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<TextWithEntities> PeerShortInfoBox::channelValue() const {
|
||||||
|
return _fields.value(
|
||||||
|
) | rpl::map([](const PeerShortInfoFields &fields) {
|
||||||
|
return Ui::Text::Link(fields.channelName, fields.channelLink);
|
||||||
|
}) | rpl::distinct_until_changed();
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> PeerShortInfoBox::linkValue() const {
|
rpl::producer<TextWithEntities> PeerShortInfoBox::linkValue() const {
|
||||||
return _fields.value(
|
return _fields.value(
|
||||||
) | rpl::map([](const PeerShortInfoFields &fields) {
|
) | rpl::map([](const PeerShortInfoFields &fields) {
|
||||||
|
|
|
@ -37,6 +37,8 @@ enum class PeerShortInfoType {
|
||||||
|
|
||||||
struct PeerShortInfoFields {
|
struct PeerShortInfoFields {
|
||||||
QString name;
|
QString name;
|
||||||
|
QString channelName;
|
||||||
|
QString channelLink;
|
||||||
QString phone;
|
QString phone;
|
||||||
QString link;
|
QString link;
|
||||||
TextWithEntities about;
|
TextWithEntities about;
|
||||||
|
@ -169,6 +171,7 @@ private:
|
||||||
int fillRoundedTopHeight();
|
int fillRoundedTopHeight();
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<QString> nameValue() const;
|
[[nodiscard]] rpl::producer<QString> nameValue() const;
|
||||||
|
[[nodiscard]] rpl::producer<TextWithEntities> channelValue() const;
|
||||||
[[nodiscard]] rpl::producer<TextWithEntities> linkValue() const;
|
[[nodiscard]] rpl::producer<TextWithEntities> linkValue() const;
|
||||||
[[nodiscard]] rpl::producer<QString> phoneValue() const;
|
[[nodiscard]] rpl::producer<QString> phoneValue() const;
|
||||||
[[nodiscard]] rpl::producer<QString> usernameValue() const;
|
[[nodiscard]] rpl::producer<QString> usernameValue() const;
|
||||||
|
|
|
@ -202,6 +202,7 @@ void ProcessFullPhoto(
|
||||||
return peer->session().changes().peerFlagsValue(
|
return peer->session().changes().peerFlagsValue(
|
||||||
peer,
|
peer,
|
||||||
(UpdateFlag::Name
|
(UpdateFlag::Name
|
||||||
|
| UpdateFlag::PersonalChannel
|
||||||
| UpdateFlag::PhoneNumber
|
| UpdateFlag::PhoneNumber
|
||||||
| UpdateFlag::Username
|
| UpdateFlag::Username
|
||||||
| UpdateFlag::About
|
| UpdateFlag::About
|
||||||
|
@ -209,8 +210,20 @@ void ProcessFullPhoto(
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
const auto user = peer->asUser();
|
const auto user = peer->asUser();
|
||||||
const auto username = peer->username();
|
const auto username = peer->username();
|
||||||
|
const auto channelId = user->personalChannelId();
|
||||||
|
const auto channel = channelId
|
||||||
|
? user->owner().channel(channelId).get()
|
||||||
|
: nullptr;
|
||||||
|
const auto channelUsername = channel
|
||||||
|
? channel->username()
|
||||||
|
: QString();
|
||||||
|
const auto hasChannel = !channelUsername.isEmpty();
|
||||||
return PeerShortInfoFields{
|
return PeerShortInfoFields{
|
||||||
.name = peer->name(),
|
.name = peer->name(),
|
||||||
|
.channelName = hasChannel ? channel->name() : QString(),
|
||||||
|
.channelLink = (hasChannel
|
||||||
|
? channel->session().createInternalLinkFull(channelUsername)
|
||||||
|
: QString()),
|
||||||
.phone = user ? Ui::FormatPhone(user->phone()) : QString(),
|
.phone = user ? Ui::FormatPhone(user->phone()) : QString(),
|
||||||
.link = ((user || username.isEmpty())
|
.link = ((user || username.isEmpty())
|
||||||
? QString()
|
? QString()
|
||||||
|
|
Loading…
Add table
Reference in a new issue