Allow revoking confcall link.

This commit is contained in:
John Preston 2025-04-04 23:53:54 +05:00
parent c507382d19
commit c972485555
5 changed files with 99 additions and 3 deletions

View file

@ -4930,6 +4930,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_confcall_join_button" = "Join Group Call";
"lng_confcall_create_link" = "Create Call Link";
"lng_confcall_create_link_description" = "You can create a link that will allow your friends on Telegram to join the call.";
"lng_confcall_link_revoke" = "Revoke link";
"lng_confcall_link_revoked_title" = "Link Revoked";
"lng_confcall_link_revoked_text" = "A new link has been generated.";
"lng_confcall_link_title" = "Call Link";
"lng_confcall_link_about" = "Anyone on Telegram can join your call by following the link below.";
"lng_confcall_link_or" = "or";

View file

@ -578,6 +578,13 @@ groupCallPopupMenu: PopupMenu(defaultPopupMenu) {
menu: groupCallMenu;
animation: groupCallPanelAnimation;
}
groupCallPopupMenuWithIcons: PopupMenu(popupMenuWithIcons) {
shadow: groupCallMenuShadow;
menu: Menu(groupCallMenu, menuWithIcons) {
arrow: icon {{ "menu/submenu_arrow", groupCallMemberNotJoinedStatus }};
}
animation: groupCallPanelAnimation;
}
groupCallPopupMenuWithVolume: PopupMenu(groupCallPopupMenu) {
scrollPadding: margins(0px, 3px, 0px, 8px);
menu: Menu(groupCallMenu) {
@ -1617,3 +1624,15 @@ groupCallInviteLink: SettingsButton(defaultSettingsButton) {
}
groupCallInviteLinkIcon: icon {{ "info/edit/group_manage_links", mediaviewTextLinkFg }};
groupCallInviteLinkIconPosition: point(23px, 2px);
confcallLinkMenu: IconButton(boxTitleClose) {
icon: icon {{ "title_menu_dots", boxTitleCloseFg }};
iconOver: icon {{ "title_menu_dots", boxTitleCloseFgOver }};
}
groupCallLinkMenu: IconButton(confcallLinkMenu) {
icon: icon {{ "title_menu_dots", groupCallMemberInactiveIcon }};
iconOver: icon {{ "title_menu_dots", groupCallMemberInactiveIcon }};
ripple: RippleAnimation(defaultRippleAnimation) {
color: groupCallMembersBgOver;
}
}

View file

@ -21,15 +21,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/boxes/boost_box.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/popup_menu.h"
#include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h"
#include "ui/toast/toast.h"
#include "ui/painter.h"
#include "ui/vertical_list.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "window/window_session_controller.h"
#include "styles/style_info.h"
#include "styles/style_layers.h"
#include "styles/style_media_view.h"
#include "styles/style_menu_icons.h"
#include "styles/style_calls.h"
#include "styles/style_chat.h"
@ -235,9 +239,12 @@ void ConferenceCallJoinConfirm(
ConferenceCallLinkStyleOverrides DarkConferenceCallLinkStyle() {
return {
.box = &st::groupCallLinkBox,
.menuToggle = &st::groupCallLinkMenu,
.menu = &st::groupCallPopupMenuWithIcons,
.close = &st::storiesStealthBoxClose,
.centerLabel = &st::groupCallLinkCenteredText,
.linkPreview = &st::groupCallLinkPreview,
.contextRevoke = &st::mediaMenuIconRemove,
.shareBox = std::make_shared<ShareBoxStyleOverrides>(
DarkShareBoxStyle()),
};
@ -251,6 +258,12 @@ void ShowConferenceCallLinkBox(
const auto st = args.st;
const auto initial = args.initial;
show->showBox(Box([=](not_null<Ui::GenericBox*> box) {
struct State {
base::unique_qptr<Ui::PopupMenu> menu;
bool resetting = false;
};
const auto state = box->lifetime().make_state<State>();
box->setStyle(st.box
? *st.box
: initial
@ -258,9 +271,65 @@ void ShowConferenceCallLinkBox(
: st::confcallLinkBox);
box->setWidth(st::boxWideWidth);
box->setNoContentMargin(true);
box->addTopButton(st.close ? *st.close : st::boxTitleClose, [=] {
box->closeBox();
});
const auto close = box->addTopButton(
st.close ? *st.close : st::boxTitleClose,
[=] { box->closeBox(); });
if (!args.initial && call->canManage()) {
const auto toggle = Ui::CreateChild<Ui::IconButton>(
close->parentWidget(),
st.menuToggle ? *st.menuToggle : st::confcallLinkMenu);
const auto handler = [=] {
if (state->resetting) {
return;
}
state->resetting = true;
using Flag = MTPphone_ToggleGroupCallSettings::Flag;
call->session().api().request(
MTPphone_ToggleGroupCallSettings(
MTP_flags(Flag::f_reset_invite_hash),
call->input(),
MTPbool()) // join_muted
).done([=] {
auto copy = args;
const auto weak = Ui::MakeWeak(box);
copy.finished = [=](QString link) {
if (const auto strong = weak.data()) {
strong->closeBox();
}
show->showToast({
.title = tr::lng_confcall_link_revoked_title(
tr::now),
.text = tr::lng_confcall_link_revoked_text(
tr::now),
});
};
ExportConferenceCallLink(
show,
call,
std::move(copy));
}).send();
};
toggle->setClickedCallback([=] {
state->menu = base::make_unique_q<Ui::PopupMenu>(
toggle,
st.menu ? *st.menu : st::popupMenuWithIcons);
state->menu->addAction(
tr::lng_confcall_link_revoke(tr::now),
handler,
(st.contextRevoke
? st.contextRevoke
: &st::menuIconRemove));
state->menu->popup(QCursor::pos());
});
close->geometryValue(
) | rpl::start_with_next([=](QRect geometry) {
toggle->moveToLeft(
geometry.x() - toggle->width(),
geometry.y());
}, close->lifetime());
}
box->addRow(
Info::BotStarRef::CreateLinkHeaderIcon(box, &call->session()),

View file

@ -18,6 +18,7 @@ struct Box;
struct FlatLabel;
struct IconButton;
struct InputField;
struct PopupMenu;
} // namespace style
namespace Data {
@ -164,9 +165,12 @@ void ConferenceCallJoinConfirm(
struct ConferenceCallLinkStyleOverrides {
const style::Box *box = nullptr;
const style::IconButton *menuToggle = nullptr;
const style::PopupMenu *menu = nullptr;
const style::IconButton *close = nullptr;
const style::FlatLabel *centerLabel = nullptr;
const style::InputField *linkPreview = nullptr;
const style::icon *contextRevoke = nullptr;
std::shared_ptr<ShareBoxStyleOverrides> shareBox;
};
[[nodiscard]] ConferenceCallLinkStyleOverrides DarkConferenceCallLinkStyle();

View file

@ -212,6 +212,7 @@ mediaMenuIconArchiveStory: icon {{ "menu/stories_archive", mediaviewMenuFg }};
mediaMenuIconStealthLocked: icon {{ "menu/stealth_locked", mediaviewMenuFg }};
mediaMenuIconStealth: icon {{ "menu/stealth", mediaviewMenuFg }};
mediaMenuIconStats: icon {{ "menu/stats", mediaviewMenuFg }};
mediaMenuIconRemove: icon {{ "menu/remove", mediaviewMenuFg }};
mediaMenuIconInfo: icon {{ "menu/info", mediaviewMenuFg }};
mediaMenuIconBlock: icon {{ "menu/block", mediaviewMenuFg }};