From f2bfaba7890424d337407ab97f296af21a48ffff Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 29 Jun 2026 19:35:56 +0400 Subject: [PATCH] Add hidden group option when creating a community --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/api/api_communities.cpp | 5 ++++- Telegram/SourceFiles/api/api_communities.h | 1 + Telegram/SourceFiles/boxes/peers/add_to_community_box.cpp | 7 +++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 575c9b6eb6..57e73e38df 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2211,6 +2211,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_community_create_title" = "New Community"; "lng_community_create_name" = "Community Name"; "lng_community_created" = "Community created."; +"lng_community_create_hidden" = "Hidden group"; "lng_community_visibility_title" = "Chat visibility"; "lng_community_visibility_visible" = "Visible"; "lng_community_visibility_visible_about" = "Anyone in the community will be able to see this chat."; diff --git a/Telegram/SourceFiles/api/api_communities.cpp b/Telegram/SourceFiles/api/api_communities.cpp index e5bc0b94a8..bc0435fef7 100644 --- a/Telegram/SourceFiles/api/api_communities.cpp +++ b/Telegram/SourceFiles/api/api_communities.cpp @@ -63,11 +63,14 @@ void Communities::create( const QString &title, const QString &about, not_null peer, + bool hidden, Fn)> done, Fn fail) { using Flag = MTPcommunities_Create::Flag; + const auto flags = (about.isEmpty() ? Flag() : Flag::f_about) + | (hidden ? Flag::f_hidden : Flag()); _api.request(MTPcommunities_Create( - MTP_flags(about.isEmpty() ? Flag() : Flag::f_about), + MTP_flags(flags), MTP_string(title), MTP_string(about), peer->input() diff --git a/Telegram/SourceFiles/api/api_communities.h b/Telegram/SourceFiles/api/api_communities.h index e01f12315a..3ea7b3e491 100644 --- a/Telegram/SourceFiles/api/api_communities.h +++ b/Telegram/SourceFiles/api/api_communities.h @@ -57,6 +57,7 @@ public: const QString &title, const QString &about, not_null peer, + bool hidden, Fn)> done, Fn fail); diff --git a/Telegram/SourceFiles/boxes/peers/add_to_community_box.cpp b/Telegram/SourceFiles/boxes/peers/add_to_community_box.cpp index d8eb1cf657..e933ac0380 100644 --- a/Telegram/SourceFiles/boxes/peers/add_to_community_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/add_to_community_box.cpp @@ -134,6 +134,12 @@ void CreateCommunityBox( tr::lng_community_create_name())); box->setFocusCallback([=] { field->setFocusFast(); }); + const auto hidden = box->addRow(object_ptr( + box, + tr::lng_community_create_hidden(tr::now), + false, + st::defaultBoxCheckbox)); + const auto creating = box->lifetime().make_state(false); const auto submit = [=] { const auto title = field->getLastText().trimmed(); @@ -149,6 +155,7 @@ void CreateCommunityBox( title, QString(), group, + hidden->checked(), crl::guard(box, [=](not_null community) { show->hideLayer(); show->showToast(tr::lng_community_created(tr::now));