mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Delegated display of EditLinkBox to caller.
This commit is contained in:
parent
b18d665fbe
commit
9dccc12734
3 changed files with 34 additions and 22 deletions
|
@ -354,7 +354,9 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
|||
RevokeLink(_peer, admin, link);
|
||||
});
|
||||
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, [=] {
|
||||
delegate()->peerListShowBox(
|
||||
|
@ -1203,7 +1205,7 @@ void InviteLinkQrBox(const QString &link) {
|
|||
}));
|
||||
}
|
||||
|
||||
void EditLink(
|
||||
object_ptr<Ui::BoxContent> EditLinkBox(
|
||||
not_null<PeerData*> peer,
|
||||
const Api::InviteLink &data) {
|
||||
const auto creating = data.link.isEmpty();
|
||||
|
@ -1242,22 +1244,26 @@ void EditLink(
|
|||
};
|
||||
const auto isGroup = !peer->isBroadcast();
|
||||
const auto isPublic = peer->isChannel() && peer->asChannel()->isPublic();
|
||||
*box = Ui::show(
|
||||
(creating
|
||||
? Box(Ui::CreateInviteLinkBox, isGroup, isPublic, done)
|
||||
: Box(
|
||||
Ui::EditInviteLinkBox,
|
||||
Fields{
|
||||
.link = data.link,
|
||||
.label = data.label,
|
||||
.expireDate = data.expireDate,
|
||||
.usageLimit = data.usageLimit,
|
||||
.requestApproval = data.requestApproval,
|
||||
.isGroup = isGroup,
|
||||
.isPublic = isPublic,
|
||||
},
|
||||
done)),
|
||||
Ui::LayerOption::KeepOther);
|
||||
if (creating) {
|
||||
auto object = Box(Ui::CreateInviteLinkBox, isGroup, isPublic, done);
|
||||
*box = Ui::MakeWeak(object.data());
|
||||
return object;
|
||||
} else {
|
||||
auto object = Box(
|
||||
Ui::EditInviteLinkBox,
|
||||
Fields{
|
||||
.link = data.link,
|
||||
.label = data.label,
|
||||
.expireDate = data.expireDate,
|
||||
.usageLimit = data.usageLimit,
|
||||
.requestApproval = data.requestApproval,
|
||||
.isGroup = isGroup,
|
||||
.isPublic = isPublic,
|
||||
},
|
||||
done);
|
||||
*box = Ui::MakeWeak(object.data());
|
||||
return object;
|
||||
}
|
||||
}
|
||||
|
||||
void RevokeLink(
|
||||
|
|
|
@ -41,7 +41,7 @@ void RevokeLink(
|
|||
not_null<PeerData*> peer,
|
||||
not_null<UserData*> admin,
|
||||
const QString &link);
|
||||
void EditLink(
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> EditLinkBox(
|
||||
not_null<PeerData*> peer,
|
||||
const Api::InviteLink &data);
|
||||
[[nodiscard]] object_ptr<Ui::BoxContent> DeleteLinkBox(
|
||||
|
|
|
@ -594,7 +594,9 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
|
|||
InviteLinkQrBox(link);
|
||||
}, &st::menuIconQrCode);
|
||||
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
|
||||
EditLink(_peer, data);
|
||||
delegate()->peerListShowBox(
|
||||
EditLinkBox(_peer, data),
|
||||
Ui::LayerOption::KeepOther);
|
||||
}, &st::menuIconEdit);
|
||||
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
|
||||
RevokeLink(_peer, _admin, link);
|
||||
|
@ -881,6 +883,8 @@ void ManageInviteLinksBox(
|
|||
int revokedCount) {
|
||||
using namespace Settings;
|
||||
|
||||
const auto show = std::make_shared<Ui::BoxShow>(box);
|
||||
|
||||
box->setTitle(tr::lng_group_invite_title());
|
||||
box->setWidth(st::boxWideWidth);
|
||||
|
||||
|
@ -903,7 +907,7 @@ void ManageInviteLinksBox(
|
|||
|
||||
AddSubsectionTitle(container, tr::lng_create_permanent_link_title());
|
||||
AddPermanentLinkBlock(
|
||||
std::make_shared<Ui::BoxShow>(box),
|
||||
show,
|
||||
container,
|
||||
peer,
|
||||
admin,
|
||||
|
@ -914,7 +918,9 @@ void ManageInviteLinksBox(
|
|||
if (admin->isSelf()) {
|
||||
const auto add = AddCreateLinkButton(container);
|
||||
add->setClickedCallback([=] {
|
||||
EditLink(peer, InviteLinkData{ .admin = admin });
|
||||
show->showBox(
|
||||
EditLinkBox(peer, InviteLinkData{ .admin = admin }),
|
||||
Ui::LayerOption::KeepOther);
|
||||
});
|
||||
} else {
|
||||
otherHeader = container->add(object_ptr<Ui::SlideWrap<>>(
|
||||
|
|
Loading…
Add table
Reference in a new issue