[Improvement] Show linked chat/channel button in profile
This commit is contained in:
parent
7e75326518
commit
c08798b64b
3 changed files with 24 additions and 0 deletions
|
|
@ -656,6 +656,21 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
if (!_topic) {
|
||||
addTranslateToMenu(about.text, 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.
|
||||
|
|
|
|||
|
|
@ -377,6 +377,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,
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@ QString IDString(not_null<PeerData*> peer);
|
|||
not_null<UserData*> user);
|
||||
[[nodiscard]] rpl::producer<bool> CanAddContactValue(
|
||||
not_null<UserData*> user);
|
||||
[[nodiscard]] rpl::producer<bool> HasLinkedChatValue(
|
||||
not_null<ChannelData*> channel);
|
||||
[[nodiscard]] rpl::producer<bool> AmInChannelValue(
|
||||
not_null<ChannelData*> channel);
|
||||
[[nodiscard]] rpl::producer<int> MembersCountValue(not_null<PeerData*> peer);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue