Added ability to remove personal channel from your profile section.

This commit is contained in:
23rd
2025-12-14 14:26:43 +03:00
committed by John Preston
parent 8c3a8a7d20
commit 0f41fd1356
3 changed files with 31 additions and 1 deletions

View File

@@ -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.";

View File

@@ -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<PersonalChannelController>(
@@ -1852,7 +1856,7 @@ const std::vector<LocalUrlHandler> &InternalUrlHandlers() {
ShowEditBirthdayPrivacy,
},
{
u"^edit_personal_channel(?::(\\d{2,}))?$"_q,
u"^edit_personal_channel(?::(?:(\\d{2,})|(remove)))?$"_q,
ShowEditPersonalChannel,
},
{

View File

@@ -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<Ui::RpWidget> DetailsFiller::setupPersonalChannel(
return text;
});
};
if (user->isSelf()) {
struct State {
base::unique_qptr<Ui::PopupMenu> menu;
};
const auto state = container->lifetime().make_state<State>();
base::install_event_filter(container, [=](
not_null<QEvent*> e) {
if (e->type() == QEvent::ContextMenu) {
const auto ce = static_cast<QContextMenuEvent*>(e.get());
state->menu = base::make_unique_q<Ui::PopupMenu>(
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(