Rename linked-chat to discussion-link.

This commit is contained in:
John Preston 2025-05-06 10:22:29 +04:00
parent 1d2f713673
commit f96f478470
17 changed files with 103 additions and 103 deletions

View file

@ -214,8 +214,8 @@ PRIVATE
boxes/peers/edit_contact_box.h boxes/peers/edit_contact_box.h
boxes/peers/edit_forum_topic_box.cpp boxes/peers/edit_forum_topic_box.cpp
boxes/peers/edit_forum_topic_box.h boxes/peers/edit_forum_topic_box.h
boxes/peers/edit_linked_chat_box.cpp boxes/peers/edit_discussion_link_box.cpp
boxes/peers/edit_linked_chat_box.h boxes/peers/edit_discussion_link_box.h
boxes/peers/edit_members_visible.cpp boxes/peers/edit_members_visible.cpp
boxes/peers/edit_members_visible.h boxes/peers/edit_members_visible.h
boxes/peers/edit_participant_box.cpp boxes/peers/edit_participant_box.cpp

View file

@ -77,7 +77,7 @@ ModerateOptions CalculateModerateOptions(const HistoryItemsList &items) {
if (author == peer) { if (author == peer) {
return {}; return {};
} else if (const auto channel = author->asChannel()) { } else if (const auto channel = author->asChannel()) {
if (channel->linkedChat() == peer) { if (channel->discussionLink() == peer) {
return {}; return {};
} }
} }

View file

@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link: For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "boxes/peers/edit_linked_chat_box.h" #include "boxes/peers/edit_discussion_link_box.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "data/data_channel.h" #include "data/data_channel.h"
@ -224,7 +224,7 @@ void Controller::choose(not_null<ChatData*> chat) {
return tr::lng_manage_discussion_group_about(Ui::Text::WithEntities); return tr::lng_manage_discussion_group_about(Ui::Text::WithEntities);
} }
[[nodiscard]] object_ptr<Ui::BoxContent> EditLinkedChatBox( [[nodiscard]] object_ptr<Ui::BoxContent> EditDiscussionLinkBox(
not_null<Window::SessionNavigation*> navigation, not_null<Window::SessionNavigation*> navigation,
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
ChannelData *chat, ChannelData *chat,
@ -272,7 +272,7 @@ void Controller::choose(not_null<ChatData*> chat) {
Settings::AddButtonWithIcon( Settings::AddButtonWithIcon(
above, above,
tr::lng_manage_discussion_group_create(), tr::lng_manage_discussion_group_create(),
st::infoCreateLinkedChatButton, st::infoCreateDiscussionLinkButton,
{ &st::menuIconGroupCreate } { &st::menuIconGroupCreate }
)->addClickHandler([=, parent = above.data()] { )->addClickHandler([=, parent = above.data()] {
const auto guarded = crl::guard(parent, callback); const auto guarded = crl::guard(parent, callback);
@ -292,7 +292,7 @@ void Controller::choose(not_null<ChatData*> chat) {
(channel->isBroadcast() (channel->isBroadcast()
? tr::lng_manage_discussion_group_unlink ? tr::lng_manage_discussion_group_unlink
: tr::lng_manage_linked_channel_unlink)(), : tr::lng_manage_linked_channel_unlink)(),
st::infoUnlinkChatButton, st::infoUnlinkDiscussionLinkButton,
{ &st::menuIconRemove } { &st::menuIconRemove }
)->addClickHandler([=] { callback(nullptr); }); )->addClickHandler([=] { callback(nullptr); });
Ui::AddSkip(below); Ui::AddSkip(below);
@ -327,12 +327,12 @@ void Controller::choose(not_null<ChatData*> chat) {
} // namespace } // namespace
object_ptr<Ui::BoxContent> EditLinkedChatBox( object_ptr<Ui::BoxContent> EditDiscussionLinkBox(
not_null<Window::SessionNavigation*> navigation, not_null<Window::SessionNavigation*> navigation,
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
std::vector<not_null<PeerData*>> &&chats, std::vector<not_null<PeerData*>> &&chats,
Fn<void(ChannelData*)> callback) { Fn<void(ChannelData*)> callback) {
return EditLinkedChatBox( return EditDiscussionLinkBox(
navigation, navigation,
channel, channel,
nullptr, nullptr,
@ -341,13 +341,13 @@ object_ptr<Ui::BoxContent> EditLinkedChatBox(
callback); callback);
} }
object_ptr<Ui::BoxContent> EditLinkedChatBox( object_ptr<Ui::BoxContent> EditDiscussionLinkBox(
not_null<Window::SessionNavigation*> navigation, not_null<Window::SessionNavigation*> navigation,
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<ChannelData*> chat, not_null<ChannelData*> chat,
bool canEdit, bool canEdit,
Fn<void(ChannelData*)> callback) { Fn<void(ChannelData*)> callback) {
return EditLinkedChatBox( return EditDiscussionLinkBox(
navigation, navigation,
channel, channel,
chat, chat,

View file

@ -17,14 +17,14 @@ namespace Window {
class SessionNavigation; class SessionNavigation;
} // namespace Window } // namespace Window
[[nodiscard]] object_ptr<Ui::BoxContent> EditLinkedChatBox( [[nodiscard]] object_ptr<Ui::BoxContent> EditDiscussionLinkBox(
not_null<Window::SessionNavigation*> navigation, not_null<Window::SessionNavigation*> navigation,
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
not_null<ChannelData*> chat, not_null<ChannelData*> chat,
bool canEdit, bool canEdit,
Fn<void(ChannelData*)> callback); Fn<void(ChannelData*)> callback);
[[nodiscard]] object_ptr<Ui::BoxContent> EditLinkedChatBox( [[nodiscard]] object_ptr<Ui::BoxContent> EditDiscussionLinkBox(
not_null<Window::SessionNavigation*> navigation, not_null<Window::SessionNavigation*> navigation,
not_null<ChannelData*> channel, not_null<ChannelData*> channel,
std::vector<not_null<PeerData*>> &&chats, std::vector<not_null<PeerData*>> &&chats,

View file

@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peers/edit_peer_history_visibility_box.h" #include "boxes/peers/edit_peer_history_visibility_box.h"
#include "boxes/peers/edit_peer_permissions_box.h" #include "boxes/peers/edit_peer_permissions_box.h"
#include "boxes/peers/edit_peer_invite_links.h" #include "boxes/peers/edit_peer_invite_links.h"
#include "boxes/peers/edit_linked_chat_box.h" #include "boxes/peers/edit_discussion_link_box.h"
#include "boxes/peers/edit_peer_requests_box.h" #include "boxes/peers/edit_peer_requests_box.h"
#include "boxes/peers/edit_peer_reactions.h" #include "boxes/peers/edit_peer_reactions.h"
#include "boxes/peers/replace_boost_box.h" #include "boxes/peers/replace_boost_box.h"
@ -364,7 +364,7 @@ private:
std::optional<bool> noForwards; std::optional<bool> noForwards;
std::optional<bool> joinToWrite; std::optional<bool> joinToWrite;
std::optional<bool> requestToJoin; std::optional<bool> requestToJoin;
std::optional<ChannelData*> linkedChat; std::optional<ChannelData*> discussionLink;
}; };
[[nodiscard]] object_ptr<Ui::RpWidget> createPhotoAndTitleEdit(); [[nodiscard]] object_ptr<Ui::RpWidget> createPhotoAndTitleEdit();
@ -380,9 +380,9 @@ private:
void refreshForumToggleLocked(); void refreshForumToggleLocked();
void showEditPeerTypeBox( void showEditPeerTypeBox(
std::optional<rpl::producer<QString>> error = {}); std::optional<rpl::producer<QString>> error = {});
void showEditLinkedChatBox(); void showEditDiscussionLinkBox();
void fillPrivacyTypeButton(); void fillPrivacyTypeButton();
void fillLinkedChatButton(); void fillDiscussionLinkButton();
//void fillInviteLinkButton(); //void fillInviteLinkButton();
void fillForumButton(); void fillForumButton();
void fillColorIndexButton(); void fillColorIndexButton();
@ -410,7 +410,7 @@ private:
[[nodiscard]] std::optional<Saving> validate() const; [[nodiscard]] std::optional<Saving> validate() const;
[[nodiscard]] bool validateUsernamesOrder(Saving &to) const; [[nodiscard]] bool validateUsernamesOrder(Saving &to) const;
[[nodiscard]] bool validateUsername(Saving &to) const; [[nodiscard]] bool validateUsername(Saving &to) const;
[[nodiscard]] bool validateLinkedChat(Saving &to) const; [[nodiscard]] bool validateDiscussionLink(Saving &to) const;
[[nodiscard]] bool validateTitle(Saving &to) const; [[nodiscard]] bool validateTitle(Saving &to) const;
[[nodiscard]] bool validateDescription(Saving &to) const; [[nodiscard]] bool validateDescription(Saving &to) const;
[[nodiscard]] bool validateHistoryVisibility(Saving &to) const; [[nodiscard]] bool validateHistoryVisibility(Saving &to) const;
@ -424,7 +424,7 @@ private:
void save(); void save();
void saveUsernamesOrder(); void saveUsernamesOrder();
void saveUsername(); void saveUsername();
void saveLinkedChat(); void saveDiscussionLink();
void saveTitle(); void saveTitle();
void saveDescription(); void saveDescription();
void saveHistoryVisibility(); void saveHistoryVisibility();
@ -450,8 +450,8 @@ private:
void subscribeToMigration(); void subscribeToMigration();
void migrate(not_null<ChannelData*> channel); void migrate(not_null<ChannelData*> channel);
std::optional<ChannelData*> _linkedChatSavedValue; std::optional<ChannelData*> _discussionLinkSavedValue;
ChannelData *_linkedChatOriginalValue = nullptr; ChannelData *_discussionLinkOriginalValue = nullptr;
bool _channelHasLocationOriginalValue = false; bool _channelHasLocationOriginalValue = false;
std::optional<HistoryVisibility> _historyVisibilitySavedValue; std::optional<HistoryVisibility> _historyVisibilitySavedValue;
std::optional<EditPeerTypeData> _typeDataSavedValue; std::optional<EditPeerTypeData> _typeDataSavedValue;
@ -479,8 +479,8 @@ private:
}; };
const rpl::event_stream<PrivacyAndForwards> _privacyTypeUpdates; const rpl::event_stream<PrivacyAndForwards> _privacyTypeUpdates;
const rpl::event_stream<ChannelData*> _linkedChatUpdates; const rpl::event_stream<ChannelData*> _discussionLinkUpdates;
mtpRequestId _linkedChatsRequestId = 0; mtpRequestId _discussionLinksRequestId = 0;
rpl::lifetime _lifetime; rpl::lifetime _lifetime;
@ -820,7 +820,7 @@ void Controller::refreshHistoryVisibility() {
_controls.historyVisibilityWrap->toggle( _controls.historyVisibilityWrap->toggle(
(!withUsername (!withUsername
&& !_channelHasLocationOriginalValue && !_channelHasLocationOriginalValue
&& (!_linkedChatSavedValue || !*_linkedChatSavedValue) && (!_discussionLinkSavedValue || !*_discussionLinkSavedValue)
&& (!_forumSavedValue || !*_forumSavedValue)), && (!_forumSavedValue || !*_forumSavedValue)),
anim::type::instant); anim::type::instant);
} }
@ -832,8 +832,8 @@ void Controller::showEditPeerTypeBox(
_typeDataSavedValue = data; _typeDataSavedValue = data;
refreshHistoryVisibility(); refreshHistoryVisibility();
}); });
_typeDataSavedValue->hasLinkedChat _typeDataSavedValue->hasDiscussionLink
= (_linkedChatSavedValue.value_or(nullptr) != nullptr); = (_discussionLinkSavedValue.value_or(nullptr) != nullptr);
const auto box = _navigation->parentController()->show( const auto box = _navigation->parentController()->show(
Box<EditPeerTypeBox>( Box<EditPeerTypeBox>(
_navigation, _navigation,
@ -848,7 +848,7 @@ void Controller::showEditPeerTypeBox(
}, box->lifetime()); }, box->lifetime());
} }
void Controller::showEditLinkedChatBox() { void Controller::showEditDiscussionLinkBox() {
Expects(_peer->isChannel()); Expects(_peer->isChannel());
if (_forumSavedValue && *_forumSavedValue) { if (_forumSavedValue && *_forumSavedValue) {
@ -862,8 +862,8 @@ void Controller::showEditLinkedChatBox() {
if (*box) { if (*box) {
(*box)->closeBox(); (*box)->closeBox();
} }
*_linkedChatSavedValue = result; *_discussionLinkSavedValue = result;
_linkedChatUpdates.fire_copy(result); _discussionLinkUpdates.fire_copy(result);
refreshHistoryVisibility(); refreshHistoryVisibility();
refreshForumToggleLocked(); refreshForumToggleLocked();
}; };
@ -874,31 +874,31 @@ void Controller::showEditLinkedChatBox() {
&& (!channel->hiddenPreHistory() && (!channel->hiddenPreHistory()
|| channel->canEditPreHistoryHidden())); || channel->canEditPreHistoryHidden()));
if (const auto chat = *_linkedChatSavedValue) { if (const auto chat = *_discussionLinkSavedValue) {
*box = _navigation->parentController()->show(EditLinkedChatBox( *box = _navigation->parentController()->show(EditDiscussionLinkBox(
_navigation, _navigation,
channel, channel,
chat, chat,
canEdit, canEdit,
callback)); callback));
return; return;
} else if (!canEdit || _linkedChatsRequestId) { } else if (!canEdit || _discussionLinksRequestId) {
return; return;
} else if (channel->isMegagroup()) { } else if (channel->isMegagroup()) {
if (_forumSavedValue if (_forumSavedValue
&& *_forumSavedValue && *_forumSavedValue
&& _linkedChatOriginalValue) { && _discussionLinkOriginalValue) {
ShowForumForDiscussionError(_navigation); ShowForumForDiscussionError(_navigation);
} else { } else {
// Restore original linked channel. // Restore original discussion link.
callback(_linkedChatOriginalValue); callback(_discussionLinkOriginalValue);
} }
return; return;
} }
_linkedChatsRequestId = _api.request( _discussionLinksRequestId = _api.request(
MTPchannels_GetGroupsForDiscussion() MTPchannels_GetGroupsForDiscussion()
).done([=](const MTPmessages_Chats &result) { ).done([=](const MTPmessages_Chats &result) {
_linkedChatsRequestId = 0; _discussionLinksRequestId = 0;
const auto list = result.match([&](const auto &data) { const auto list = result.match([&](const auto &data) {
return data.vchats().v; return data.vchats().v;
}); });
@ -907,13 +907,13 @@ void Controller::showEditLinkedChatBox() {
for (const auto &item : list) { for (const auto &item : list) {
chats.emplace_back(_peer->owner().processChat(item)); chats.emplace_back(_peer->owner().processChat(item));
} }
*box = _navigation->parentController()->show(EditLinkedChatBox( *box = _navigation->parentController()->show(EditDiscussionLinkBox(
_navigation, _navigation,
channel, channel,
std::move(chats), std::move(chats),
callback)); callback));
}).fail([=] { }).fail([=] {
_linkedChatsRequestId = 0; _discussionLinksRequestId = 0;
}).send(); }).send();
} }
@ -979,11 +979,11 @@ void Controller::fillPrivacyTypeButton() {
}); });
} }
void Controller::fillLinkedChatButton() { void Controller::fillDiscussionLinkButton() {
Expects(_controls.buttonsLayout != nullptr); Expects(_controls.buttonsLayout != nullptr);
_linkedChatSavedValue = _linkedChatOriginalValue = _peer->isChannel() _discussionLinkSavedValue = _discussionLinkOriginalValue = _peer->isChannel()
? _peer->asChannel()->linkedChat() ? _peer->asChannel()->discussionLink()
: nullptr; : nullptr;
const auto isGroup = (_peer->isChat() || _peer->isMegagroup()); const auto isGroup = (_peer->isChat() || _peer->isMegagroup());
@ -992,7 +992,7 @@ void Controller::fillLinkedChatButton() {
: rpl::combine( : rpl::combine(
tr::lng_manage_linked_channel(), tr::lng_manage_linked_channel(),
tr::lng_manage_linked_channel_restore(), tr::lng_manage_linked_channel_restore(),
_linkedChatUpdates.events() _discussionLinkUpdates.events()
) | rpl::map([=]( ) | rpl::map([=](
const QString &edit, const QString &edit,
const QString &restore, const QString &restore,
@ -1000,13 +1000,13 @@ void Controller::fillLinkedChatButton() {
return chat ? edit : restore; return chat ? edit : restore;
}); });
auto label = isGroup auto label = isGroup
? _linkedChatUpdates.events( ? _discussionLinkUpdates.events(
) | rpl::map([](ChannelData *chat) { ) | rpl::map([](ChannelData *chat) {
return chat ? chat->name() : QString(); return chat ? chat->name() : QString();
}) | rpl::type_erased() }) | rpl::type_erased()
: rpl::combine( : rpl::combine(
tr::lng_manage_discussion_group_add(), tr::lng_manage_discussion_group_add(),
_linkedChatUpdates.events() _discussionLinkUpdates.events()
) | rpl::map([=](const QString &add, ChannelData *chat) { ) | rpl::map([=](const QString &add, ChannelData *chat) {
return chat ? chat->name() : add; return chat ? chat->name() : add;
}) | rpl::type_erased(); }) | rpl::type_erased();
@ -1014,9 +1014,9 @@ void Controller::fillLinkedChatButton() {
_controls.buttonsLayout, _controls.buttonsLayout,
std::move(text), std::move(text),
std::move(label), std::move(label),
[=] { showEditLinkedChatBox(); }, [=] { showEditDiscussionLinkBox(); },
{ isGroup ? &st::menuIconChannel : &st::menuIconGroups }); { isGroup ? &st::menuIconChannel : &st::menuIconGroups });
_linkedChatUpdates.fire_copy(*_linkedChatSavedValue); _discussionLinkUpdates.fire_copy(*_discussionLinkSavedValue);
} }
// //
//void Controller::fillInviteLinkButton() { //void Controller::fillInviteLinkButton() {
@ -1051,7 +1051,7 @@ void Controller::fillForumButton() {
) | rpl::start_with_next([=](bool toggled) { ) | rpl::start_with_next([=](bool toggled) {
if (_controls.forumToggleLocked && toggled) { if (_controls.forumToggleLocked && toggled) {
unlocks->fire(false); unlocks->fire(false);
if (_linkedChatSavedValue && *_linkedChatSavedValue) { if (_discussionLinkSavedValue && *_discussionLinkSavedValue) {
ShowForumForDiscussionError(_navigation); ShowForumForDiscussionError(_navigation);
} else { } else {
_navigation->showToast( _navigation->showToast(
@ -1081,8 +1081,8 @@ void Controller::refreshForumToggleLocked() {
const auto channel = _peer->asChannel(); const auto channel = _peer->asChannel();
const auto notenough = !_peer->isForum() const auto notenough = !_peer->isForum()
&& ((chat ? chat->count : channel->membersCount()) < limit); && ((chat ? chat->count : channel->membersCount()) < limit);
const auto linked = _linkedChatSavedValue const auto linked = _discussionLinkSavedValue
&& *_linkedChatSavedValue; && *_discussionLinkSavedValue;
const auto locked = _controls.forumToggleLocked = notenough || linked; const auto locked = _controls.forumToggleLocked = notenough || linked;
_controls.forumToggle->setToggleLocked(locked); _controls.forumToggle->setToggleLocked(locked);
} }
@ -1355,8 +1355,8 @@ void Controller::fillManageSection() {
const auto canEditStickers = isChannel && channel->canEditStickers(); const auto canEditStickers = isChannel && channel->canEditStickers();
const auto canDeleteChannel = isChannel && channel->canDelete(); const auto canDeleteChannel = isChannel && channel->canDelete();
const auto canEditColorIndex = isChannel && channel->canEditEmoji(); const auto canEditColorIndex = isChannel && channel->canEditEmoji();
const auto canViewOrEditLinkedChat = isChannel const auto canViewOrEditDiscussionLink = isChannel
&& (channel->linkedChat() && (channel->discussionLink()
|| (channel->isBroadcast() && channel->canEditInformation())); || (channel->isBroadcast() && channel->canEditInformation()));
::AddSkip(_controls.buttonsLayout, 0); ::AddSkip(_controls.buttonsLayout, 0);
@ -1366,8 +1366,8 @@ void Controller::fillManageSection() {
//} else if (canEditInviteLinks) { //} else if (canEditInviteLinks) {
// fillInviteLinkButton(); // fillInviteLinkButton();
} }
if (canViewOrEditLinkedChat) { if (canViewOrEditDiscussionLink) {
fillLinkedChatButton(); fillDiscussionLinkButton();
} }
if (canEditPreHistoryHidden) { if (canEditPreHistoryHidden) {
fillHistoryVisibilityButton(); fillHistoryVisibilityButton();
@ -1387,7 +1387,7 @@ void Controller::fillManageSection() {
|| canEditForum || canEditForum
|| canEditColorIndex || canEditColorIndex
//|| canEditInviteLinks //|| canEditInviteLinks
|| canViewOrEditLinkedChat || canViewOrEditDiscussionLink
|| canEditType) { || canEditType) {
::AddSkip(_controls.buttonsLayout); ::AddSkip(_controls.buttonsLayout);
} }
@ -1971,7 +1971,7 @@ std::optional<Controller::Saving> Controller::validate() const {
auto result = Saving(); auto result = Saving();
if (validateUsernamesOrder(result) if (validateUsernamesOrder(result)
&& validateUsername(result) && validateUsername(result)
&& validateLinkedChat(result) && validateDiscussionLink(result)
&& validateTitle(result) && validateTitle(result)
&& validateDescription(result) && validateDescription(result)
&& validateHistoryVisibility(result) && validateHistoryVisibility(result)
@ -2013,11 +2013,11 @@ bool Controller::validateUsername(Saving &to) const {
return true; return true;
} }
bool Controller::validateLinkedChat(Saving &to) const { bool Controller::validateDiscussionLink(Saving &to) const {
if (!_linkedChatSavedValue) { if (!_discussionLinkSavedValue) {
return true; return true;
} }
to.linkedChat = *_linkedChatSavedValue; to.discussionLink = *_discussionLinkSavedValue;
return true; return true;
} }
@ -2118,7 +2118,7 @@ void Controller::save() {
_savingData = *saving; _savingData = *saving;
pushSaveStage([=] { saveUsernamesOrder(); }); pushSaveStage([=] { saveUsernamesOrder(); });
pushSaveStage([=] { saveUsername(); }); pushSaveStage([=] { saveUsername(); });
pushSaveStage([=] { saveLinkedChat(); }); pushSaveStage([=] { saveDiscussionLink(); });
pushSaveStage([=] { saveTitle(); }); pushSaveStage([=] { saveTitle(); });
pushSaveStage([=] { saveDescription(); }); pushSaveStage([=] { saveDescription(); });
pushSaveStage([=] { saveHistoryVisibility(); }); pushSaveStage([=] { saveHistoryVisibility(); });
@ -2241,34 +2241,34 @@ void Controller::saveUsername() {
}).send(); }).send();
} }
void Controller::saveLinkedChat() { void Controller::saveDiscussionLink() {
const auto channel = _peer->asChannel(); const auto channel = _peer->asChannel();
if (!channel) { if (!channel) {
return continueSave(); return continueSave();
} }
if (!_savingData.linkedChat if (!_savingData.discussionLink
|| *_savingData.linkedChat == channel->linkedChat()) { || *_savingData.discussionLink == channel->discussionLink()) {
return continueSave(); return continueSave();
} }
const auto chat = *_savingData.linkedChat; const auto chat = *_savingData.discussionLink;
if (channel->isBroadcast() && chat && chat->hiddenPreHistory()) { if (channel->isBroadcast() && chat && chat->hiddenPreHistory()) {
togglePreHistoryHidden( togglePreHistoryHidden(
chat, chat,
false, false,
[=] { saveLinkedChat(); }, [=] { saveDiscussionLink(); },
[=] { cancelSave(); }); [=] { cancelSave(); });
return; return;
} }
const auto input = *_savingData.linkedChat const auto input = *_savingData.discussionLink
? (*_savingData.linkedChat)->inputChannel ? (*_savingData.discussionLink)->inputChannel
: MTP_inputChannelEmpty(); : MTP_inputChannelEmpty();
_api.request(MTPchannels_SetDiscussionGroup( _api.request(MTPchannels_SetDiscussionGroup(
(channel->isBroadcast() ? channel->inputChannel : input), (channel->isBroadcast() ? channel->inputChannel : input),
(channel->isBroadcast() ? input : channel->inputChannel) (channel->isBroadcast() ? input : channel->inputChannel)
)).done([=] { )).done([=] {
channel->setLinkedChat(*_savingData.linkedChat); channel->setDiscussionLink(*_savingData.discussionLink);
continueSave(); continueSave();
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
_navigation->showToast(error.type()); _navigation->showToast(error.type());

View file

@ -1138,7 +1138,7 @@ void ShowEditPeerPermissionsBox(
result.emplace( result.emplace(
Flag::ChangeInfo | Flag::PinMessages, Flag::ChangeInfo | Flag::PinMessages,
tr::lng_rights_permission_unavailable(tr::now)); tr::lng_rights_permission_unavailable(tr::now));
} else if (channel->isMegagroup() && channel->linkedChat()) { } else if (channel->isMegagroup() && channel->discussionLink()) {
result.emplace( result.emplace(
Flag::ChangeInfo | Flag::PinMessages, Flag::ChangeInfo | Flag::PinMessages,
tr::lng_rights_permission_in_discuss(tr::now)); tr::lng_rights_permission_in_discuss(tr::now));

View file

@ -220,7 +220,7 @@ void Controller::createContent() {
const auto wrap = _controls.whoSendWrap->entity(); const auto wrap = _controls.whoSendWrap->entity();
Ui::AddSkip(wrap); Ui::AddSkip(wrap);
if (_dataSavedValue->hasLinkedChat) { if (_dataSavedValue->hasDiscussionLink) {
Ui::AddSubsectionTitle(wrap, tr::lng_manage_peer_send_title()); Ui::AddSubsectionTitle(wrap, tr::lng_manage_peer_send_title());
_controls.joinToWrite = wrap->add(EditPeerInfoBox::CreateButton( _controls.joinToWrite = wrap->add(EditPeerInfoBox::CreateButton(
@ -498,7 +498,7 @@ void Controller::privacyChanged(Privacy value) {
} }
_controls.whoSendWrap->toggle( _controls.whoSendWrap->toggle(
(value == Privacy::HasUsername (value == Privacy::HasUsername
|| (_dataSavedValue && _dataSavedValue->hasLinkedChat)), || (_dataSavedValue && _dataSavedValue->hasDiscussionLink)),
anim::type::instant); anim::type::instant);
}; };
const auto refreshVisibilities = [&] { const auto refreshVisibilities = [&] {

View file

@ -37,7 +37,7 @@ struct EditPeerTypeData {
Privacy privacy = Privacy::NoUsername; Privacy privacy = Privacy::NoUsername;
QString username; QString username;
std::vector<QString> usernamesOrder; std::vector<QString> usernamesOrder;
bool hasLinkedChat = false; bool hasDiscussionLink = false;
bool noForwards = false; bool noForwards = false;
bool joinToWrite = false; bool joinToWrite = false;
bool requestToJoin = false; bool requestToJoin = false;

View file

@ -111,7 +111,7 @@ struct PeerUpdate {
ChannelAmIn = (1ULL << 45), ChannelAmIn = (1ULL << 45),
StickersSet = (1ULL << 46), StickersSet = (1ULL << 46),
EmojiSet = (1ULL << 47), EmojiSet = (1ULL << 47),
ChannelLinkedChat = (1ULL << 48), DiscussionLink = (1ULL << 48),
ChannelLocation = (1ULL << 49), ChannelLocation = (1ULL << 49),
Slowmode = (1ULL << 50), Slowmode = (1ULL << 50),
GroupCall = (1ULL << 51), GroupCall = (1ULL << 51),

View file

@ -275,22 +275,22 @@ const ChannelLocation *ChannelData::getLocation() const {
return mgInfo ? mgInfo->getLocation() : nullptr; return mgInfo ? mgInfo->getLocation() : nullptr;
} }
void ChannelData::setLinkedChat(ChannelData *linked) { void ChannelData::setDiscussionLink(ChannelData *linked) {
if (_linkedChat != linked) { if (_discussionLink != linked) {
_linkedChat = linked; _discussionLink = linked;
if (const auto history = owner().historyLoaded(this)) { if (const auto history = owner().historyLoaded(this)) {
history->forceFullResize(); history->forceFullResize();
} }
session().changes().peerUpdated(this, UpdateFlag::ChannelLinkedChat); session().changes().peerUpdated(this, UpdateFlag::DiscussionLink);
} }
} }
ChannelData *ChannelData::linkedChat() const { ChannelData *ChannelData::discussionLink() const {
return _linkedChat.value_or(nullptr); return _discussionLink.value_or(nullptr);
} }
bool ChannelData::linkedChatKnown() const { bool ChannelData::discussionLinkKnown() const {
return _linkedChat.has_value(); return _discussionLink.has_value();
} }
void ChannelData::setMembersCount(int newMembersCount) { void ChannelData::setMembersCount(int newMembersCount) {
@ -1236,9 +1236,9 @@ void ApplyChannelUpdate(
channel->setLocation(MTP_channelLocationEmpty()); channel->setLocation(MTP_channelLocationEmpty());
} }
if (const auto chat = update.vlinked_chat_id()) { if (const auto chat = update.vlinked_chat_id()) {
channel->setLinkedChat(channel->owner().channelLoaded(chat->v)); channel->setDiscussionLink(channel->owner().channelLoaded(chat->v));
} else { } else {
channel->setLinkedChat(nullptr); channel->setDiscussionLink(nullptr);
} }
if (const auto history = channel->owner().historyLoaded(channel)) { if (const auto history = channel->owner().historyLoaded(channel)) {
if (const auto available = update.vavailable_min_id()) { if (const auto available = update.vavailable_min_id()) {

View file

@ -409,9 +409,9 @@ public:
void setLocation(const MTPChannelLocation &data); void setLocation(const MTPChannelLocation &data);
[[nodiscard]] const ChannelLocation *getLocation() const; [[nodiscard]] const ChannelLocation *getLocation() const;
void setLinkedChat(ChannelData *linked); void setDiscussionLink(ChannelData *link);
[[nodiscard]] ChannelData *linkedChat() const; [[nodiscard]] ChannelData *discussionLink() const;
[[nodiscard]] bool linkedChatKnown() const; [[nodiscard]] bool discussionLinkKnown() const;
void ptsInit(int32 pts) { void ptsInit(int32 pts) {
_ptsWaiter.init(pts); _ptsWaiter.init(pts);
@ -570,7 +570,7 @@ private:
std::vector<Data::UnavailableReason> _unavailableReasons; std::vector<Data::UnavailableReason> _unavailableReasons;
std::unique_ptr<InvitePeek> _invitePeek; std::unique_ptr<InvitePeek> _invitePeek;
QString _inviteLink; QString _inviteLink;
std::optional<ChannelData*> _linkedChat; std::optional<ChannelData*> _discussionLink;
Data::AllowedReactions _allowedReactions; Data::AllowedReactions _allowedReactions;

View file

@ -1044,14 +1044,14 @@ void HistoryItem::setGroupId(MessageGroupId groupId) {
_history->owner().groups().registerMessage(this); _history->owner().groups().registerMessage(this);
} }
bool HistoryItem::checkCommentsLinkedChat(ChannelId id) const { bool HistoryItem::checkDiscussionLink(ChannelId id) const {
if (!id) { if (!id) {
return true; return true;
} else if (const auto channel = _history->peer->asChannel()) { } else if (const auto channel = _history->peer->asChannel()) {
if (channel->linkedChatKnown() if (channel->discussionLinkKnown()
|| !(channel->flags() & ChannelDataFlag::HasLink)) { || !(channel->flags() & ChannelDataFlag::HasLink)) {
const auto linked = channel->linkedChat(); const auto link = channel->discussionLink();
if (!linked || peerToChannel(linked->id) != id) { if (!link || peerToChannel(link->id) != id) {
return false; return false;
} }
} }
@ -1154,7 +1154,7 @@ bool HistoryItem::areCommentsUnread() const {
const auto views = Get<HistoryMessageViews>(); const auto views = Get<HistoryMessageViews>();
if (!views if (!views
|| !views->commentsMegagroupId || !views->commentsMegagroupId
|| !checkCommentsLinkedChat(views->commentsMegagroupId)) { || !checkDiscussionLink(views->commentsMegagroupId)) {
return false; return false;
} }
const auto till = views->commentsInboxReadTillId; const auto till = views->commentsInboxReadTillId;
@ -3301,7 +3301,7 @@ int HistoryItem::viewsCount() const {
int HistoryItem::repliesCount() const { int HistoryItem::repliesCount() const {
if (const auto views = Get<HistoryMessageViews>()) { if (const auto views = Get<HistoryMessageViews>()) {
if (!checkCommentsLinkedChat(views->commentsMegagroupId)) { if (!checkDiscussionLink(views->commentsMegagroupId)) {
return 0; return 0;
} }
return std::max(views->replies.count, 0); return std::max(views->replies.count, 0);
@ -3312,7 +3312,7 @@ int HistoryItem::repliesCount() const {
bool HistoryItem::repliesAreComments() const { bool HistoryItem::repliesAreComments() const {
if (const auto views = Get<HistoryMessageViews>()) { if (const auto views = Get<HistoryMessageViews>()) {
return (views->commentsMegagroupId != 0) return (views->commentsMegagroupId != 0)
&& checkCommentsLinkedChat(views->commentsMegagroupId); && checkDiscussionLink(views->commentsMegagroupId);
} }
return false; return false;
} }
@ -3805,9 +3805,9 @@ void HistoryItem::createComponents(CreateConfig &&config) {
&& isSending() && isSending()
&& config.markup.isNull()) { && config.markup.isNull()) {
if (const auto broadcast = _history->peer->asBroadcast()) { if (const auto broadcast = _history->peer->asBroadcast()) {
if (const auto linked = broadcast->linkedChat()) { if (const auto link = broadcast->discussionLink()) {
config.replies.isNull = false; config.replies.isNull = false;
config.replies.channelId = peerToChannel(linked->id); config.replies.channelId = peerToChannel(link->id);
} }
} }
} }

View file

@ -597,7 +597,7 @@ private:
return _flags & MessageFlag::Legacy; return _flags & MessageFlag::Legacy;
} }
[[nodiscard]] bool checkCommentsLinkedChat(ChannelId id) const; [[nodiscard]] bool checkDiscussionLink(ChannelId id) const;
void setReplyMarkup(HistoryMessageMarkupData &&markup); void setReplyMarkup(HistoryMessageMarkupData &&markup);

View file

@ -805,7 +805,7 @@ HistoryWidget::HistoryWidget(
| PeerUpdateFlag::OnlineStatus | PeerUpdateFlag::OnlineStatus
| PeerUpdateFlag::Notifications | PeerUpdateFlag::Notifications
| PeerUpdateFlag::ChannelAmIn | PeerUpdateFlag::ChannelAmIn
| PeerUpdateFlag::ChannelLinkedChat | PeerUpdateFlag::DiscussionLink
| PeerUpdateFlag::Slowmode | PeerUpdateFlag::Slowmode
| PeerUpdateFlag::BotStartToken | PeerUpdateFlag::BotStartToken
| PeerUpdateFlag::MessagesTTL | PeerUpdateFlag::MessagesTTL
@ -877,7 +877,7 @@ HistoryWidget::HistoryWidget(
| PeerUpdateFlag::OnlineStatus | PeerUpdateFlag::OnlineStatus
| PeerUpdateFlag::Rights | PeerUpdateFlag::Rights
| PeerUpdateFlag::ChannelAmIn | PeerUpdateFlag::ChannelAmIn
| PeerUpdateFlag::ChannelLinkedChat)) { | PeerUpdateFlag::DiscussionLink)) {
handlePeerUpdate(); handlePeerUpdate();
} }
if (flags & PeerUpdateFlag::MessagesTTL) { if (flags & PeerUpdateFlag::MessagesTTL) {

View file

@ -572,12 +572,12 @@ infoBlockButton: SettingsButton(infoProfileButton) {
textFg: attentionButtonFg; textFg: attentionButtonFg;
textFgOver: attentionButtonFgOver; textFgOver: attentionButtonFgOver;
} }
infoCreateLinkedChatButton: SettingsButton(infoProfileButton) { infoCreateDiscussionLinkButton: SettingsButton(infoProfileButton) {
padding: margins(74px, 10px, 8px, 8px); padding: margins(74px, 10px, 8px, 8px);
textFg: lightButtonFg; textFg: lightButtonFg;
textFgOver: lightButtonFgOver; textFgOver: lightButtonFgOver;
} }
infoUnlinkChatButton: SettingsButton(infoCreateLinkedChatButton) { infoUnlinkDiscussionLinkButton: SettingsButton(infoCreateDiscussionLinkButton) {
textFg: attentionButtonFg; textFg: attentionButtonFg;
textFgOver: attentionButtonFgOver; textFgOver: attentionButtonFgOver;
} }

View file

@ -839,7 +839,7 @@ void Filler::addViewDiscussion() {
if (!channel) { if (!channel) {
return; return;
} }
const auto chat = channel->linkedChat(); const auto chat = channel->discussionLink();
if (!chat) { if (!chat) {
return; return;
} }

View file

@ -2428,7 +2428,7 @@ void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
if (!clickedChannel->isPublic() if (!clickedChannel->isPublic()
&& !clickedChannel->amIn() && !clickedChannel->amIn()
&& (!currentPeer->isChannel() && (!currentPeer->isChannel()
|| currentPeer->asChannel()->linkedChat() || currentPeer->asChannel()->discussionLink()
!= clickedChannel)) { != clickedChannel)) {
MainWindowShow(this).showToast(peer->isMegagroup() MainWindowShow(this).showToast(peer->isMegagroup()
? tr::lng_group_not_accessible(tr::now) ? tr::lng_group_not_accessible(tr::now)