Respect hidden_members_group_size_min in group edit.

This commit is contained in:
John Preston 2022-12-23 14:34:49 +04:00
parent bd490421e8
commit d6c188d642
3 changed files with 19 additions and 2 deletions

View file

@ -14,16 +14,33 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/slide_wrap.h"
#include "ui/widgets/buttons.h"
#include "settings/settings_common.h"
#include "main/main_account.h"
#include "main/main_app_config.h"
#include "main/main_session.h"
#include "apiwrap.h"
#include "lang/lang_keys.h"
#include "styles/style_info.h"
namespace {
[[nodiscard]] int EnableHideMembersMin(not_null<ChannelData*> channel) {
return channel->session().account().appConfig().get<int>(
u"hidden_members_group_size_min"_q,
100);
}
} // namespace
[[nodiscard]] object_ptr<Ui::RpWidget> CreateMembersVisibleButton(
not_null<ChannelData*> megagroup) {
auto result = object_ptr<Ui::VerticalLayout>((QWidget*)nullptr);
const auto container = result.data();
const auto min = EnableHideMembersMin(megagroup);
if (!megagroup->canBanMembers() || megagroup->membersCount() < min) {
return { nullptr };
}
struct State {
rpl::event_stream<bool> toggled;
};

View file

@ -1189,7 +1189,7 @@ void ParticipantsBoxController::prepare() {
Unexpected("Role in ParticipantsBoxController::prepare()");
}();
if (const auto megagroup = _peer->asMegagroup()) {
if ((_role == Role::Members) && megagroup->canBanMembers()) {
if (_role == Role::Members) {
delegate()->peerListSetAboveWidget(CreateMembersVisibleButton(
megagroup));
} else if ((_role == Role::Admins)

View file

@ -85,7 +85,7 @@ object_ptr<Ui::RpWidget> AntiSpamValidator::createButton() const {
const auto updateLocked = [=] {
const auto min = EnableAntiSpamMinMembers(channel);
const auto locked = (channel->membersCount() <= min);
const auto locked = (channel->membersCount() < min);
state->locked = locked;
button->setToggleLocked(locked);
};