diff --git a/Telegram/SourceFiles/api/api_invite_links.cpp b/Telegram/SourceFiles/api/api_invite_links.cpp index 986ccaa08..e43ad32a7 100644 --- a/Telegram/SourceFiles/api/api_invite_links.cpp +++ b/Telegram/SourceFiles/api/api_invite_links.cpp @@ -41,27 +41,26 @@ void RemovePermanent(PeerInviteLinks &links) { } // namespace -// #TODO links -//JoinedByLinkSlice ParseJoinedByLinkSlice( -// not_null peer, -// const MTPmessages_ChatInviteImporters &slice) { -// auto result = JoinedByLinkSlice(); -// slice.match([&](const MTPDmessages_chatInviteImporters &data) { -// auto &owner = peer->session().data(); -// owner.processUsers(data.vusers()); -// result.count = data.vcount().v; -// result.users.reserve(data.vimporters().v.size()); -// for (const auto importer : data.vimporters().v) { -// importer.match([&](const MTPDchatInviteImporter &data) { -// result.users.push_back({ -// .user = owner.user(data.vuser_id().v), -// .date = data.vdate().v, -// }); -// }); -// } -// }); -// return result; -//} +JoinedByLinkSlice ParseJoinedByLinkSlice( + not_null peer, + const MTPmessages_ChatInviteImporters &slice) { + auto result = JoinedByLinkSlice(); + slice.match([&](const MTPDmessages_chatInviteImporters &data) { + auto &owner = peer->session().data(); + owner.processUsers(data.vusers()); + result.count = data.vcount().v; + result.users.reserve(data.vimporters().v.size()); + for (const auto importer : data.vimporters().v) { + importer.match([&](const MTPDchatInviteImporter &data) { + result.users.push_back({ + .user = owner.user(data.vuser_id().v), + .date = data.vdate().v, + }); + }); + } + }); + return result; +} InviteLinks::InviteLinks(not_null api) : _api(api) { } @@ -216,51 +215,55 @@ void InviteLinks::performEdit( if (done) { callbacks.push_back(std::move(done)); } - // #TODO links - //using Flag = MTPmessages_EditExportedChatInvite::Flag; - //_api->request(MTPmessages_EditExportedChatInvite( - // MTP_flags((revoke ? Flag::f_revoked : Flag(0)) - // | ((!revoke && expireDate) ? Flag::f_expire_date : Flag(0)) - // | ((!revoke && usageLimit) ? Flag::f_usage_limit : Flag(0))), - // peer->input, - // MTP_string(link), - // MTP_int(expireDate), - // MTP_int(usageLimit) - //)).done([=](const MTPmessages_ExportedChatInvite &result) { - // const auto callbacks = _editCallbacks.take(key); - // const auto peer = key.peer; - // result.match([&](const MTPDmessages_exportedChatInvite &data) { - // _api->session().data().processUsers(data.vusers()); - // const auto link = parse(peer, data.vinvite()); - // auto i = _firstSlices.find(peer); - // if (i != end(_firstSlices)) { - // const auto j = ranges::find( - // i->second.links, - // key.link, - // &Link::link); - // if (j != end(i->second.links)) { - // if (link.revoked && !j->revoked) { - // i->second.links.erase(j); - // if (i->second.count > 0) { - // --i->second.count; - // } - // } else { - // *j = link; - // } - // } - // } - // for (const auto &callback : *callbacks) { - // callback(link); - // } - // _updates.fire(Update{ - // .peer = peer, - // .was = key.link, - // .now = link, - // }); - // }); - //}).fail([=](const RPCError &error) { - // _editCallbacks.erase(key); - //}).send(); + using Flag = MTPmessages_EditExportedChatInvite::Flag; + _api->request(MTPmessages_EditExportedChatInvite( + MTP_flags((revoke ? Flag::f_revoked : Flag(0)) + | ((!revoke && expireDate) ? Flag::f_expire_date : Flag(0)) + | ((!revoke && usageLimit) ? Flag::f_usage_limit : Flag(0))), + peer->input, + MTP_string(link), + MTP_int(expireDate), + MTP_int(usageLimit) + )).done([=](const MTPmessages_ExportedChatInvite &result) { + const auto callbacks = _editCallbacks.take(key); + const auto peer = key.peer; + result.match([&](const auto &data) { + _api->session().data().processUsers(data.vusers()); + const auto link = parse(peer, data.vinvite()); + auto i = _firstSlices.find(peer); + if (i != end(_firstSlices)) { + const auto j = ranges::find( + i->second.links, + key.link, + &Link::link); + if (j != end(i->second.links)) { + if (link.revoked && !j->revoked) { + i->second.links.erase(j); + if (i->second.count > 0) { + --i->second.count; + } + } else { + *j = link; + } + } + } + for (const auto &callback : *callbacks) { + callback(link); + } + _updates.fire(Update{ + .peer = peer, + .was = key.link, + .now = link, + }); + + using Replaced = MTPDmessages_exportedChatInviteReplaced; + if constexpr (Replaced::Is()) { + prepend(peer, data.vnew_invite()); + } + }); + }).fail([=](const RPCError &error) { + _editCallbacks.erase(key); + }).send(); } void InviteLinks::revoke( @@ -272,8 +275,13 @@ void InviteLinks::revoke( void InviteLinks::revokePermanent( not_null peer, - Fn done) { - performCreate(peer, std::move(done), true); + Fn done) { + const auto callback = [=](auto&&) { done(); }; + if (const auto permanent = lookupPermanent(peer)) { + performEdit(peer, permanent->link, callback, true); + } else { + performCreate(peer, callback, true); + } } void InviteLinks::destroy( @@ -294,24 +302,23 @@ void InviteLinks::destroy( if (done) { callbacks.push_back(std::move(done)); } - // #TODO links - //_api->request(MTPmessages_DeleteExportedChatInvite( - // peer->input, - // MTP_string(link) - //)).done([=](const MTPBool &result) { - // const auto callbacks = _deleteCallbacks.take(key); - // if (callbacks) { - // for (const auto &callback : *callbacks) { - // callback(); - // } - // } - // _updates.fire(Update{ - // .peer = peer, - // .was = key.link, - // }); - //}).fail([=](const RPCError &error) { - // _deleteCallbacks.erase(key); - //}).send(); + _api->request(MTPmessages_DeleteExportedChatInvite( + peer->input, + MTP_string(link) + )).done([=](const MTPBool &result) { + const auto callbacks = _deleteCallbacks.take(key); + if (callbacks) { + for (const auto &callback : *callbacks) { + callback(); + } + } + _updates.fire(Update{ + .peer = peer, + .was = key.link, + }); + }).fail([=](const RPCError &error) { + _deleteCallbacks.erase(key); + }).send(); } void InviteLinks::destroyAllRevoked( @@ -328,62 +335,61 @@ void InviteLinks::destroyAllRevoked( if (done) { callbacks.push_back(std::move(done)); } - // #TODO links - //_api->request(MTPmessages_DeleteRevokedExportedChatInvites( - // peer->input - //)).done([=](const MTPBool &result) { - // if (const auto callbacks = _deleteRevokedCallbacks.take(peer)) { - // for (const auto &callback : *callbacks) { - // callback(); - // } - // } - // _allRevokedDestroyed.fire_copy(peer); - //}).fail([=](const RPCError &error) { - //}).send(); + _api->request(MTPmessages_DeleteRevokedExportedChatInvites( + peer->input, + MTP_inputUserSelf() + )).done([=](const MTPBool &result) { + if (const auto callbacks = _deleteRevokedCallbacks.take(peer)) { + for (const auto &callback : *callbacks) { + callback(); + } + } + _allRevokedDestroyed.fire_copy(peer); + }).fail([=](const RPCError &error) { + }).send(); } void InviteLinks::requestLinks(not_null peer) { if (_firstSliceRequests.contains(peer)) { return; } - // #TODO links - //const auto requestId = _api->request(MTPmessages_GetExportedChatInvites( - // MTP_flags(0), - // peer->input, - // MTPInputUser(), // admin_id - // MTPint(), // offset_date - // MTPstring(), // offset_link - // MTP_int(kFirstPage) - //)).done([=](const MTPmessages_ExportedChatInvites &result) { - // _firstSliceRequests.remove(peer); - // auto slice = parseSlice(peer, result); - // auto i = _firstSlices.find(peer); - // const auto permanent = (i != end(_firstSlices)) - // ? lookupPermanent(i->second) - // : nullptr; - // if (!permanent) { - // BringPermanentToFront(slice); - // const auto j = _firstSlices.emplace_or_assign( - // peer, - // std::move(slice)).first; - // if (const auto permanent = lookupPermanent(j->second)) { - // editPermanentLink(peer, permanent->link); - // } - // } else { - // RemovePermanent(slice); - // auto &existing = i->second.links; - // existing.erase(begin(existing) + 1, end(existing)); - // existing.insert( - // end(existing), - // begin(slice.links), - // end(slice.links)); - // i->second.count = std::max(slice.count, int(existing.size())); - // } - // notify(peer); - //}).fail([=](const RPCError &error) { - // _firstSliceRequests.remove(peer); - //}).send(); - //_firstSliceRequests.emplace(peer, requestId); + const auto requestId = _api->request(MTPmessages_GetExportedChatInvites( + MTP_flags(0), + peer->input, + MTP_inputUserSelf(), + MTPint(), // offset_date + MTPstring(), // offset_link + MTP_int(kFirstPage) + )).done([=](const MTPmessages_ExportedChatInvites &result) { + _firstSliceRequests.remove(peer); + auto slice = parseSlice(peer, result); + auto i = _firstSlices.find(peer); + const auto permanent = (i != end(_firstSlices)) + ? lookupPermanent(i->second) + : nullptr; + if (!permanent) { + BringPermanentToFront(slice); + const auto j = _firstSlices.emplace_or_assign( + peer, + std::move(slice)).first; + if (const auto permanent = lookupPermanent(j->second)) { + editPermanentLink(peer, permanent->link); + } + } else { + RemovePermanent(slice); + auto &existing = i->second.links; + existing.erase(begin(existing) + 1, end(existing)); + existing.insert( + end(existing), + begin(slice.links), + end(slice.links)); + i->second.count = std::max(slice.count, int(existing.size())); + } + notify(peer); + }).fail([=](const RPCError &error) { + _firstSliceRequests.remove(peer); + }).send(); + _firstSliceRequests.emplace(peer, requestId); } std::optional InviteLinks::lookupJoinedFirstSlice( @@ -444,23 +450,23 @@ rpl::producer<> InviteLinks::allRevokedDestroyed( } void InviteLinks::requestJoinedFirstSlice(LinkKey key) { - //if (_firstJoinedRequests.contains(key)) { // #TODO links - // return; - //} - //const auto requestId = _api->request(MTPmessages_GetChatInviteImporters( - // key.peer->input, - // MTP_string(key.link), - // MTP_int(0), // offset_date - // MTP_inputUserEmpty(), // offset_user - // MTP_int(kJoinedFirstPage) - //)).done([=](const MTPmessages_ChatInviteImporters &result) { - // _firstJoinedRequests.remove(key); - // _firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result); - // _joinedFirstSliceLoaded.fire_copy(key); - //}).fail([=](const RPCError &error) { - // _firstJoinedRequests.remove(key); - //}).send(); - //_firstJoinedRequests.emplace(key, requestId); + if (_firstJoinedRequests.contains(key)) { + return; + } + const auto requestId = _api->request(MTPmessages_GetChatInviteImporters( + key.peer->input, + MTP_string(key.link), + MTP_int(0), // offset_date + MTP_inputUserEmpty(), // offset_user + MTP_int(kJoinedFirstPage) + )).done([=](const MTPmessages_ChatInviteImporters &result) { + _firstJoinedRequests.remove(key); + _firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result); + _joinedFirstSliceLoaded.fire_copy(key); + }).fail([=](const RPCError &error) { + _firstJoinedRequests.remove(key); + }).send(); + _firstJoinedRequests.emplace(key, requestId); } void InviteLinks::setPermanent( @@ -548,27 +554,27 @@ auto InviteLinks::links(not_null peer) const -> const Links & { const auto i = _firstSlices.find(peer); return (i != end(_firstSlices)) ? i->second : kEmpty; } -// #TODO links -//auto InviteLinks::parseSlice( -// not_null peer, -// const MTPmessages_ExportedChatInvites &slice) const -> Links { -// auto i = _firstSlices.find(peer); -// const auto permanent = (i != end(_firstSlices)) -// ? lookupPermanent(i->second) -// : nullptr; -// auto result = Links(); -// slice.match([&](const MTPDmessages_exportedChatInvites &data) { -// peer->session().data().processUsers(data.vusers()); -// result.count = data.vcount().v; -// for (const auto &invite : data.vinvites().v) { -// const auto link = parse(peer, invite); -// if (!permanent || link.link != permanent->link) { -// result.links.push_back(link); -// } -// } -// }); -// return result; -//} + +auto InviteLinks::parseSlice( + not_null peer, + const MTPmessages_ExportedChatInvites &slice) const -> Links { + auto i = _firstSlices.find(peer); + const auto permanent = (i != end(_firstSlices)) + ? lookupPermanent(i->second) + : nullptr; + auto result = Links(); + slice.match([&](const MTPDmessages_exportedChatInvites &data) { + peer->session().data().processUsers(data.vusers()); + result.count = data.vcount().v; + for (const auto &invite : data.vinvites().v) { + const auto link = parse(peer, invite); + if (!permanent || link.link != permanent->link) { + result.links.push_back(link); + } + } + }); + return result; +} auto InviteLinks::parse( not_null peer, @@ -582,7 +588,7 @@ auto InviteLinks::parse( .expireDate = data.vexpire_date().value_or_empty(), .usageLimit = data.vusage_limit().value_or_empty(), .usage = data.vusage().value_or_empty(), - .permanent = true,//data.is_permanent(), // #TODO links + .permanent = data.is_permanent(), .revoked = data.is_revoked(), }; }); @@ -594,23 +600,22 @@ void InviteLinks::requestMoreLinks( const QString &lastLink, bool revoked, Fn done) { - // #TODO links - //using Flag = MTPmessages_GetExportedChatInvites::Flag; - //_api->request(MTPmessages_GetExportedChatInvites( - // MTP_flags(Flag::f_offset_link - // | (revoked ? Flag::f_revoked : Flag(0))), - // peer->input, - // MTPInputUser(), // admin_id, - // MTP_int(lastDate), - // MTP_string(lastLink), - // MTP_int(kPerPage) - //)).done([=](const MTPmessages_ExportedChatInvites &result) { - // auto slice = parseSlice(peer, result); - // RemovePermanent(slice); - // done(std::move(slice)); - //}).fail([=](const RPCError &error) { - // done(Links()); - //}).send(); + using Flag = MTPmessages_GetExportedChatInvites::Flag; + _api->request(MTPmessages_GetExportedChatInvites( + MTP_flags(Flag::f_offset_link + | (revoked ? Flag::f_revoked : Flag(0))), + peer->input, + MTP_inputUserSelf(), + MTP_int(lastDate), + MTP_string(lastLink), + MTP_int(kPerPage) + )).done([=](const MTPmessages_ExportedChatInvites &result) { + auto slice = parseSlice(peer, result); + RemovePermanent(slice); + done(std::move(slice)); + }).fail([=](const RPCError &error) { + done(Links()); + }).send(); } void InviteLinks::editPermanentLink( diff --git a/Telegram/SourceFiles/api/api_invite_links.h b/Telegram/SourceFiles/api/api_invite_links.h index e7089dbcf..e84447a42 100644 --- a/Telegram/SourceFiles/api/api_invite_links.h +++ b/Telegram/SourceFiles/api/api_invite_links.h @@ -43,10 +43,10 @@ struct InviteLinkUpdate { QString was; std::optional now; }; -// #TODO links -//[[nodiscard]] JoinedByLinkSlice ParseJoinedByLinkSlice( -// not_null peer, -// const MTPmessages_ChatInviteImporters &slice); + +[[nodiscard]] JoinedByLinkSlice ParseJoinedByLinkSlice( + not_null peer, + const MTPmessages_ChatInviteImporters &slice); class InviteLinks final { public: @@ -73,7 +73,7 @@ public: Fn done = nullptr); void revokePermanent( not_null peer, - Fn done = nullptr); + Fn done = nullptr); void destroy( not_null peer, const QString &link, @@ -124,10 +124,9 @@ private: } }; - // #TODO links - //[[nodiscard]] Links parseSlice( - // not_null peer, - // const MTPmessages_ExportedChatInvites &slice) const; + [[nodiscard]] Links parseSlice( + not_null peer, + const MTPmessages_ExportedChatInvites &slice) const; [[nodiscard]] Link parse( not_null peer, const MTPExportedChatInvite &invite) const; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 54dfa5334..bf6f6596c 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -332,7 +332,7 @@ private: void showEditLinkedChatBox(); void fillPrivacyTypeButton(); void fillLinkedChatButton(); - void fillInviteLinkButton(); + //void fillInviteLinkButton(); void fillSignaturesButton(); void fillHistoryVisibilityButton(); void fillManageSection(); @@ -798,20 +798,20 @@ void Controller::fillLinkedChatButton() { [=] { showEditLinkedChatBox(); }); _linkedChatUpdates.fire_copy(*_linkedChatSavedValue); } - -void Controller::fillInviteLinkButton() { - Expects(_controls.buttonsLayout != nullptr); - - const auto buttonCallback = [=] { - Ui::show(Box(_peer), Ui::LayerOption::KeepOther); - }; - - AddButtonWithText( - _controls.buttonsLayout, - tr::lng_profile_invite_link_section(), - rpl::single(QString()), //Empty text. - buttonCallback); -} +// +//void Controller::fillInviteLinkButton() { +// Expects(_controls.buttonsLayout != nullptr); +// +// const auto buttonCallback = [=] { +// Ui::show(Box(_peer), Ui::LayerOption::KeepOther); +// }; +// +// AddButtonWithText( +// _controls.buttonsLayout, +// tr::lng_profile_invite_link_section(), +// rpl::single(QString()), //Empty text. +// buttonCallback); +//} void Controller::fillSignaturesButton() { Expects(_controls.buttonsLayout != nullptr); @@ -959,8 +959,8 @@ void Controller::fillManageSection() { if (canEditUsername) { fillPrivacyTypeButton(); - } else if (canEditInviteLinks) { - fillInviteLinkButton(); + //} else if (canEditInviteLinks) { + // fillInviteLinkButton(); } if (canViewOrEditLinkedChat) { fillLinkedChatButton(); @@ -995,29 +995,29 @@ void Controller::fillManageSection() { [=] { ShowEditPermissions(_navigation, _peer); }, st::infoIconPermissions); } - //if (canEditInviteLinks) { // #TODO links - // AddButtonWithCount( - // _controls.buttonsLayout, - // tr::lng_manage_peer_invite_links(), - // Info::Profile::MigratedOrMeValue( - // _peer - // ) | rpl::map([=](not_null peer) { - // peer->session().api().inviteLinks().requestLinks(peer); - // return peer->session().changes().peerUpdates( - // peer, - // Data::PeerUpdate::Flag::InviteLinks - // ) | rpl::map([=] { - // return peer->session().api().inviteLinks().links( - // peer).count; - // }); - // }) | rpl::flatten_latest( - // ) | ToPositiveNumberString(), - // [=] { Ui::show( - // Box(ManageInviteLinksBox, _peer), - // Ui::LayerOption::KeepOther); - // }, - // st::infoIconInviteLinks); - //} + if (canEditInviteLinks) { + AddButtonWithCount( + _controls.buttonsLayout, + tr::lng_manage_peer_invite_links(), + Info::Profile::MigratedOrMeValue( + _peer + ) | rpl::map([=](not_null peer) { + peer->session().api().inviteLinks().requestLinks(peer); + return peer->session().changes().peerUpdates( + peer, + Data::PeerUpdate::Flag::InviteLinks + ) | rpl::map([=] { + return peer->session().api().inviteLinks().links( + peer).count; + }); + }) | rpl::flatten_latest( + ) | ToPositiveNumberString(), + [=] { Ui::show( + Box(ManageInviteLinksBox, _peer), + Ui::LayerOption::KeepOther); + }, + st::infoIconInviteLinks); + } if (canViewAdmins) { AddButtonWithCount( _controls.buttonsLayout, diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp index df593d0d7..12af5097a 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_link.cpp @@ -222,22 +222,21 @@ void Controller::loadMoreRows() { if (_requestId || _allLoaded) { return; } - _allLoaded = true; // #TODO links - //_requestId = _api.request(MTPmessages_GetChatInviteImporters( - // _peer->input, - // MTP_string(_data.link), - // MTP_int(_lastUser ? _lastUser->date : 0), - // _lastUser ? _lastUser->user->inputUser : MTP_inputUserEmpty(), - // MTP_int(_lastUser ? kPerPage : kFirstPage) - //)).done([=](const MTPmessages_ChatInviteImporters &result) { - // _requestId = 0; - // auto slice = Api::ParseJoinedByLinkSlice(_peer, result); - // _allLoaded = slice.users.empty(); - // appendSlice(slice); - //}).fail([=](const RPCError &error) { - // _requestId = 0; - // _allLoaded = true; - //}).send(); + _requestId = _api.request(MTPmessages_GetChatInviteImporters( + _peer->input, + MTP_string(_data.link), + MTP_int(_lastUser ? _lastUser->date : 0), + _lastUser ? _lastUser->user->inputUser : MTP_inputUserEmpty(), + MTP_int(_lastUser ? kPerPage : kFirstPage) + )).done([=](const MTPmessages_ChatInviteImporters &result) { + _requestId = 0; + auto slice = Api::ParseJoinedByLinkSlice(_peer, result); + _allLoaded = slice.users.empty(); + appendSlice(slice); + }).fail([=](const RPCError &error) { + _requestId = 0; + _allLoaded = true; + }).send(); } void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) { @@ -318,7 +317,7 @@ void AddPermanentLinkBlock( const auto revokeLink = crl::guard(weak, [=] { const auto box = std::make_shared>(); const auto done = crl::guard(weak, [=] { - const auto close = [=](auto&&) { + const auto close = [=] { if (*box) { (*box)->closeBox(); } diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp index 4f8f08f5a..a28ea6fa1 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_invite_links.cpp @@ -441,8 +441,10 @@ Controller::Controller(not_null peer, bool revoked) delegate()->peerListRefreshRows(); } } else if (update.was.isEmpty()) { - prependRow(*update.now, now); - delegate()->peerListRefreshRows(); + if (!update.now->permanent || update.now->revoked) { + prependRow(*update.now, now); + delegate()->peerListRefreshRows(); + } } else { updateRow(*update.now, now); } @@ -581,6 +583,8 @@ void Controller::updateRow(const InviteLinkData &data, TimeId now) { real->update(data, now); checkExpiringTimer(real); delegate()->peerListUpdateRow(row); + } else if (_revoked) { + prependRow(data, now); } } diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index d587ecbca..dcc40a5ee 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -186,20 +186,20 @@ void Controller::createContent() { _wrap->add(createUsernameEdit()); } - //using namespace Settings; // #TODO links - //AddSkip(_wrap.get()); - //_wrap->add(EditPeerInfoBox::CreateButton( - // _wrap.get(), - // tr::lng_group_invite_manage(), - // rpl::single(QString()), - // [=] { Ui::show( - // Box(ManageInviteLinksBox, _peer), - // Ui::LayerOption::KeepOther); - // }, - // st::manageGroupButton, - // &st::infoIconInviteLinks)); - //AddSkip(_wrap.get()); - //AddDividerText(_wrap.get(), tr::lng_group_invite_manage_about()); + using namespace Settings; + AddSkip(_wrap.get()); + _wrap->add(EditPeerInfoBox::CreateButton( + _wrap.get(), + tr::lng_group_invite_manage(), + rpl::single(QString()), + [=] { Ui::show( + Box(ManageInviteLinksBox, _peer), + Ui::LayerOption::KeepOther); + }, + st::manageGroupButton, + &st::infoIconInviteLinks)); + AddSkip(_wrap.get()); + AddDividerText(_wrap.get(), tr::lng_group_invite_manage_about()); if (_linkOnly) { _controls.inviteLinkWrap->show(anim::type::instant); @@ -564,9 +564,8 @@ object_ptr Controller::createInviteLinkBlock() { if (_privacySavedValue) { AddSkip(container); - AddSubsectionTitle(container, tr::lng_create_invite_link_title()); + AddSubsectionTitle(container, tr::lng_create_permanent_link_title()); } - // tr::lng_create_permanent_link_title()); // #TODO links AddPermanentLinkBlock(container, _peer); AddSkip(container); @@ -577,16 +576,6 @@ object_ptr Controller::createInviteLinkBlock() { ? tr::lng_group_invite_about_permanent_group() : tr::lng_group_invite_about_permanent_channel())); - if (_peer->wasFullUpdated()) { - const auto link = _peer->isChat() - ? _peer->asChat()->inviteLink() - : _peer->asChannel()->inviteLink(); - if (link.isEmpty()) { - // #TODO links remove this auto-export link. - _peer->session().api().inviteLinks().revokePermanent(_peer); - } - } - return result; }