2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-29 13:47:47 +00:00

[Improvement] Show linked chat/channel button in profile

This commit is contained in:
RadRussianRus 2022-09-11 05:40:56 +03:00 committed by Eric Kotato
parent 92f6a4dce7
commit f7e828a91c
3 changed files with 24 additions and 0 deletions

View File

@ -1325,6 +1325,21 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
if (!_topic) {
addTranslateToMenu(about.text, AboutWithIdValue(_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

@ -413,6 +413,13 @@ rpl::producer<ChannelData*> PersonalChannelValue(not_null<UserData*> user) {
});
}
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

@ -101,6 +101,8 @@ struct LinkWithUrl {
not_null<UserData*> user);
[[nodiscard]] rpl::producer<ChannelData*> PersonalChannelValue(
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);