[Improvement] Show linked chat/channel button in profile

This commit is contained in:
Eric Kotato 2022-09-11 05:40:56 +03:00
parent abd3dbe0c8
commit 54c40e8cf0
3 changed files with 23 additions and 0 deletions

View file

@ -479,6 +479,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() && !::Kotato::JsonSettings::GetBool("profile_top_mute")) {
// No notifications toggle for Self => no separator.

View file

@ -249,6 +249,13 @@ rpl::producer<bool> CanAddContactValue(not_null<UserData*> user) {
) | rpl::map(!_1);
}
rpl::producer<bool> HasLinkedChatValue(not_null<ChannelData*> channel) {
return channel->session().changes().peerFlagsValue(
channel,
UpdateFlag::ChannelLinkedChat
) | rpl::map([channel] { return channel->linkedChat() != nullptr; });
}
rpl::producer<bool> AmInChannelValue(not_null<ChannelData*> channel) {
return channel->session().changes().peerFlagsValue(
channel,

View file

@ -57,6 +57,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> PendingRequestsCountValue(not_null<PeerData*> peer);