[Improvement] Show linked chat/channel button in profile
This commit is contained in:
		
							parent
							
								
									a230d00aab
								
							
						
					
					
						commit
						71b51bb0af
					
				
					 3 changed files with 24 additions and 0 deletions
				
			
		|  | @ -1325,6 +1325,21 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() { | ||||||
| 		if (!_topic) { | 		if (!_topic) { | ||||||
| 			addTranslateToMenu(about.text, AboutWithIdValue(_peer)); | 			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")) { | 	if (!_peer->isSelf() && !::Kotato::JsonSettings::GetBool("profile_top_mute")) { | ||||||
| 		// No notifications toggle for Self => no separator.
 | 		// No notifications toggle for Self => no separator.
 | ||||||
|  |  | ||||||
|  | @ -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) { | rpl::producer<bool> AmInChannelValue(not_null<ChannelData*> channel) { | ||||||
| 	return channel->session().changes().peerFlagsValue( | 	return channel->session().changes().peerFlagsValue( | ||||||
| 		channel, | 		channel, | ||||||
|  |  | ||||||
|  | @ -101,6 +101,8 @@ struct LinkWithUrl { | ||||||
| 	not_null<UserData*> user); | 	not_null<UserData*> user); | ||||||
| [[nodiscard]] rpl::producer<ChannelData*> PersonalChannelValue( | [[nodiscard]] rpl::producer<ChannelData*> PersonalChannelValue( | ||||||
| 	not_null<UserData*> user); | 	not_null<UserData*> user); | ||||||
|  | [[nodiscard]] rpl::producer<bool> HasLinkedChatValue( | ||||||
|  | 	not_null<ChannelData*> channel); | ||||||
| [[nodiscard]] rpl::producer<bool> AmInChannelValue( | [[nodiscard]] rpl::producer<bool> AmInChannelValue( | ||||||
| 	not_null<ChannelData*> channel); | 	not_null<ChannelData*> channel); | ||||||
| [[nodiscard]] rpl::producer<int> MembersCountValue(not_null<PeerData*> peer); | [[nodiscard]] rpl::producer<int> MembersCountValue(not_null<PeerData*> peer); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue