Improve revoked link view box.
This commit is contained in:
parent
1426a43743
commit
c9fccc8ea7
Binary file not shown.
After Width: | Height: | Size: 432 B |
Binary file not shown.
After Width: | Height: | Size: 791 B |
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -1188,6 +1188,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_group_invite_share" = "Share Link";
|
"lng_group_invite_share" = "Share Link";
|
||||||
"lng_group_invite_revoke" = "Revoke Link";
|
"lng_group_invite_revoke" = "Revoke Link";
|
||||||
"lng_group_invite_reactivate" = "Reactivate Link";
|
"lng_group_invite_reactivate" = "Reactivate Link";
|
||||||
|
"lng_group_invite_delete" = "Delete Link";
|
||||||
"lng_group_invite_no_joined" = "No one joined yet";
|
"lng_group_invite_no_joined" = "No one joined yet";
|
||||||
"lng_group_invite_joined#one" = "{count} joined";
|
"lng_group_invite_joined#one" = "{count} joined";
|
||||||
"lng_group_invite_joined#other" = "{count} joined";
|
"lng_group_invite_joined#other" = "{count} joined";
|
||||||
|
|
|
@ -137,6 +137,7 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
||||||
using namespace Settings;
|
using namespace Settings;
|
||||||
|
|
||||||
const auto current = _data.current();
|
const auto current = _data.current();
|
||||||
|
const auto revoked = current.revoked;
|
||||||
const auto link = current.link;
|
const auto link = current.link;
|
||||||
const auto admin = current.admin;
|
const auto admin = current.admin;
|
||||||
const auto weak = Ui::MakeWeak(container);
|
const auto weak = Ui::MakeWeak(container);
|
||||||
|
@ -152,21 +153,30 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
||||||
const auto editLink = crl::guard(weak, [=] {
|
const auto editLink = crl::guard(weak, [=] {
|
||||||
EditLink(_peer, _data.current());
|
EditLink(_peer, _data.current());
|
||||||
});
|
});
|
||||||
|
const auto deleteLink = [=] {
|
||||||
|
DeleteLink(_peer, admin, link);
|
||||||
|
};
|
||||||
|
|
||||||
const auto createMenu = [=] {
|
const auto createMenu = [=] {
|
||||||
auto result = base::make_unique_q<Ui::PopupMenu>(container);
|
auto result = base::make_unique_q<Ui::PopupMenu>(container);
|
||||||
result->addAction(
|
if (revoked) {
|
||||||
tr::lng_group_invite_context_copy(tr::now),
|
result->addAction(
|
||||||
copyLink);
|
tr::lng_group_invite_context_delete(tr::now),
|
||||||
result->addAction(
|
deleteLink);
|
||||||
tr::lng_group_invite_context_share(tr::now),
|
} else {
|
||||||
shareLink);
|
result->addAction(
|
||||||
result->addAction(
|
tr::lng_group_invite_context_copy(tr::now),
|
||||||
tr::lng_group_invite_context_edit(tr::now),
|
copyLink);
|
||||||
editLink);
|
result->addAction(
|
||||||
result->addAction(
|
tr::lng_group_invite_context_share(tr::now),
|
||||||
tr::lng_group_invite_context_revoke(tr::now),
|
shareLink);
|
||||||
revokeLink);
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_edit(tr::now),
|
||||||
|
editLink);
|
||||||
|
result->addAction(
|
||||||
|
tr::lng_group_invite_context_revoke(tr::now),
|
||||||
|
revokeLink);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -197,6 +207,9 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
||||||
|
|
||||||
AddReactivateLinkButton(reactivateWrap->entity(), editLink);
|
AddReactivateLinkButton(reactivateWrap->entity(), editLink);
|
||||||
AddCopyShareLinkButtons(copyShareWrap->entity(), copyLink, shareLink);
|
AddCopyShareLinkButtons(copyShareWrap->entity(), copyLink, shareLink);
|
||||||
|
if (revoked) {
|
||||||
|
AddDeleteLinkButton(container, deleteLink);
|
||||||
|
}
|
||||||
|
|
||||||
AddSkip(container, st::inviteLinkJoinedRowPadding.bottom() * 2);
|
AddSkip(container, st::inviteLinkJoinedRowPadding.bottom() * 2);
|
||||||
|
|
||||||
|
@ -242,19 +255,19 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
|
||||||
) | rpl::start_with_next([=](const LinkData &data) {
|
) | rpl::start_with_next([=](const LinkData &data) {
|
||||||
const auto now = base::unixtime::now();
|
const auto now = base::unixtime::now();
|
||||||
const auto expired = IsExpiredLink(data, now);
|
const auto expired = IsExpiredLink(data, now);
|
||||||
reactivateWrap->toggle(expired, anim::type::instant);
|
reactivateWrap->toggle(!revoked && expired, anim::type::instant);
|
||||||
copyShareWrap->toggle(!expired, anim::type::instant);
|
copyShareWrap->toggle(!revoked && !expired, anim::type::instant);
|
||||||
|
|
||||||
const auto timeExpired = (data.expireDate > 0)
|
const auto timeExpired = (data.expireDate > 0)
|
||||||
&& (data.expireDate <= now);
|
&& (data.expireDate <= now);
|
||||||
const auto usageExpired = (data.usageLimit > 0)
|
const auto usageExpired = (data.usageLimit > 0)
|
||||||
&& (data.usageLimit <= data.usage);
|
&& (data.usageLimit <= data.usage);
|
||||||
redLabelWrap->toggle(timeExpired, anim::type::instant);
|
redLabelWrap->toggle(!revoked && timeExpired, anim::type::instant);
|
||||||
grayLabelWrap->toggle(
|
grayLabelWrap->toggle(
|
||||||
!timeExpired && (data.expireDate > 0 || usageExpired),
|
!revoked && !timeExpired && (data.expireDate > 0 || usageExpired),
|
||||||
anim::type::instant);
|
anim::type::instant);
|
||||||
justDividerWrap->toggle(
|
justDividerWrap->toggle(
|
||||||
!data.expireDate && !expired,
|
revoked || (!data.expireDate && !expired),
|
||||||
anim::type::instant);
|
anim::type::instant);
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
@ -266,7 +279,8 @@ void Controller::prepare() {
|
||||||
const auto container = header.data();
|
const auto container = header.data();
|
||||||
|
|
||||||
const auto current = _data.current();
|
const auto current = _data.current();
|
||||||
if (!current.revoked && !current.permanent) {
|
const auto revoked = current.revoked;
|
||||||
|
if (revoked || !current.permanent) {
|
||||||
addHeaderBlock(container);
|
addHeaderBlock(container);
|
||||||
}
|
}
|
||||||
AddSubsectionTitle(
|
AddSubsectionTitle(
|
||||||
|
@ -296,7 +310,7 @@ void Controller::prepare() {
|
||||||
const auto now = base::unixtime::now();
|
const auto now = base::unixtime::now();
|
||||||
const auto timeExpired = (data.expireDate > 0)
|
const auto timeExpired = (data.expireDate > 0)
|
||||||
&& (data.expireDate <= now);
|
&& (data.expireDate <= now);
|
||||||
if (!data.usage && data.usageLimit > 0 && !timeExpired) {
|
if (!revoked && !data.usage && data.usageLimit > 0 && !timeExpired) {
|
||||||
auto description = object_ptr<Ui::FlatLabel>(
|
auto description = object_ptr<Ui::FlatLabel>(
|
||||||
nullptr,
|
nullptr,
|
||||||
tr::lng_group_invite_can_join_via_link(
|
tr::lng_group_invite_can_join_via_link(
|
||||||
|
@ -320,7 +334,7 @@ void Controller::prepare() {
|
||||||
delegate()->peerListSetDescription(nullptr);
|
delegate()->peerListSetDescription(nullptr);
|
||||||
}
|
}
|
||||||
listHeaderWrap->toggle(
|
listHeaderWrap->toggle(
|
||||||
data.usage || (data.usageLimit > 0 && !timeExpired),
|
!revoked && (data.usage || (data.usageLimit > 0 && !timeExpired)),
|
||||||
anim::type::instant);
|
anim::type::instant);
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
return data.usage
|
return data.usage
|
||||||
|
@ -351,7 +365,7 @@ void Controller::prepare() {
|
||||||
(data.usageLimit && (data.usageLimit <= data.usage)
|
(data.usageLimit && (data.usageLimit <= data.usage)
|
||||||
? std::make_optional(st::boxTextFgError->c)
|
? std::make_optional(st::boxTextFgError->c)
|
||||||
: std::nullopt));
|
: std::nullopt));
|
||||||
if (!data.usage && data.usageLimit > 0) {
|
if (revoked || (!data.usage && data.usageLimit > 0)) {
|
||||||
remaining->hide();
|
remaining->hide();
|
||||||
} else {
|
} else {
|
||||||
remaining->show();
|
remaining->show();
|
||||||
|
@ -836,6 +850,28 @@ void RevokeLink(
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeleteLink(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
not_null<UserData*> admin,
|
||||||
|
const QString &link) {
|
||||||
|
const auto box = std::make_shared<QPointer<ConfirmBox>>();
|
||||||
|
const auto sure = [=] {
|
||||||
|
const auto finish = [=] {
|
||||||
|
if (*box) {
|
||||||
|
(*box)->closeBox();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
peer->session().api().inviteLinks().destroy(
|
||||||
|
peer,
|
||||||
|
admin,
|
||||||
|
link,
|
||||||
|
finish);
|
||||||
|
};
|
||||||
|
*box = Ui::show(
|
||||||
|
Box<ConfirmBox>(tr::lng_group_invite_delete_sure(tr::now), sure),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
}
|
||||||
|
|
||||||
void ShowInviteLinkBox(
|
void ShowInviteLinkBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::InviteLink &link) {
|
const Api::InviteLink &link) {
|
||||||
|
@ -851,9 +887,7 @@ void ShowInviteLinkBox(
|
||||||
}) | rpl::map([=](const Api::InviteLinkUpdate &update) {
|
}) | rpl::map([=](const Api::InviteLinkUpdate &update) {
|
||||||
return update.now ? *update.now : LinkData{ .admin = admin };
|
return update.now ? *update.now : LinkData{ .admin = admin };
|
||||||
});
|
});
|
||||||
auto data = revoked
|
auto data = rpl::single(link) | rpl::then(std::move(updates));
|
||||||
? rpl::single(link) | rpl::type_erased()
|
|
||||||
: rpl::single(link) | rpl::then(std::move(updates));
|
|
||||||
|
|
||||||
auto initBox = [=, data = rpl::duplicate(data)](
|
auto initBox = [=, data = rpl::duplicate(data)](
|
||||||
not_null<Ui::BoxContent*> box) {
|
not_null<Ui::BoxContent*> box) {
|
||||||
|
|
|
@ -41,6 +41,10 @@ void RevokeLink(
|
||||||
void EditLink(
|
void EditLink(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::InviteLink &data);
|
const Api::InviteLink &data);
|
||||||
|
void DeleteLink(
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
not_null<UserData*> admin,
|
||||||
|
const QString &link);
|
||||||
|
|
||||||
void ShowInviteLinkBox(
|
void ShowInviteLinkBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
|
|
@ -195,28 +195,6 @@ private:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeleteLink(
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
not_null<UserData*> admin,
|
|
||||||
const QString &link) {
|
|
||||||
const auto box = std::make_shared<QPointer<ConfirmBox>>();
|
|
||||||
const auto sure = [=] {
|
|
||||||
const auto finish = [=] {
|
|
||||||
if (*box) {
|
|
||||||
(*box)->closeBox();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
peer->session().api().inviteLinks().destroy(
|
|
||||||
peer,
|
|
||||||
admin,
|
|
||||||
link,
|
|
||||||
finish);
|
|
||||||
};
|
|
||||||
*box = Ui::show(
|
|
||||||
Box<ConfirmBox>(tr::lng_group_invite_delete_sure(tr::now), sure),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DeleteAllRevoked(
|
void DeleteAllRevoked(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
not_null<UserData*> admin) {
|
not_null<UserData*> admin) {
|
||||||
|
|
|
@ -872,6 +872,10 @@ inviteLinkReactivate: RoundButton(inviteLinkCopy) {
|
||||||
icon: icon {{ "info/edit/links_reactivate", activeButtonFg }};
|
icon: icon {{ "info/edit/links_reactivate", activeButtonFg }};
|
||||||
iconOver: icon {{ "info/edit/links_reactivate", activeButtonFgOver }};
|
iconOver: icon {{ "info/edit/links_reactivate", activeButtonFgOver }};
|
||||||
}
|
}
|
||||||
|
inviteLinkDelete: RoundButton(inviteLinkCopy) {
|
||||||
|
icon: icon {{ "info/edit/links_delete", activeButtonFg }};
|
||||||
|
iconOver: icon {{ "info/edit/links_delete", activeButtonFgOver }};
|
||||||
|
}
|
||||||
inviteLinkUserpics: GroupCallUserpics {
|
inviteLinkUserpics: GroupCallUserpics {
|
||||||
size: 28px;
|
size: 28px;
|
||||||
shift: 6px;
|
shift: 6px;
|
||||||
|
|
|
@ -75,6 +75,19 @@ void AddReactivateLinkButton(
|
||||||
button->setClickedCallback(editLink);
|
button->setClickedCallback(editLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddDeleteLinkButton(
|
||||||
|
not_null<VerticalLayout*> container,
|
||||||
|
Fn<void()> deleteLink) {
|
||||||
|
const auto button = container->add(
|
||||||
|
object_ptr<RoundButton>(
|
||||||
|
container,
|
||||||
|
tr::lng_group_invite_delete(),
|
||||||
|
st::inviteLinkDelete),
|
||||||
|
st::inviteLinkButtonsPadding);
|
||||||
|
button->setTextTransform(RoundButton::TextTransform::NoTransform);
|
||||||
|
button->setClickedCallback(deleteLink);
|
||||||
|
}
|
||||||
|
|
||||||
not_null<AbstractButton*> AddJoinedCountButton(
|
not_null<AbstractButton*> AddJoinedCountButton(
|
||||||
not_null<VerticalLayout*> container,
|
not_null<VerticalLayout*> container,
|
||||||
rpl::producer<JoinedCountContent> content,
|
rpl::producer<JoinedCountContent> content,
|
||||||
|
|
|
@ -21,6 +21,10 @@ void AddReactivateLinkButton(
|
||||||
not_null<VerticalLayout*> container,
|
not_null<VerticalLayout*> container,
|
||||||
Fn<void()> editLink);
|
Fn<void()> editLink);
|
||||||
|
|
||||||
|
void AddDeleteLinkButton(
|
||||||
|
not_null<VerticalLayout*> container,
|
||||||
|
Fn<void()> deleteLink);
|
||||||
|
|
||||||
struct JoinedCountContent {
|
struct JoinedCountContent {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
QImage userpics;
|
QImage userpics;
|
||||||
|
|
Loading…
Reference in New Issue