Fix limit in business features exception box.

This commit is contained in:
John Preston 2024-03-07 17:15:27 +04:00
parent 00dcf11691
commit d608bffecb
4 changed files with 20 additions and 15 deletions

View file

@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat_filters.h" #include "data/data_chat_filters.h"
#include "data/data_peer.h" #include "data/data_peer.h"
#include "data/data_peer_values.h" // Data::AmPremiumValue. #include "data/data_peer_values.h" // Data::AmPremiumValue.
#include "data/data_premium_limits.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "core/application.h" #include "core/application.h"
@ -124,6 +125,12 @@ void EditExceptions(
const auto include = (options & Flag::Contacts) != Flags(0); const auto include = (options & Flag::Contacts) != Flags(0);
const auto rules = data->current(); const auto rules = data->current();
const auto session = &window->session(); const auto session = &window->session();
const auto limit = Data::PremiumLimits(
session
).dialogFiltersChatsCurrent();
const auto showLimitReached = [=] {
window->show(Box(FilterChatsLimitBox, session, limit, include));
};
auto controller = std::make_unique<EditFilterChatsListController>( auto controller = std::make_unique<EditFilterChatsListController>(
session, session,
(include (include
@ -132,9 +139,8 @@ void EditExceptions(
options, options,
rules.flags() & options, rules.flags() & options,
include ? rules.always() : rules.never(), include ? rules.always() : rules.never(),
[=](int count) { limit,
return Box(FilterChatsLimitBox, session, count, include); showLimitReached);
});
const auto rawController = controller.get(); const auto rawController = controller.get();
auto initBox = [=](not_null<PeerListBox*> box) { auto initBox = [=](not_null<PeerListBox*> box) {
box->setCloseByOutsideClick(false); box->setCloseByOutsideClick(false);

View file

@ -333,17 +333,17 @@ EditFilterChatsListController::EditFilterChatsListController(
Flags options, Flags options,
Flags selected, Flags selected,
const base::flat_set<not_null<History*>> &peers, const base::flat_set<not_null<History*>> &peers,
LimitBoxFactory limitBox) int limit,
Fn<void()> showLimitReached)
: ChatsListBoxController(session) : ChatsListBoxController(session)
, _session(session) , _session(session)
, _limitBox(std::move(limitBox)) , _showLimitReached(std::move(showLimitReached))
, _title(std::move(title)) , _title(std::move(title))
, _peers(peers) , _peers(peers)
, _options(options & ~Flag::Chatlist) , _options(options & ~Flag::Chatlist)
, _selected(selected) , _selected(selected)
, _limit(Data::PremiumLimits(session).dialogFiltersChatsCurrent()) , _limit(limit)
, _chatlist(options & Flag::Chatlist) { , _chatlist(options & Flag::Chatlist) {
Expects(_limitBox != nullptr);
} }
Main::Session &EditFilterChatsListController::session() const { Main::Session &EditFilterChatsListController::session() const {
@ -371,8 +371,8 @@ void EditFilterChatsListController::rowClicked(not_null<PeerListRow*> row) {
if (count < _limit || row->checked()) { if (count < _limit || row->checked()) {
delegate()->peerListSetRowChecked(row, !row->checked()); delegate()->peerListSetRowChecked(row, !row->checked());
updateTitle(); updateTitle();
} else { } else if (const auto copy = _showLimitReached) {
delegate()->peerListUiShow()->showBox(_limitBox(count)); copy();
} }
} }

View file

@ -43,7 +43,6 @@ class EditFilterChatsListController final : public ChatsListBoxController {
public: public:
using Flag = Data::ChatFilter::Flag; using Flag = Data::ChatFilter::Flag;
using Flags = Data::ChatFilter::Flags; using Flags = Data::ChatFilter::Flags;
using LimitBoxFactory = Fn<object_ptr<Ui::BoxContent>(int)>;
EditFilterChatsListController( EditFilterChatsListController(
not_null<Main::Session*> session, not_null<Main::Session*> session,
@ -51,7 +50,8 @@ public:
Flags options, Flags options,
Flags selected, Flags selected,
const base::flat_set<not_null<History*>> &peers, const base::flat_set<not_null<History*>> &peers,
LimitBoxFactory limitBox); int limit,
Fn<void()> showLimitReached);
[[nodiscard]] Main::Session &session() const override; [[nodiscard]] Main::Session &session() const override;
[[nodiscard]] Flags chosenOptions() const { [[nodiscard]] Flags chosenOptions() const {
@ -72,7 +72,7 @@ private:
void updateTitle(); void updateTitle();
const not_null<Main::Session*> _session; const not_null<Main::Session*> _session;
const LimitBoxFactory _limitBox; const Fn<void()> _showLimitReached;
rpl::producer<QString> _title; rpl::producer<QString> _title;
base::flat_set<not_null<History*>> _peers; base::flat_set<not_null<History*>> _peers;
Flags _options; Flags _options;

View file

@ -72,9 +72,8 @@ void EditBusinessChats(
options, options,
TypesToFlags(descriptor.current.types) & options, TypesToFlags(descriptor.current.types) & options,
base::flat_set<not_null<History*>>(begin(peers), end(peers)), base::flat_set<not_null<History*>>(begin(peers), end(peers)),
[=](int count) { 100,
return nullptr; AssertIsDebug(); nullptr);
});
const auto rawController = controller.get(); const auto rawController = controller.get();
const auto save = descriptor.save; const auto save = descriptor.save;
auto initBox = [=](not_null<PeerListBox*> box) { auto initBox = [=](not_null<PeerListBox*> box) {