diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index eec2f1233e..60a3e0bc3c 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -277,8 +277,9 @@ object_ptr EditLinkedChatBox( not_null channel, ChannelData *chat, std::vector> &&chats, + bool canEdit, Fn callback) { - Expects(channel->isBroadcast() || (chat != nullptr)); + Expects((channel->isBroadcast() && canEdit) || (chat != nullptr)); const auto init = [=](not_null box) { auto above = object_ptr(box); @@ -291,7 +292,7 @@ object_ptr EditLinkedChatBox( box->peerListSetAboveWidget(std::move(above)); auto below = object_ptr(box); - if (chat) { + if (chat && canEdit) { below->add(SetupUnlink(below, channel, callback)); } below->add( @@ -318,12 +319,18 @@ object_ptr EditLinkedChatBox( not_null channel, std::vector> &&chats, Fn callback) { - return EditLinkedChatBox(channel, nullptr, std::move(chats), callback); + return EditLinkedChatBox( + channel, + nullptr, + std::move(chats), + true, + callback); } object_ptr EditLinkedChatBox( not_null channel, not_null chat, + bool canEdit, Fn callback) { - return EditLinkedChatBox(channel, chat, {}, callback); + return EditLinkedChatBox(channel, chat, {}, canEdit, callback); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h index 0962dfddab..7ecd70f618 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL object_ptr EditLinkedChatBox( not_null channel, not_null chat, + bool canEdit, Fn callback); object_ptr EditLinkedChatBox( diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 659f62ee96..023ce38526 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -524,12 +524,19 @@ void Controller::showEditLinkedChatBox() { _linkedChatUpdates.fire_copy(result); refreshHistoryVisibility(); }; + const auto canEdit = channel->isBroadcast() + ? channel->canEditInformation() + : (channel->canPinMessages() + && (channel->amCreator() || channel->adminRights() != 0) + && (!channel->hiddenPreHistory() + || channel->canEditPreHistoryHidden())); + if (const auto chat = *_linkedChatSavedValue) { *box = Ui::show( - EditLinkedChatBox(channel, chat, callback), + EditLinkedChatBox(channel, chat, canEdit, callback), LayerOption::KeepOther); return; - } else if (_linkedChatsRequestId) { + } else if (!canEdit || _linkedChatsRequestId) { return; } else if (channel->isMegagroup()) { // Restore original linked channel. @@ -779,16 +786,12 @@ void Controller::fillManageSection() { : false; }(); - const auto canEditLinkedChat = [&] { + const auto canViewOrEditLinkedChat = [&] { return !isChannel ? false - : channel->isBroadcast() - ? channel->canEditInformation() - : (channel->linkedChat() - && channel->canPinMessages() - && (channel->amCreator() || channel->adminRights() != 0) - && (!channel->hiddenPreHistory() - || channel->canEditPreHistoryHidden())); + : channel->linkedChat() + ? true + : (channel->isBroadcast() && channel->canEditInformation()); }(); AddSkip(_controls.buttonsLayout, 0); @@ -798,7 +801,7 @@ void Controller::fillManageSection() { } else if (canEditInviteLink) { fillInviteLinkButton(); } - if (canEditLinkedChat) { + if (canViewOrEditLinkedChat) { fillLinkedChatButton(); } if (canEditSignatures) { @@ -810,7 +813,7 @@ void Controller::fillManageSection() { if (canEditPreHistoryHidden || canEditSignatures || canEditInviteLink - || canEditLinkedChat + || canViewOrEditLinkedChat || canEditUsername) { AddSkip( _controls.buttonsLayout,