diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index eb2bf8bec3..1cc9694c1b 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -214,8 +214,8 @@ PRIVATE boxes/peers/edit_contact_box.h boxes/peers/edit_forum_topic_box.cpp boxes/peers/edit_forum_topic_box.h - boxes/peers/edit_linked_chat_box.cpp - boxes/peers/edit_linked_chat_box.h + boxes/peers/edit_discussion_link_box.cpp + boxes/peers/edit_discussion_link_box.h boxes/peers/edit_members_visible.cpp boxes/peers/edit_members_visible.h boxes/peers/edit_participant_box.cpp diff --git a/Telegram/SourceFiles/boxes/moderate_messages_box.cpp b/Telegram/SourceFiles/boxes/moderate_messages_box.cpp index 0fa39c2ee4..fbe6ee72b4 100644 --- a/Telegram/SourceFiles/boxes/moderate_messages_box.cpp +++ b/Telegram/SourceFiles/boxes/moderate_messages_box.cpp @@ -77,7 +77,7 @@ ModerateOptions CalculateModerateOptions(const HistoryItemsList &items) { if (author == peer) { return {}; } else if (const auto channel = author->asChannel()) { - if (channel->linkedChat() == peer) { + if (channel->discussionLink() == peer) { return {}; } } diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_discussion_link_box.cpp similarity index 96% rename from Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp rename to Telegram/SourceFiles/boxes/peers/edit_discussion_link_box.cpp index bae3d8a769..ab2089b6a1 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_discussion_link_box.cpp @@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: 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 "data/data_channel.h" @@ -224,7 +224,7 @@ void Controller::choose(not_null chat) { return tr::lng_manage_discussion_group_about(Ui::Text::WithEntities); } -[[nodiscard]] object_ptr EditLinkedChatBox( +[[nodiscard]] object_ptr EditDiscussionLinkBox( not_null navigation, not_null channel, ChannelData *chat, @@ -272,7 +272,7 @@ void Controller::choose(not_null chat) { Settings::AddButtonWithIcon( above, tr::lng_manage_discussion_group_create(), - st::infoCreateLinkedChatButton, + st::infoCreateDiscussionLinkButton, { &st::menuIconGroupCreate } )->addClickHandler([=, parent = above.data()] { const auto guarded = crl::guard(parent, callback); @@ -292,7 +292,7 @@ void Controller::choose(not_null chat) { (channel->isBroadcast() ? tr::lng_manage_discussion_group_unlink : tr::lng_manage_linked_channel_unlink)(), - st::infoUnlinkChatButton, + st::infoUnlinkDiscussionLinkButton, { &st::menuIconRemove } )->addClickHandler([=] { callback(nullptr); }); Ui::AddSkip(below); @@ -327,12 +327,12 @@ void Controller::choose(not_null chat) { } // namespace -object_ptr EditLinkedChatBox( +object_ptr EditDiscussionLinkBox( not_null navigation, not_null channel, std::vector> &&chats, Fn callback) { - return EditLinkedChatBox( + return EditDiscussionLinkBox( navigation, channel, nullptr, @@ -341,13 +341,13 @@ object_ptr EditLinkedChatBox( callback); } -object_ptr EditLinkedChatBox( +object_ptr EditDiscussionLinkBox( not_null navigation, not_null channel, not_null chat, bool canEdit, Fn callback) { - return EditLinkedChatBox( + return EditDiscussionLinkBox( navigation, channel, chat, diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h b/Telegram/SourceFiles/boxes/peers/edit_discussion_link_box.h similarity index 86% rename from Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h rename to Telegram/SourceFiles/boxes/peers/edit_discussion_link_box.h index 788f57757e..113a9ca1f5 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_discussion_link_box.h @@ -17,14 +17,14 @@ namespace Window { class SessionNavigation; } // namespace Window -[[nodiscard]] object_ptr EditLinkedChatBox( +[[nodiscard]] object_ptr EditDiscussionLinkBox( not_null navigation, not_null channel, not_null chat, bool canEdit, Fn callback); -[[nodiscard]] object_ptr EditLinkedChatBox( +[[nodiscard]] object_ptr EditDiscussionLinkBox( not_null navigation, not_null channel, std::vector> &&chats, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 5367230426..9d52003021 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -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_permissions_box.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_reactions.h" #include "boxes/peers/replace_boost_box.h" @@ -364,7 +364,7 @@ private: std::optional noForwards; std::optional joinToWrite; std::optional requestToJoin; - std::optional linkedChat; + std::optional discussionLink; }; [[nodiscard]] object_ptr createPhotoAndTitleEdit(); @@ -380,9 +380,9 @@ private: void refreshForumToggleLocked(); void showEditPeerTypeBox( std::optional> error = {}); - void showEditLinkedChatBox(); + void showEditDiscussionLinkBox(); void fillPrivacyTypeButton(); - void fillLinkedChatButton(); + void fillDiscussionLinkButton(); //void fillInviteLinkButton(); void fillForumButton(); void fillColorIndexButton(); @@ -410,7 +410,7 @@ private: [[nodiscard]] std::optional validate() const; [[nodiscard]] bool validateUsernamesOrder(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 validateDescription(Saving &to) const; [[nodiscard]] bool validateHistoryVisibility(Saving &to) const; @@ -424,7 +424,7 @@ private: void save(); void saveUsernamesOrder(); void saveUsername(); - void saveLinkedChat(); + void saveDiscussionLink(); void saveTitle(); void saveDescription(); void saveHistoryVisibility(); @@ -450,8 +450,8 @@ private: void subscribeToMigration(); void migrate(not_null channel); - std::optional _linkedChatSavedValue; - ChannelData *_linkedChatOriginalValue = nullptr; + std::optional _discussionLinkSavedValue; + ChannelData *_discussionLinkOriginalValue = nullptr; bool _channelHasLocationOriginalValue = false; std::optional _historyVisibilitySavedValue; std::optional _typeDataSavedValue; @@ -479,8 +479,8 @@ private: }; const rpl::event_stream _privacyTypeUpdates; - const rpl::event_stream _linkedChatUpdates; - mtpRequestId _linkedChatsRequestId = 0; + const rpl::event_stream _discussionLinkUpdates; + mtpRequestId _discussionLinksRequestId = 0; rpl::lifetime _lifetime; @@ -820,7 +820,7 @@ void Controller::refreshHistoryVisibility() { _controls.historyVisibilityWrap->toggle( (!withUsername && !_channelHasLocationOriginalValue - && (!_linkedChatSavedValue || !*_linkedChatSavedValue) + && (!_discussionLinkSavedValue || !*_discussionLinkSavedValue) && (!_forumSavedValue || !*_forumSavedValue)), anim::type::instant); } @@ -832,8 +832,8 @@ void Controller::showEditPeerTypeBox( _typeDataSavedValue = data; refreshHistoryVisibility(); }); - _typeDataSavedValue->hasLinkedChat - = (_linkedChatSavedValue.value_or(nullptr) != nullptr); + _typeDataSavedValue->hasDiscussionLink + = (_discussionLinkSavedValue.value_or(nullptr) != nullptr); const auto box = _navigation->parentController()->show( Box( _navigation, @@ -848,7 +848,7 @@ void Controller::showEditPeerTypeBox( }, box->lifetime()); } -void Controller::showEditLinkedChatBox() { +void Controller::showEditDiscussionLinkBox() { Expects(_peer->isChannel()); if (_forumSavedValue && *_forumSavedValue) { @@ -862,8 +862,8 @@ void Controller::showEditLinkedChatBox() { if (*box) { (*box)->closeBox(); } - *_linkedChatSavedValue = result; - _linkedChatUpdates.fire_copy(result); + *_discussionLinkSavedValue = result; + _discussionLinkUpdates.fire_copy(result); refreshHistoryVisibility(); refreshForumToggleLocked(); }; @@ -874,31 +874,31 @@ void Controller::showEditLinkedChatBox() { && (!channel->hiddenPreHistory() || channel->canEditPreHistoryHidden())); - if (const auto chat = *_linkedChatSavedValue) { - *box = _navigation->parentController()->show(EditLinkedChatBox( + if (const auto chat = *_discussionLinkSavedValue) { + *box = _navigation->parentController()->show(EditDiscussionLinkBox( _navigation, channel, chat, canEdit, callback)); return; - } else if (!canEdit || _linkedChatsRequestId) { + } else if (!canEdit || _discussionLinksRequestId) { return; } else if (channel->isMegagroup()) { if (_forumSavedValue && *_forumSavedValue - && _linkedChatOriginalValue) { + && _discussionLinkOriginalValue) { ShowForumForDiscussionError(_navigation); } else { - // Restore original linked channel. - callback(_linkedChatOriginalValue); + // Restore original discussion link. + callback(_discussionLinkOriginalValue); } return; } - _linkedChatsRequestId = _api.request( + _discussionLinksRequestId = _api.request( MTPchannels_GetGroupsForDiscussion() ).done([=](const MTPmessages_Chats &result) { - _linkedChatsRequestId = 0; + _discussionLinksRequestId = 0; const auto list = result.match([&](const auto &data) { return data.vchats().v; }); @@ -907,13 +907,13 @@ void Controller::showEditLinkedChatBox() { for (const auto &item : list) { chats.emplace_back(_peer->owner().processChat(item)); } - *box = _navigation->parentController()->show(EditLinkedChatBox( + *box = _navigation->parentController()->show(EditDiscussionLinkBox( _navigation, channel, std::move(chats), callback)); }).fail([=] { - _linkedChatsRequestId = 0; + _discussionLinksRequestId = 0; }).send(); } @@ -979,11 +979,11 @@ void Controller::fillPrivacyTypeButton() { }); } -void Controller::fillLinkedChatButton() { +void Controller::fillDiscussionLinkButton() { Expects(_controls.buttonsLayout != nullptr); - _linkedChatSavedValue = _linkedChatOriginalValue = _peer->isChannel() - ? _peer->asChannel()->linkedChat() + _discussionLinkSavedValue = _discussionLinkOriginalValue = _peer->isChannel() + ? _peer->asChannel()->discussionLink() : nullptr; const auto isGroup = (_peer->isChat() || _peer->isMegagroup()); @@ -992,7 +992,7 @@ void Controller::fillLinkedChatButton() { : rpl::combine( tr::lng_manage_linked_channel(), tr::lng_manage_linked_channel_restore(), - _linkedChatUpdates.events() + _discussionLinkUpdates.events() ) | rpl::map([=]( const QString &edit, const QString &restore, @@ -1000,13 +1000,13 @@ void Controller::fillLinkedChatButton() { return chat ? edit : restore; }); auto label = isGroup - ? _linkedChatUpdates.events( + ? _discussionLinkUpdates.events( ) | rpl::map([](ChannelData *chat) { return chat ? chat->name() : QString(); }) | rpl::type_erased() : rpl::combine( tr::lng_manage_discussion_group_add(), - _linkedChatUpdates.events() + _discussionLinkUpdates.events() ) | rpl::map([=](const QString &add, ChannelData *chat) { return chat ? chat->name() : add; }) | rpl::type_erased(); @@ -1014,9 +1014,9 @@ void Controller::fillLinkedChatButton() { _controls.buttonsLayout, std::move(text), std::move(label), - [=] { showEditLinkedChatBox(); }, + [=] { showEditDiscussionLinkBox(); }, { isGroup ? &st::menuIconChannel : &st::menuIconGroups }); - _linkedChatUpdates.fire_copy(*_linkedChatSavedValue); + _discussionLinkUpdates.fire_copy(*_discussionLinkSavedValue); } // //void Controller::fillInviteLinkButton() { @@ -1051,7 +1051,7 @@ void Controller::fillForumButton() { ) | rpl::start_with_next([=](bool toggled) { if (_controls.forumToggleLocked && toggled) { unlocks->fire(false); - if (_linkedChatSavedValue && *_linkedChatSavedValue) { + if (_discussionLinkSavedValue && *_discussionLinkSavedValue) { ShowForumForDiscussionError(_navigation); } else { _navigation->showToast( @@ -1081,8 +1081,8 @@ void Controller::refreshForumToggleLocked() { const auto channel = _peer->asChannel(); const auto notenough = !_peer->isForum() && ((chat ? chat->count : channel->membersCount()) < limit); - const auto linked = _linkedChatSavedValue - && *_linkedChatSavedValue; + const auto linked = _discussionLinkSavedValue + && *_discussionLinkSavedValue; const auto locked = _controls.forumToggleLocked = notenough || linked; _controls.forumToggle->setToggleLocked(locked); } @@ -1355,8 +1355,8 @@ void Controller::fillManageSection() { const auto canEditStickers = isChannel && channel->canEditStickers(); const auto canDeleteChannel = isChannel && channel->canDelete(); const auto canEditColorIndex = isChannel && channel->canEditEmoji(); - const auto canViewOrEditLinkedChat = isChannel - && (channel->linkedChat() + const auto canViewOrEditDiscussionLink = isChannel + && (channel->discussionLink() || (channel->isBroadcast() && channel->canEditInformation())); ::AddSkip(_controls.buttonsLayout, 0); @@ -1366,8 +1366,8 @@ void Controller::fillManageSection() { //} else if (canEditInviteLinks) { // fillInviteLinkButton(); } - if (canViewOrEditLinkedChat) { - fillLinkedChatButton(); + if (canViewOrEditDiscussionLink) { + fillDiscussionLinkButton(); } if (canEditPreHistoryHidden) { fillHistoryVisibilityButton(); @@ -1387,7 +1387,7 @@ void Controller::fillManageSection() { || canEditForum || canEditColorIndex //|| canEditInviteLinks - || canViewOrEditLinkedChat + || canViewOrEditDiscussionLink || canEditType) { ::AddSkip(_controls.buttonsLayout); } @@ -1971,7 +1971,7 @@ std::optional Controller::validate() const { auto result = Saving(); if (validateUsernamesOrder(result) && validateUsername(result) - && validateLinkedChat(result) + && validateDiscussionLink(result) && validateTitle(result) && validateDescription(result) && validateHistoryVisibility(result) @@ -2013,11 +2013,11 @@ bool Controller::validateUsername(Saving &to) const { return true; } -bool Controller::validateLinkedChat(Saving &to) const { - if (!_linkedChatSavedValue) { +bool Controller::validateDiscussionLink(Saving &to) const { + if (!_discussionLinkSavedValue) { return true; } - to.linkedChat = *_linkedChatSavedValue; + to.discussionLink = *_discussionLinkSavedValue; return true; } @@ -2118,7 +2118,7 @@ void Controller::save() { _savingData = *saving; pushSaveStage([=] { saveUsernamesOrder(); }); pushSaveStage([=] { saveUsername(); }); - pushSaveStage([=] { saveLinkedChat(); }); + pushSaveStage([=] { saveDiscussionLink(); }); pushSaveStage([=] { saveTitle(); }); pushSaveStage([=] { saveDescription(); }); pushSaveStage([=] { saveHistoryVisibility(); }); @@ -2241,34 +2241,34 @@ void Controller::saveUsername() { }).send(); } -void Controller::saveLinkedChat() { +void Controller::saveDiscussionLink() { const auto channel = _peer->asChannel(); if (!channel) { return continueSave(); } - if (!_savingData.linkedChat - || *_savingData.linkedChat == channel->linkedChat()) { + if (!_savingData.discussionLink + || *_savingData.discussionLink == channel->discussionLink()) { return continueSave(); } - const auto chat = *_savingData.linkedChat; + const auto chat = *_savingData.discussionLink; if (channel->isBroadcast() && chat && chat->hiddenPreHistory()) { togglePreHistoryHidden( chat, false, - [=] { saveLinkedChat(); }, + [=] { saveDiscussionLink(); }, [=] { cancelSave(); }); return; } - const auto input = *_savingData.linkedChat - ? (*_savingData.linkedChat)->inputChannel + const auto input = *_savingData.discussionLink + ? (*_savingData.discussionLink)->inputChannel : MTP_inputChannelEmpty(); _api.request(MTPchannels_SetDiscussionGroup( (channel->isBroadcast() ? channel->inputChannel : input), (channel->isBroadcast() ? input : channel->inputChannel) )).done([=] { - channel->setLinkedChat(*_savingData.linkedChat); + channel->setDiscussionLink(*_savingData.discussionLink); continueSave(); }).fail([=](const MTP::Error &error) { _navigation->showToast(error.type()); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 5f562f5313..58cfd01fcf 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -1138,7 +1138,7 @@ void ShowEditPeerPermissionsBox( result.emplace( Flag::ChangeInfo | Flag::PinMessages, tr::lng_rights_permission_unavailable(tr::now)); - } else if (channel->isMegagroup() && channel->linkedChat()) { + } else if (channel->isMegagroup() && channel->discussionLink()) { result.emplace( Flag::ChangeInfo | Flag::PinMessages, tr::lng_rights_permission_in_discuss(tr::now)); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index b77a9e1d29..2b3665aac6 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -220,7 +220,7 @@ void Controller::createContent() { const auto wrap = _controls.whoSendWrap->entity(); Ui::AddSkip(wrap); - if (_dataSavedValue->hasLinkedChat) { + if (_dataSavedValue->hasDiscussionLink) { Ui::AddSubsectionTitle(wrap, tr::lng_manage_peer_send_title()); _controls.joinToWrite = wrap->add(EditPeerInfoBox::CreateButton( @@ -498,7 +498,7 @@ void Controller::privacyChanged(Privacy value) { } _controls.whoSendWrap->toggle( (value == Privacy::HasUsername - || (_dataSavedValue && _dataSavedValue->hasLinkedChat)), + || (_dataSavedValue && _dataSavedValue->hasDiscussionLink)), anim::type::instant); }; const auto refreshVisibilities = [&] { diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h index ae77872074..7b9aba6f9a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.h @@ -37,7 +37,7 @@ struct EditPeerTypeData { Privacy privacy = Privacy::NoUsername; QString username; std::vector usernamesOrder; - bool hasLinkedChat = false; + bool hasDiscussionLink = false; bool noForwards = false; bool joinToWrite = false; bool requestToJoin = false; diff --git a/Telegram/SourceFiles/data/data_changes.h b/Telegram/SourceFiles/data/data_changes.h index 39a654d3c0..2eb84caedf 100644 --- a/Telegram/SourceFiles/data/data_changes.h +++ b/Telegram/SourceFiles/data/data_changes.h @@ -111,7 +111,7 @@ struct PeerUpdate { ChannelAmIn = (1ULL << 45), StickersSet = (1ULL << 46), EmojiSet = (1ULL << 47), - ChannelLinkedChat = (1ULL << 48), + DiscussionLink = (1ULL << 48), ChannelLocation = (1ULL << 49), Slowmode = (1ULL << 50), GroupCall = (1ULL << 51), diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index f54562516e..8761065915 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -275,22 +275,22 @@ const ChannelLocation *ChannelData::getLocation() const { return mgInfo ? mgInfo->getLocation() : nullptr; } -void ChannelData::setLinkedChat(ChannelData *linked) { - if (_linkedChat != linked) { - _linkedChat = linked; +void ChannelData::setDiscussionLink(ChannelData *linked) { + if (_discussionLink != linked) { + _discussionLink = linked; if (const auto history = owner().historyLoaded(this)) { history->forceFullResize(); } - session().changes().peerUpdated(this, UpdateFlag::ChannelLinkedChat); + session().changes().peerUpdated(this, UpdateFlag::DiscussionLink); } } -ChannelData *ChannelData::linkedChat() const { - return _linkedChat.value_or(nullptr); +ChannelData *ChannelData::discussionLink() const { + return _discussionLink.value_or(nullptr); } -bool ChannelData::linkedChatKnown() const { - return _linkedChat.has_value(); +bool ChannelData::discussionLinkKnown() const { + return _discussionLink.has_value(); } void ChannelData::setMembersCount(int newMembersCount) { @@ -1236,9 +1236,9 @@ void ApplyChannelUpdate( channel->setLocation(MTP_channelLocationEmpty()); } if (const auto chat = update.vlinked_chat_id()) { - channel->setLinkedChat(channel->owner().channelLoaded(chat->v)); + channel->setDiscussionLink(channel->owner().channelLoaded(chat->v)); } else { - channel->setLinkedChat(nullptr); + channel->setDiscussionLink(nullptr); } if (const auto history = channel->owner().historyLoaded(channel)) { if (const auto available = update.vavailable_min_id()) { diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index 61591122ac..b4f99b5243 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -409,9 +409,9 @@ public: void setLocation(const MTPChannelLocation &data); [[nodiscard]] const ChannelLocation *getLocation() const; - void setLinkedChat(ChannelData *linked); - [[nodiscard]] ChannelData *linkedChat() const; - [[nodiscard]] bool linkedChatKnown() const; + void setDiscussionLink(ChannelData *link); + [[nodiscard]] ChannelData *discussionLink() const; + [[nodiscard]] bool discussionLinkKnown() const; void ptsInit(int32 pts) { _ptsWaiter.init(pts); @@ -570,7 +570,7 @@ private: std::vector _unavailableReasons; std::unique_ptr _invitePeek; QString _inviteLink; - std::optional _linkedChat; + std::optional _discussionLink; Data::AllowedReactions _allowedReactions; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index b35191d103..e5f4e6501f 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1044,14 +1044,14 @@ void HistoryItem::setGroupId(MessageGroupId groupId) { _history->owner().groups().registerMessage(this); } -bool HistoryItem::checkCommentsLinkedChat(ChannelId id) const { +bool HistoryItem::checkDiscussionLink(ChannelId id) const { if (!id) { return true; } else if (const auto channel = _history->peer->asChannel()) { - if (channel->linkedChatKnown() + if (channel->discussionLinkKnown() || !(channel->flags() & ChannelDataFlag::HasLink)) { - const auto linked = channel->linkedChat(); - if (!linked || peerToChannel(linked->id) != id) { + const auto link = channel->discussionLink(); + if (!link || peerToChannel(link->id) != id) { return false; } } @@ -1154,7 +1154,7 @@ bool HistoryItem::areCommentsUnread() const { const auto views = Get(); if (!views || !views->commentsMegagroupId - || !checkCommentsLinkedChat(views->commentsMegagroupId)) { + || !checkDiscussionLink(views->commentsMegagroupId)) { return false; } const auto till = views->commentsInboxReadTillId; @@ -3301,7 +3301,7 @@ int HistoryItem::viewsCount() const { int HistoryItem::repliesCount() const { if (const auto views = Get()) { - if (!checkCommentsLinkedChat(views->commentsMegagroupId)) { + if (!checkDiscussionLink(views->commentsMegagroupId)) { return 0; } return std::max(views->replies.count, 0); @@ -3312,7 +3312,7 @@ int HistoryItem::repliesCount() const { bool HistoryItem::repliesAreComments() const { if (const auto views = Get()) { return (views->commentsMegagroupId != 0) - && checkCommentsLinkedChat(views->commentsMegagroupId); + && checkDiscussionLink(views->commentsMegagroupId); } return false; } @@ -3805,9 +3805,9 @@ void HistoryItem::createComponents(CreateConfig &&config) { && isSending() && config.markup.isNull()) { 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.channelId = peerToChannel(linked->id); + config.replies.channelId = peerToChannel(link->id); } } } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 05db24526e..a12c5e46de 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -597,7 +597,7 @@ private: return _flags & MessageFlag::Legacy; } - [[nodiscard]] bool checkCommentsLinkedChat(ChannelId id) const; + [[nodiscard]] bool checkDiscussionLink(ChannelId id) const; void setReplyMarkup(HistoryMessageMarkupData &&markup); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 4d34fd0b86..e75ccda787 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -805,7 +805,7 @@ HistoryWidget::HistoryWidget( | PeerUpdateFlag::OnlineStatus | PeerUpdateFlag::Notifications | PeerUpdateFlag::ChannelAmIn - | PeerUpdateFlag::ChannelLinkedChat + | PeerUpdateFlag::DiscussionLink | PeerUpdateFlag::Slowmode | PeerUpdateFlag::BotStartToken | PeerUpdateFlag::MessagesTTL @@ -877,7 +877,7 @@ HistoryWidget::HistoryWidget( | PeerUpdateFlag::OnlineStatus | PeerUpdateFlag::Rights | PeerUpdateFlag::ChannelAmIn - | PeerUpdateFlag::ChannelLinkedChat)) { + | PeerUpdateFlag::DiscussionLink)) { handlePeerUpdate(); } if (flags & PeerUpdateFlag::MessagesTTL) { diff --git a/Telegram/SourceFiles/info/info.style b/Telegram/SourceFiles/info/info.style index 9c841e39d9..3097de7a26 100644 --- a/Telegram/SourceFiles/info/info.style +++ b/Telegram/SourceFiles/info/info.style @@ -572,12 +572,12 @@ infoBlockButton: SettingsButton(infoProfileButton) { textFg: attentionButtonFg; textFgOver: attentionButtonFgOver; } -infoCreateLinkedChatButton: SettingsButton(infoProfileButton) { +infoCreateDiscussionLinkButton: SettingsButton(infoProfileButton) { padding: margins(74px, 10px, 8px, 8px); textFg: lightButtonFg; textFgOver: lightButtonFgOver; } -infoUnlinkChatButton: SettingsButton(infoCreateLinkedChatButton) { +infoUnlinkDiscussionLinkButton: SettingsButton(infoCreateDiscussionLinkButton) { textFg: attentionButtonFg; textFgOver: attentionButtonFgOver; } diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 0bfa52bfc1..166ebb254d 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -839,7 +839,7 @@ void Filler::addViewDiscussion() { if (!channel) { return; } - const auto chat = channel->linkedChat(); + const auto chat = channel->discussionLink(); if (!chat) { return; } diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 5e55a41111..cb43649a0d 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -2428,7 +2428,7 @@ void SessionController::showPeer(not_null peer, MsgId msgId) { if (!clickedChannel->isPublic() && !clickedChannel->amIn() && (!currentPeer->isChannel() - || currentPeer->asChannel()->linkedChat() + || currentPeer->asChannel()->discussionLink() != clickedChannel)) { MainWindowShow(this).showToast(peer->isMegagroup() ? tr::lng_group_not_accessible(tr::now)