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_peer.h"
#include "data/data_peer_values.h" // Data::AmPremiumValue.
#include "data/data_premium_limits.h"
#include "data/data_session.h"
#include "data/data_user.h"
#include "core/application.h"
@ -124,6 +125,12 @@ void EditExceptions(
const auto include = (options & Flag::Contacts) != Flags(0);
const auto rules = data->current();
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>(
session,
(include
@ -132,9 +139,8 @@ void EditExceptions(
options,
rules.flags() & options,
include ? rules.always() : rules.never(),
[=](int count) {
return Box(FilterChatsLimitBox, session, count, include);
});
limit,
showLimitReached);
const auto rawController = controller.get();
auto initBox = [=](not_null<PeerListBox*> box) {
box->setCloseByOutsideClick(false);

View file

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

View file

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

View file

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