Return rich invite links section.

This commit is contained in:
John Preston 2021-02-02 14:43:38 +04:00
parent 502a3ca70f
commit 9d3edb785c
6 changed files with 282 additions and 286 deletions

View file

@ -41,27 +41,26 @@ void RemovePermanent(PeerInviteLinks &links) {
} // namespace } // namespace
// #TODO links JoinedByLinkSlice ParseJoinedByLinkSlice(
//JoinedByLinkSlice ParseJoinedByLinkSlice( not_null<PeerData*> peer,
// not_null<PeerData*> peer, const MTPmessages_ChatInviteImporters &slice) {
// const MTPmessages_ChatInviteImporters &slice) { auto result = JoinedByLinkSlice();
// auto result = JoinedByLinkSlice(); slice.match([&](const MTPDmessages_chatInviteImporters &data) {
// slice.match([&](const MTPDmessages_chatInviteImporters &data) { auto &owner = peer->session().data();
// auto &owner = peer->session().data(); owner.processUsers(data.vusers());
// owner.processUsers(data.vusers()); result.count = data.vcount().v;
// result.count = data.vcount().v; result.users.reserve(data.vimporters().v.size());
// result.users.reserve(data.vimporters().v.size()); for (const auto importer : data.vimporters().v) {
// for (const auto importer : data.vimporters().v) { importer.match([&](const MTPDchatInviteImporter &data) {
// importer.match([&](const MTPDchatInviteImporter &data) { result.users.push_back({
// result.users.push_back({ .user = owner.user(data.vuser_id().v),
// .user = owner.user(data.vuser_id().v), .date = data.vdate().v,
// .date = data.vdate().v, });
// }); });
// }); }
// } });
// }); return result;
// return result; }
//}
InviteLinks::InviteLinks(not_null<ApiWrap*> api) : _api(api) { InviteLinks::InviteLinks(not_null<ApiWrap*> api) : _api(api) {
} }
@ -216,51 +215,55 @@ void InviteLinks::performEdit(
if (done) { if (done) {
callbacks.push_back(std::move(done)); callbacks.push_back(std::move(done));
} }
// #TODO links using Flag = MTPmessages_EditExportedChatInvite::Flag;
//using Flag = MTPmessages_EditExportedChatInvite::Flag; _api->request(MTPmessages_EditExportedChatInvite(
//_api->request(MTPmessages_EditExportedChatInvite( MTP_flags((revoke ? Flag::f_revoked : Flag(0))
// MTP_flags((revoke ? Flag::f_revoked : Flag(0)) | ((!revoke && expireDate) ? Flag::f_expire_date : Flag(0))
// | ((!revoke && expireDate) ? Flag::f_expire_date : Flag(0)) | ((!revoke && usageLimit) ? Flag::f_usage_limit : Flag(0))),
// | ((!revoke && usageLimit) ? Flag::f_usage_limit : Flag(0))), peer->input,
// peer->input, MTP_string(link),
// MTP_string(link), MTP_int(expireDate),
// MTP_int(expireDate), MTP_int(usageLimit)
// MTP_int(usageLimit) )).done([=](const MTPmessages_ExportedChatInvite &result) {
//)).done([=](const MTPmessages_ExportedChatInvite &result) { const auto callbacks = _editCallbacks.take(key);
// const auto callbacks = _editCallbacks.take(key); const auto peer = key.peer;
// const auto peer = key.peer; result.match([&](const auto &data) {
// result.match([&](const MTPDmessages_exportedChatInvite &data) { _api->session().data().processUsers(data.vusers());
// _api->session().data().processUsers(data.vusers()); const auto link = parse(peer, data.vinvite());
// const auto link = parse(peer, data.vinvite()); auto i = _firstSlices.find(peer);
// auto i = _firstSlices.find(peer); if (i != end(_firstSlices)) {
// if (i != end(_firstSlices)) { const auto j = ranges::find(
// const auto j = ranges::find( i->second.links,
// i->second.links, key.link,
// key.link, &Link::link);
// &Link::link); if (j != end(i->second.links)) {
// if (j != end(i->second.links)) { if (link.revoked && !j->revoked) {
// if (link.revoked && !j->revoked) { i->second.links.erase(j);
// i->second.links.erase(j); if (i->second.count > 0) {
// if (i->second.count > 0) { --i->second.count;
// --i->second.count; }
// } } else {
// } else { *j = link;
// *j = link; }
// } }
// } }
// } for (const auto &callback : *callbacks) {
// for (const auto &callback : *callbacks) { callback(link);
// callback(link); }
// } _updates.fire(Update{
// _updates.fire(Update{ .peer = peer,
// .peer = peer, .was = key.link,
// .was = key.link, .now = link,
// .now = link, });
// });
// }); using Replaced = MTPDmessages_exportedChatInviteReplaced;
//}).fail([=](const RPCError &error) { if constexpr (Replaced::Is<decltype(data)>()) {
// _editCallbacks.erase(key); prepend(peer, data.vnew_invite());
//}).send(); }
});
}).fail([=](const RPCError &error) {
_editCallbacks.erase(key);
}).send();
} }
void InviteLinks::revoke( void InviteLinks::revoke(
@ -272,8 +275,13 @@ void InviteLinks::revoke(
void InviteLinks::revokePermanent( void InviteLinks::revokePermanent(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Fn<void(Link)> done) { Fn<void()> done) {
performCreate(peer, std::move(done), true); 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( void InviteLinks::destroy(
@ -294,24 +302,23 @@ void InviteLinks::destroy(
if (done) { if (done) {
callbacks.push_back(std::move(done)); callbacks.push_back(std::move(done));
} }
// #TODO links _api->request(MTPmessages_DeleteExportedChatInvite(
//_api->request(MTPmessages_DeleteExportedChatInvite( peer->input,
// peer->input, MTP_string(link)
// MTP_string(link) )).done([=](const MTPBool &result) {
//)).done([=](const MTPBool &result) { const auto callbacks = _deleteCallbacks.take(key);
// const auto callbacks = _deleteCallbacks.take(key); if (callbacks) {
// if (callbacks) { for (const auto &callback : *callbacks) {
// for (const auto &callback : *callbacks) { callback();
// callback(); }
// } }
// } _updates.fire(Update{
// _updates.fire(Update{ .peer = peer,
// .peer = peer, .was = key.link,
// .was = key.link, });
// }); }).fail([=](const RPCError &error) {
//}).fail([=](const RPCError &error) { _deleteCallbacks.erase(key);
// _deleteCallbacks.erase(key); }).send();
//}).send();
} }
void InviteLinks::destroyAllRevoked( void InviteLinks::destroyAllRevoked(
@ -328,62 +335,61 @@ void InviteLinks::destroyAllRevoked(
if (done) { if (done) {
callbacks.push_back(std::move(done)); callbacks.push_back(std::move(done));
} }
// #TODO links _api->request(MTPmessages_DeleteRevokedExportedChatInvites(
//_api->request(MTPmessages_DeleteRevokedExportedChatInvites( peer->input,
// peer->input MTP_inputUserSelf()
//)).done([=](const MTPBool &result) { )).done([=](const MTPBool &result) {
// if (const auto callbacks = _deleteRevokedCallbacks.take(peer)) { if (const auto callbacks = _deleteRevokedCallbacks.take(peer)) {
// for (const auto &callback : *callbacks) { for (const auto &callback : *callbacks) {
// callback(); callback();
// } }
// } }
// _allRevokedDestroyed.fire_copy(peer); _allRevokedDestroyed.fire_copy(peer);
//}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
//}).send(); }).send();
} }
void InviteLinks::requestLinks(not_null<PeerData*> peer) { void InviteLinks::requestLinks(not_null<PeerData*> peer) {
if (_firstSliceRequests.contains(peer)) { if (_firstSliceRequests.contains(peer)) {
return; return;
} }
// #TODO links const auto requestId = _api->request(MTPmessages_GetExportedChatInvites(
//const auto requestId = _api->request(MTPmessages_GetExportedChatInvites( MTP_flags(0),
// MTP_flags(0), peer->input,
// peer->input, MTP_inputUserSelf(),
// MTPInputUser(), // admin_id MTPint(), // offset_date
// MTPint(), // offset_date MTPstring(), // offset_link
// MTPstring(), // offset_link MTP_int(kFirstPage)
// MTP_int(kFirstPage) )).done([=](const MTPmessages_ExportedChatInvites &result) {
//)).done([=](const MTPmessages_ExportedChatInvites &result) { _firstSliceRequests.remove(peer);
// _firstSliceRequests.remove(peer); auto slice = parseSlice(peer, result);
// auto slice = parseSlice(peer, result); auto i = _firstSlices.find(peer);
// auto i = _firstSlices.find(peer); const auto permanent = (i != end(_firstSlices))
// const auto permanent = (i != end(_firstSlices)) ? lookupPermanent(i->second)
// ? lookupPermanent(i->second) : nullptr;
// : nullptr; if (!permanent) {
// if (!permanent) { BringPermanentToFront(slice);
// BringPermanentToFront(slice); const auto j = _firstSlices.emplace_or_assign(
// const auto j = _firstSlices.emplace_or_assign( peer,
// peer, std::move(slice)).first;
// std::move(slice)).first; if (const auto permanent = lookupPermanent(j->second)) {
// if (const auto permanent = lookupPermanent(j->second)) { editPermanentLink(peer, permanent->link);
// editPermanentLink(peer, permanent->link); }
// } } else {
// } else { RemovePermanent(slice);
// RemovePermanent(slice); auto &existing = i->second.links;
// auto &existing = i->second.links; existing.erase(begin(existing) + 1, end(existing));
// existing.erase(begin(existing) + 1, end(existing)); existing.insert(
// existing.insert( end(existing),
// end(existing), begin(slice.links),
// begin(slice.links), end(slice.links));
// end(slice.links)); i->second.count = std::max(slice.count, int(existing.size()));
// i->second.count = std::max(slice.count, int(existing.size())); }
// } notify(peer);
// notify(peer); }).fail([=](const RPCError &error) {
//}).fail([=](const RPCError &error) { _firstSliceRequests.remove(peer);
// _firstSliceRequests.remove(peer); }).send();
//}).send(); _firstSliceRequests.emplace(peer, requestId);
//_firstSliceRequests.emplace(peer, requestId);
} }
std::optional<JoinedByLinkSlice> InviteLinks::lookupJoinedFirstSlice( std::optional<JoinedByLinkSlice> InviteLinks::lookupJoinedFirstSlice(
@ -444,23 +450,23 @@ rpl::producer<> InviteLinks::allRevokedDestroyed(
} }
void InviteLinks::requestJoinedFirstSlice(LinkKey key) { void InviteLinks::requestJoinedFirstSlice(LinkKey key) {
//if (_firstJoinedRequests.contains(key)) { // #TODO links if (_firstJoinedRequests.contains(key)) {
// return; return;
//} }
//const auto requestId = _api->request(MTPmessages_GetChatInviteImporters( const auto requestId = _api->request(MTPmessages_GetChatInviteImporters(
// key.peer->input, key.peer->input,
// MTP_string(key.link), MTP_string(key.link),
// MTP_int(0), // offset_date MTP_int(0), // offset_date
// MTP_inputUserEmpty(), // offset_user MTP_inputUserEmpty(), // offset_user
// MTP_int(kJoinedFirstPage) MTP_int(kJoinedFirstPage)
//)).done([=](const MTPmessages_ChatInviteImporters &result) { )).done([=](const MTPmessages_ChatInviteImporters &result) {
// _firstJoinedRequests.remove(key); _firstJoinedRequests.remove(key);
// _firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result); _firstJoined[key] = ParseJoinedByLinkSlice(key.peer, result);
// _joinedFirstSliceLoaded.fire_copy(key); _joinedFirstSliceLoaded.fire_copy(key);
//}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
// _firstJoinedRequests.remove(key); _firstJoinedRequests.remove(key);
//}).send(); }).send();
//_firstJoinedRequests.emplace(key, requestId); _firstJoinedRequests.emplace(key, requestId);
} }
void InviteLinks::setPermanent( void InviteLinks::setPermanent(
@ -548,27 +554,27 @@ auto InviteLinks::links(not_null<PeerData*> peer) const -> const Links & {
const auto i = _firstSlices.find(peer); const auto i = _firstSlices.find(peer);
return (i != end(_firstSlices)) ? i->second : kEmpty; return (i != end(_firstSlices)) ? i->second : kEmpty;
} }
// #TODO links
//auto InviteLinks::parseSlice( auto InviteLinks::parseSlice(
// not_null<PeerData*> peer, not_null<PeerData*> peer,
// const MTPmessages_ExportedChatInvites &slice) const -> Links { const MTPmessages_ExportedChatInvites &slice) const -> Links {
// auto i = _firstSlices.find(peer); auto i = _firstSlices.find(peer);
// const auto permanent = (i != end(_firstSlices)) const auto permanent = (i != end(_firstSlices))
// ? lookupPermanent(i->second) ? lookupPermanent(i->second)
// : nullptr; : nullptr;
// auto result = Links(); auto result = Links();
// slice.match([&](const MTPDmessages_exportedChatInvites &data) { slice.match([&](const MTPDmessages_exportedChatInvites &data) {
// peer->session().data().processUsers(data.vusers()); peer->session().data().processUsers(data.vusers());
// result.count = data.vcount().v; result.count = data.vcount().v;
// for (const auto &invite : data.vinvites().v) { for (const auto &invite : data.vinvites().v) {
// const auto link = parse(peer, invite); const auto link = parse(peer, invite);
// if (!permanent || link.link != permanent->link) { if (!permanent || link.link != permanent->link) {
// result.links.push_back(link); result.links.push_back(link);
// } }
// } }
// }); });
// return result; return result;
//} }
auto InviteLinks::parse( auto InviteLinks::parse(
not_null<PeerData*> peer, not_null<PeerData*> peer,
@ -582,7 +588,7 @@ auto InviteLinks::parse(
.expireDate = data.vexpire_date().value_or_empty(), .expireDate = data.vexpire_date().value_or_empty(),
.usageLimit = data.vusage_limit().value_or_empty(), .usageLimit = data.vusage_limit().value_or_empty(),
.usage = data.vusage().value_or_empty(), .usage = data.vusage().value_or_empty(),
.permanent = true,//data.is_permanent(), // #TODO links .permanent = data.is_permanent(),
.revoked = data.is_revoked(), .revoked = data.is_revoked(),
}; };
}); });
@ -594,23 +600,22 @@ void InviteLinks::requestMoreLinks(
const QString &lastLink, const QString &lastLink,
bool revoked, bool revoked,
Fn<void(Links)> done) { Fn<void(Links)> done) {
// #TODO links using Flag = MTPmessages_GetExportedChatInvites::Flag;
//using Flag = MTPmessages_GetExportedChatInvites::Flag; _api->request(MTPmessages_GetExportedChatInvites(
//_api->request(MTPmessages_GetExportedChatInvites( MTP_flags(Flag::f_offset_link
// MTP_flags(Flag::f_offset_link | (revoked ? Flag::f_revoked : Flag(0))),
// | (revoked ? Flag::f_revoked : Flag(0))), peer->input,
// peer->input, MTP_inputUserSelf(),
// MTPInputUser(), // admin_id, MTP_int(lastDate),
// MTP_int(lastDate), MTP_string(lastLink),
// MTP_string(lastLink), MTP_int(kPerPage)
// MTP_int(kPerPage) )).done([=](const MTPmessages_ExportedChatInvites &result) {
//)).done([=](const MTPmessages_ExportedChatInvites &result) { auto slice = parseSlice(peer, result);
// auto slice = parseSlice(peer, result); RemovePermanent(slice);
// RemovePermanent(slice); done(std::move(slice));
// done(std::move(slice)); }).fail([=](const RPCError &error) {
//}).fail([=](const RPCError &error) { done(Links());
// done(Links()); }).send();
//}).send();
} }
void InviteLinks::editPermanentLink( void InviteLinks::editPermanentLink(

View file

@ -43,10 +43,10 @@ struct InviteLinkUpdate {
QString was; QString was;
std::optional<InviteLink> now; std::optional<InviteLink> now;
}; };
// #TODO links
//[[nodiscard]] JoinedByLinkSlice ParseJoinedByLinkSlice( [[nodiscard]] JoinedByLinkSlice ParseJoinedByLinkSlice(
// not_null<PeerData*> peer, not_null<PeerData*> peer,
// const MTPmessages_ChatInviteImporters &slice); const MTPmessages_ChatInviteImporters &slice);
class InviteLinks final { class InviteLinks final {
public: public:
@ -73,7 +73,7 @@ public:
Fn<void(Link)> done = nullptr); Fn<void(Link)> done = nullptr);
void revokePermanent( void revokePermanent(
not_null<PeerData*> peer, not_null<PeerData*> peer,
Fn<void(Link)> done = nullptr); Fn<void()> done = nullptr);
void destroy( void destroy(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const QString &link, const QString &link,
@ -124,10 +124,9 @@ private:
} }
}; };
// #TODO links [[nodiscard]] Links parseSlice(
//[[nodiscard]] Links parseSlice( not_null<PeerData*> peer,
// not_null<PeerData*> peer, const MTPmessages_ExportedChatInvites &slice) const;
// const MTPmessages_ExportedChatInvites &slice) const;
[[nodiscard]] Link parse( [[nodiscard]] Link parse(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const MTPExportedChatInvite &invite) const; const MTPExportedChatInvite &invite) const;

View file

@ -332,7 +332,7 @@ private:
void showEditLinkedChatBox(); void showEditLinkedChatBox();
void fillPrivacyTypeButton(); void fillPrivacyTypeButton();
void fillLinkedChatButton(); void fillLinkedChatButton();
void fillInviteLinkButton(); //void fillInviteLinkButton();
void fillSignaturesButton(); void fillSignaturesButton();
void fillHistoryVisibilityButton(); void fillHistoryVisibilityButton();
void fillManageSection(); void fillManageSection();
@ -798,20 +798,20 @@ void Controller::fillLinkedChatButton() {
[=] { showEditLinkedChatBox(); }); [=] { showEditLinkedChatBox(); });
_linkedChatUpdates.fire_copy(*_linkedChatSavedValue); _linkedChatUpdates.fire_copy(*_linkedChatSavedValue);
} }
//
void Controller::fillInviteLinkButton() { //void Controller::fillInviteLinkButton() {
Expects(_controls.buttonsLayout != nullptr); // Expects(_controls.buttonsLayout != nullptr);
//
const auto buttonCallback = [=] { // const auto buttonCallback = [=] {
Ui::show(Box<EditPeerTypeBox>(_peer), Ui::LayerOption::KeepOther); // Ui::show(Box<EditPeerTypeBox>(_peer), Ui::LayerOption::KeepOther);
}; // };
//
AddButtonWithText( // AddButtonWithText(
_controls.buttonsLayout, // _controls.buttonsLayout,
tr::lng_profile_invite_link_section(), // tr::lng_profile_invite_link_section(),
rpl::single(QString()), //Empty text. // rpl::single(QString()), //Empty text.
buttonCallback); // buttonCallback);
} //}
void Controller::fillSignaturesButton() { void Controller::fillSignaturesButton() {
Expects(_controls.buttonsLayout != nullptr); Expects(_controls.buttonsLayout != nullptr);
@ -959,8 +959,8 @@ void Controller::fillManageSection() {
if (canEditUsername) { if (canEditUsername) {
fillPrivacyTypeButton(); fillPrivacyTypeButton();
} else if (canEditInviteLinks) { //} else if (canEditInviteLinks) {
fillInviteLinkButton(); // fillInviteLinkButton();
} }
if (canViewOrEditLinkedChat) { if (canViewOrEditLinkedChat) {
fillLinkedChatButton(); fillLinkedChatButton();
@ -995,29 +995,29 @@ void Controller::fillManageSection() {
[=] { ShowEditPermissions(_navigation, _peer); }, [=] { ShowEditPermissions(_navigation, _peer); },
st::infoIconPermissions); st::infoIconPermissions);
} }
//if (canEditInviteLinks) { // #TODO links if (canEditInviteLinks) {
// AddButtonWithCount( AddButtonWithCount(
// _controls.buttonsLayout, _controls.buttonsLayout,
// tr::lng_manage_peer_invite_links(), tr::lng_manage_peer_invite_links(),
// Info::Profile::MigratedOrMeValue( Info::Profile::MigratedOrMeValue(
// _peer _peer
// ) | rpl::map([=](not_null<PeerData*> peer) { ) | rpl::map([=](not_null<PeerData*> peer) {
// peer->session().api().inviteLinks().requestLinks(peer); peer->session().api().inviteLinks().requestLinks(peer);
// return peer->session().changes().peerUpdates( return peer->session().changes().peerUpdates(
// peer, peer,
// Data::PeerUpdate::Flag::InviteLinks Data::PeerUpdate::Flag::InviteLinks
// ) | rpl::map([=] { ) | rpl::map([=] {
// return peer->session().api().inviteLinks().links( return peer->session().api().inviteLinks().links(
// peer).count; peer).count;
// }); });
// }) | rpl::flatten_latest( }) | rpl::flatten_latest(
// ) | ToPositiveNumberString(), ) | ToPositiveNumberString(),
// [=] { Ui::show( [=] { Ui::show(
// Box(ManageInviteLinksBox, _peer), Box(ManageInviteLinksBox, _peer),
// Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
// }, },
// st::infoIconInviteLinks); st::infoIconInviteLinks);
//} }
if (canViewAdmins) { if (canViewAdmins) {
AddButtonWithCount( AddButtonWithCount(
_controls.buttonsLayout, _controls.buttonsLayout,

View file

@ -222,22 +222,21 @@ void Controller::loadMoreRows() {
if (_requestId || _allLoaded) { if (_requestId || _allLoaded) {
return; return;
} }
_allLoaded = true; // #TODO links _requestId = _api.request(MTPmessages_GetChatInviteImporters(
//_requestId = _api.request(MTPmessages_GetChatInviteImporters( _peer->input,
// _peer->input, MTP_string(_data.link),
// MTP_string(_data.link), MTP_int(_lastUser ? _lastUser->date : 0),
// MTP_int(_lastUser ? _lastUser->date : 0), _lastUser ? _lastUser->user->inputUser : MTP_inputUserEmpty(),
// _lastUser ? _lastUser->user->inputUser : MTP_inputUserEmpty(), MTP_int(_lastUser ? kPerPage : kFirstPage)
// MTP_int(_lastUser ? kPerPage : kFirstPage) )).done([=](const MTPmessages_ChatInviteImporters &result) {
//)).done([=](const MTPmessages_ChatInviteImporters &result) { _requestId = 0;
// _requestId = 0; auto slice = Api::ParseJoinedByLinkSlice(_peer, result);
// auto slice = Api::ParseJoinedByLinkSlice(_peer, result); _allLoaded = slice.users.empty();
// _allLoaded = slice.users.empty(); appendSlice(slice);
// appendSlice(slice); }).fail([=](const RPCError &error) {
//}).fail([=](const RPCError &error) { _requestId = 0;
// _requestId = 0; _allLoaded = true;
// _allLoaded = true; }).send();
//}).send();
} }
void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) { void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) {
@ -318,7 +317,7 @@ void AddPermanentLinkBlock(
const auto revokeLink = crl::guard(weak, [=] { const auto revokeLink = crl::guard(weak, [=] {
const auto box = std::make_shared<QPointer<ConfirmBox>>(); const auto box = std::make_shared<QPointer<ConfirmBox>>();
const auto done = crl::guard(weak, [=] { const auto done = crl::guard(weak, [=] {
const auto close = [=](auto&&) { const auto close = [=] {
if (*box) { if (*box) {
(*box)->closeBox(); (*box)->closeBox();
} }

View file

@ -441,8 +441,10 @@ Controller::Controller(not_null<PeerData*> peer, bool revoked)
delegate()->peerListRefreshRows(); delegate()->peerListRefreshRows();
} }
} else if (update.was.isEmpty()) { } else if (update.was.isEmpty()) {
prependRow(*update.now, now); if (!update.now->permanent || update.now->revoked) {
delegate()->peerListRefreshRows(); prependRow(*update.now, now);
delegate()->peerListRefreshRows();
}
} else { } else {
updateRow(*update.now, now); updateRow(*update.now, now);
} }
@ -581,6 +583,8 @@ void Controller::updateRow(const InviteLinkData &data, TimeId now) {
real->update(data, now); real->update(data, now);
checkExpiringTimer(real); checkExpiringTimer(real);
delegate()->peerListUpdateRow(row); delegate()->peerListUpdateRow(row);
} else if (_revoked) {
prependRow(data, now);
} }
} }

View file

@ -186,20 +186,20 @@ void Controller::createContent() {
_wrap->add(createUsernameEdit()); _wrap->add(createUsernameEdit());
} }
//using namespace Settings; // #TODO links using namespace Settings;
//AddSkip(_wrap.get()); AddSkip(_wrap.get());
//_wrap->add(EditPeerInfoBox::CreateButton( _wrap->add(EditPeerInfoBox::CreateButton(
// _wrap.get(), _wrap.get(),
// tr::lng_group_invite_manage(), tr::lng_group_invite_manage(),
// rpl::single(QString()), rpl::single(QString()),
// [=] { Ui::show( [=] { Ui::show(
// Box(ManageInviteLinksBox, _peer), Box(ManageInviteLinksBox, _peer),
// Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
// }, },
// st::manageGroupButton, st::manageGroupButton,
// &st::infoIconInviteLinks)); &st::infoIconInviteLinks));
//AddSkip(_wrap.get()); AddSkip(_wrap.get());
//AddDividerText(_wrap.get(), tr::lng_group_invite_manage_about()); AddDividerText(_wrap.get(), tr::lng_group_invite_manage_about());
if (_linkOnly) { if (_linkOnly) {
_controls.inviteLinkWrap->show(anim::type::instant); _controls.inviteLinkWrap->show(anim::type::instant);
@ -564,9 +564,8 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkBlock() {
if (_privacySavedValue) { if (_privacySavedValue) {
AddSkip(container); 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); AddPermanentLinkBlock(container, _peer);
AddSkip(container); AddSkip(container);
@ -577,16 +576,6 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkBlock() {
? tr::lng_group_invite_about_permanent_group() ? tr::lng_group_invite_about_permanent_group()
: tr::lng_group_invite_about_permanent_channel())); : 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; return result;
} }