Add discussion button to profile

This commit is contained in:
Eric Kotato 2019-10-01 02:20:21 +03:00
parent aaa55042aa
commit b4b10609b5
3 changed files with 23 additions and 0 deletions

View file

@ -354,6 +354,21 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
}
addInfoLine(tr::lng_info_about_label(), AboutValue(_peer));
if (const auto channel = _peer->asChannel()) {
const auto controller = _controller->parentController();
auto viewLinkedGroup = [=] {
controller->showPeerHistory(
channel->linkedChat(),
Window::SectionShow::Way::Forward);
};
AddMainButton(
result,
(channel->isBroadcast() ? tr::lng_channel_discuss() : tr::lng_manage_linked_channel()),
HasLinkedChatValue(channel),
std::move(viewLinkedGroup),
tracker);
}
}
if (!_peer->isSelf()) {
// No notifications toggle for Self => no separator.

View file

@ -198,6 +198,13 @@ rpl::producer<bool> CanAddContactValue(not_null<UserData*> user) {
) | rpl::map(!_1);
}
rpl::producer<bool> HasLinkedChatValue(not_null<ChannelData*> channel) {
return Notify::PeerUpdateValue(
channel,
Notify::PeerUpdate::Flag::ChannelLinkedChat
) | rpl::map([channel] { return channel->linkedChat() != nullptr; });
}
rpl::producer<bool> AmInChannelValue(not_null<ChannelData*> channel) {
return Notify::PeerUpdateValue(
channel,

View file

@ -50,6 +50,7 @@ rpl::producer<bool> IsContactValue(not_null<UserData*> user);
rpl::producer<bool> CanInviteBotToGroupValue(not_null<UserData*> user);
rpl::producer<bool> CanShareContactValue(not_null<UserData*> user);
rpl::producer<bool> CanAddContactValue(not_null<UserData*> user);
rpl::producer<bool> HasLinkedChatValue(not_null<ChannelData*> channel);
rpl::producer<bool> AmInChannelValue(not_null<ChannelData*> channel);
rpl::producer<int> MembersCountValue(not_null<PeerData*> peer);
rpl::producer<int> AdminsCountValue(not_null<PeerData*> peer);