Delegated display of EditLinkBox to caller.
This commit is contained in:
parent
b18d665fbe
commit
9dccc12734
|
@ -354,7 +354,9 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
||||||
RevokeLink(_peer, admin, link);
|
RevokeLink(_peer, admin, link);
|
||||||
});
|
});
|
||||||
const auto editLink = crl::guard(weak, [=] {
|
const auto editLink = crl::guard(weak, [=] {
|
||||||
EditLink(_peer, _data.current());
|
delegate()->peerListShowBox(
|
||||||
|
EditLinkBox(_peer, _data.current()),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
});
|
});
|
||||||
const auto deleteLink = crl::guard(weak, [=] {
|
const auto deleteLink = crl::guard(weak, [=] {
|
||||||
delegate()->peerListShowBox(
|
delegate()->peerListShowBox(
|
||||||
|
@ -1203,7 +1205,7 @@ void InviteLinkQrBox(const QString &link) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditLink(
|
object_ptr<Ui::BoxContent> EditLinkBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::InviteLink &data) {
|
const Api::InviteLink &data) {
|
||||||
const auto creating = data.link.isEmpty();
|
const auto creating = data.link.isEmpty();
|
||||||
|
@ -1242,22 +1244,26 @@ void EditLink(
|
||||||
};
|
};
|
||||||
const auto isGroup = !peer->isBroadcast();
|
const auto isGroup = !peer->isBroadcast();
|
||||||
const auto isPublic = peer->isChannel() && peer->asChannel()->isPublic();
|
const auto isPublic = peer->isChannel() && peer->asChannel()->isPublic();
|
||||||
*box = Ui::show(
|
if (creating) {
|
||||||
(creating
|
auto object = Box(Ui::CreateInviteLinkBox, isGroup, isPublic, done);
|
||||||
? Box(Ui::CreateInviteLinkBox, isGroup, isPublic, done)
|
*box = Ui::MakeWeak(object.data());
|
||||||
: Box(
|
return object;
|
||||||
Ui::EditInviteLinkBox,
|
} else {
|
||||||
Fields{
|
auto object = Box(
|
||||||
.link = data.link,
|
Ui::EditInviteLinkBox,
|
||||||
.label = data.label,
|
Fields{
|
||||||
.expireDate = data.expireDate,
|
.link = data.link,
|
||||||
.usageLimit = data.usageLimit,
|
.label = data.label,
|
||||||
.requestApproval = data.requestApproval,
|
.expireDate = data.expireDate,
|
||||||
.isGroup = isGroup,
|
.usageLimit = data.usageLimit,
|
||||||
.isPublic = isPublic,
|
.requestApproval = data.requestApproval,
|
||||||
},
|
.isGroup = isGroup,
|
||||||
done)),
|
.isPublic = isPublic,
|
||||||
Ui::LayerOption::KeepOther);
|
},
|
||||||
|
done);
|
||||||
|
*box = Ui::MakeWeak(object.data());
|
||||||
|
return object;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RevokeLink(
|
void RevokeLink(
|
||||||
|
|
|
@ -41,7 +41,7 @@ void RevokeLink(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
not_null<UserData*> admin,
|
not_null<UserData*> admin,
|
||||||
const QString &link);
|
const QString &link);
|
||||||
void EditLink(
|
[[nodiscard]] object_ptr<Ui::BoxContent> EditLinkBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::InviteLink &data);
|
const Api::InviteLink &data);
|
||||||
[[nodiscard]] object_ptr<Ui::BoxContent> DeleteLinkBox(
|
[[nodiscard]] object_ptr<Ui::BoxContent> DeleteLinkBox(
|
||||||
|
|
|
@ -594,7 +594,9 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
|
||||||
InviteLinkQrBox(link);
|
InviteLinkQrBox(link);
|
||||||
}, &st::menuIconQrCode);
|
}, &st::menuIconQrCode);
|
||||||
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
|
||||||
EditLink(_peer, data);
|
delegate()->peerListShowBox(
|
||||||
|
EditLinkBox(_peer, data),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
}, &st::menuIconEdit);
|
}, &st::menuIconEdit);
|
||||||
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
|
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
|
||||||
RevokeLink(_peer, _admin, link);
|
RevokeLink(_peer, _admin, link);
|
||||||
|
@ -881,6 +883,8 @@ void ManageInviteLinksBox(
|
||||||
int revokedCount) {
|
int revokedCount) {
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
|
|
||||||
|
const auto show = std::make_shared<Ui::BoxShow>(box);
|
||||||
|
|
||||||
box->setTitle(tr::lng_group_invite_title());
|
box->setTitle(tr::lng_group_invite_title());
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
|
|
||||||
|
@ -903,7 +907,7 @@ void ManageInviteLinksBox(
|
||||||
|
|
||||||
AddSubsectionTitle(container, tr::lng_create_permanent_link_title());
|
AddSubsectionTitle(container, tr::lng_create_permanent_link_title());
|
||||||
AddPermanentLinkBlock(
|
AddPermanentLinkBlock(
|
||||||
std::make_shared<Ui::BoxShow>(box),
|
show,
|
||||||
container,
|
container,
|
||||||
peer,
|
peer,
|
||||||
admin,
|
admin,
|
||||||
|
@ -914,7 +918,9 @@ void ManageInviteLinksBox(
|
||||||
if (admin->isSelf()) {
|
if (admin->isSelf()) {
|
||||||
const auto add = AddCreateLinkButton(container);
|
const auto add = AddCreateLinkButton(container);
|
||||||
add->setClickedCallback([=] {
|
add->setClickedCallback([=] {
|
||||||
EditLink(peer, InviteLinkData{ .admin = admin });
|
show->showBox(
|
||||||
|
EditLinkBox(peer, InviteLinkData{ .admin = admin }),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
otherHeader = container->add(object_ptr<Ui::SlideWrap<>>(
|
otherHeader = container->add(object_ptr<Ui::SlideWrap<>>(
|
||||||
|
|
Loading…
Reference in New Issue