diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 77d758b258..f8be4fb457 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -797,6 +797,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_channel_label" = "Personal channel"; "lng_settings_channel_add" = "Add"; "lng_settings_channel_remove" = "Remove"; +"lng_settings_channel_menu_remove" = "Remove Personal Channel"; "lng_settings_channel_no_yet" = "You don't have any public channels yet."; "lng_settings_channel_start" = "Start a Channel"; "lng_settings_channel_saved" = "Your personal channel was updated."; diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 4d844ae01f..afc03da744 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -1147,6 +1147,7 @@ bool ShowEditPersonalChannel( return true; } const auto maybePeerId = match->captured(1); + const auto maybeRemove = match->captured(2); if (!maybePeerId.isEmpty()) { if (const auto peerId = PeerId(maybePeerId.toULongLong())) { @@ -1157,6 +1158,9 @@ bool ShowEditPersonalChannel( } } } + } else if (!maybeRemove.isEmpty()) { + SavePersonalChannel(controller, nullptr); + return true; } auto listController = std::make_unique( @@ -1852,7 +1856,7 @@ const std::vector &InternalUrlHandlers() { ShowEditBirthdayPrivacy, }, { - u"^edit_personal_channel(?::(\\d{2,}))?$"_q, + u"^edit_personal_channel(?::(?:(\\d{2,})|(remove)))?$"_q, ShowEditPersonalChannel, }, { diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 5f3dfc6d34..83aed2839a 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_credits.h" #include "api/api_statistics.h" #include "apiwrap.h" +#include "base/event_filter.h" #include "base/options.h" #include "base/timer_rpl.h" #include "base/unixtime.h" @@ -1806,6 +1807,30 @@ object_ptr DetailsFiller::setupPersonalChannel( return text; }); }; + if (user->isSelf()) { + struct State { + base::unique_qptr menu; + }; + const auto state = container->lifetime().make_state(); + base::install_event_filter(container, [=]( + not_null e) { + if (e->type() == QEvent::ContextMenu) { + const auto ce = static_cast(e.get()); + state->menu = base::make_unique_q( + container, + st::defaultPopupMenu); + state->menu->addAction( + tr::lng_settings_channel_menu_remove(tr::now), + [] { + UrlClickHandler::Open( + u"internal:edit_personal_channel:remove"_q); + }); + state->menu->popup(ce->globalPos()); + return base::EventFilterResult::Cancel; + } + return base::EventFilterResult::Continue; + }, container->lifetime()); + } { const auto onlyChannelWrap = container->add(