mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Respect hidden_members_group_size_min in group edit.
This commit is contained in:
parent
bd490421e8
commit
d6c188d642
3 changed files with 19 additions and 2 deletions
|
@ -14,16 +14,33 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
|
#include "main/main_account.h"
|
||||||
|
#include "main/main_app_config.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "styles/style_info.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(
|
[[nodiscard]] object_ptr<Ui::RpWidget> CreateMembersVisibleButton(
|
||||||
not_null<ChannelData*> megagroup) {
|
not_null<ChannelData*> megagroup) {
|
||||||
auto result = object_ptr<Ui::VerticalLayout>((QWidget*)nullptr);
|
auto result = object_ptr<Ui::VerticalLayout>((QWidget*)nullptr);
|
||||||
const auto container = result.data();
|
const auto container = result.data();
|
||||||
|
|
||||||
|
const auto min = EnableHideMembersMin(megagroup);
|
||||||
|
if (!megagroup->canBanMembers() || megagroup->membersCount() < min) {
|
||||||
|
return { nullptr };
|
||||||
|
}
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
rpl::event_stream<bool> toggled;
|
rpl::event_stream<bool> toggled;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1189,7 +1189,7 @@ void ParticipantsBoxController::prepare() {
|
||||||
Unexpected("Role in ParticipantsBoxController::prepare()");
|
Unexpected("Role in ParticipantsBoxController::prepare()");
|
||||||
}();
|
}();
|
||||||
if (const auto megagroup = _peer->asMegagroup()) {
|
if (const auto megagroup = _peer->asMegagroup()) {
|
||||||
if ((_role == Role::Members) && megagroup->canBanMembers()) {
|
if (_role == Role::Members) {
|
||||||
delegate()->peerListSetAboveWidget(CreateMembersVisibleButton(
|
delegate()->peerListSetAboveWidget(CreateMembersVisibleButton(
|
||||||
megagroup));
|
megagroup));
|
||||||
} else if ((_role == Role::Admins)
|
} else if ((_role == Role::Admins)
|
||||||
|
|
|
@ -85,7 +85,7 @@ object_ptr<Ui::RpWidget> AntiSpamValidator::createButton() const {
|
||||||
|
|
||||||
const auto updateLocked = [=] {
|
const auto updateLocked = [=] {
|
||||||
const auto min = EnableAntiSpamMinMembers(channel);
|
const auto min = EnableAntiSpamMinMembers(channel);
|
||||||
const auto locked = (channel->membersCount() <= min);
|
const auto locked = (channel->membersCount() < min);
|
||||||
state->locked = locked;
|
state->locked = locked;
|
||||||
button->setToggleLocked(locked);
|
button->setToggleLocked(locked);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue