mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Delegated display of RevokeLinkBox to caller.
This commit is contained in:
parent
905a7e6346
commit
dc6788706c
3 changed files with 30 additions and 29 deletions
Telegram/SourceFiles/boxes/peers
|
@ -351,7 +351,9 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
|||
InviteLinkQrBox(link);
|
||||
});
|
||||
const auto revokeLink = crl::guard(weak, [=] {
|
||||
RevokeLink(_peer, admin, link);
|
||||
delegate()->peerListShowBox(
|
||||
RevokeLinkBox(_peer, admin, link),
|
||||
Ui::LayerOption::KeepOther);
|
||||
});
|
||||
const auto editLink = crl::guard(weak, [=] {
|
||||
delegate()->peerListShowBox(
|
||||
|
@ -959,19 +961,11 @@ void AddPermanentLinkBlock(
|
|||
}
|
||||
});
|
||||
const auto revokeLink = crl::guard(weak, [=] {
|
||||
const auto done = crl::guard(weak, [=](Fn<void()> &&close) {
|
||||
peer->session().api().inviteLinks().revokePermanent(
|
||||
peer,
|
||||
admin,
|
||||
value->current().link,
|
||||
std::move(close));
|
||||
});
|
||||
show->showBox(
|
||||
Ui::MakeConfirmBox({
|
||||
tr::lng_group_invite_about_new(tr::now),
|
||||
done
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
if (const auto current = value->current(); !current.link.isEmpty()) {
|
||||
show->showBox(
|
||||
RevokeLinkBox(peer, admin, current.link, true),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}
|
||||
});
|
||||
|
||||
auto link = value->value(
|
||||
|
@ -1266,22 +1260,26 @@ object_ptr<Ui::BoxContent> EditLinkBox(
|
|||
}
|
||||
}
|
||||
|
||||
void RevokeLink(
|
||||
object_ptr<Ui::BoxContent> RevokeLinkBox(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> admin,
|
||||
const QString &link) {
|
||||
const QString &link,
|
||||
bool permanent) {
|
||||
const auto revoke = [=](Fn<void()> &&close) {
|
||||
const auto done = [close = std::move(close)](const LinkData &data) {
|
||||
close();
|
||||
};
|
||||
peer->session().api().inviteLinks().revoke(peer, admin, link, done);
|
||||
auto &l = peer->session().api().inviteLinks();
|
||||
if (permanent) {
|
||||
l.revokePermanent(peer, admin, link, std::move(close));
|
||||
} else {
|
||||
auto done = [c = std::move(close)](const LinkData &) { c(); };
|
||||
l.revoke(peer, admin, link, std::move(done));
|
||||
}
|
||||
};
|
||||
Ui::show(
|
||||
Ui::MakeConfirmBox({
|
||||
tr::lng_group_invite_revoke_about(),
|
||||
revoke
|
||||
}),
|
||||
Ui::LayerOption::KeepOther);
|
||||
return Ui::MakeConfirmBox({
|
||||
permanent
|
||||
? tr::lng_group_invite_about_new()
|
||||
: tr::lng_group_invite_revoke_about(),
|
||||
revoke
|
||||
});
|
||||
}
|
||||
|
||||
object_ptr<Ui::BoxContent> DeleteLinkBox(
|
||||
|
|
|
@ -37,10 +37,11 @@ void AddPermanentLinkBlock(
|
|||
void CopyInviteLink(const QString &link);
|
||||
void ShareInviteLinkBox(not_null<PeerData*> peer, const QString &link);
|
||||
void InviteLinkQrBox(const QString &link);
|
||||
void RevokeLink(
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> RevokeLinkBox(
|
||||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> admin,
|
||||
const QString &link);
|
||||
const QString &link,
|
||||
bool permanent = false);
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> EditLinkBox(
|
||||
not_null<PeerData*> peer,
|
||||
const Api::InviteLink &data);
|
||||
|
|
|
@ -599,7 +599,9 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
|
|||
Ui::LayerOption::KeepOther);
|
||||
}, &st::menuIconEdit);
|
||||
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
|
||||
RevokeLink(_peer, _admin, link);
|
||||
delegate()->peerListShowBox(
|
||||
RevokeLinkBox(_peer, _admin, link),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}, &st::menuIconRemove);
|
||||
}
|
||||
return result;
|
||||
|
|
Loading…
Add table
Reference in a new issue