-
Notifications
You must be signed in to change notification settings - Fork 208
Add batch "Dismiss all" and "Ban all" actions to join requests UI #239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1026,6 +1026,16 @@ requestsRejectButton: RoundButton(defaultLightButton) { | |||||||||
| textTop: 6px; | ||||||||||
| } | ||||||||||
| requestsBanButton: RoundButton(defaultActiveButton) { | ||||||||||
| textBg: banButtonBg; | ||||||||||
| textBgOver: banButtonBgOver; | ||||||||||
| width: -28px; | ||||||||||
| height: 30px; | ||||||||||
| textTop: 6px; | ||||||||||
| ripple: RippleAnimation(defaultRippleAnimation) { | ||||||||||
| color: banButtonBgRipple; | ||||||||||
| } | ||||||||||
|
Comment on lines
+1035
to
+1036
|
||||||||||
| color: banButtonBgRipple; | |
| } | |
| color: banButtonBgRipple; | |
| } |
Copilot
AI
Nov 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Negative width value -28px is likely incorrect. This should be a positive value or use a different sizing approach.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,8 @@ For license and copyright information please follow this link: | |
| #include "ui/painter.h" | ||
| #include "ui/round_rect.h" | ||
| #include "ui/text/text_utilities.h" | ||
| #include "ui/widgets/buttons.h" | ||
| #include "ui/boxes/confirm_box.h" | ||
| #include "window/window_session_controller.h" | ||
| #include "styles/style_boxes.h" | ||
|
|
||
|
|
@@ -398,9 +400,123 @@ void RequestsBoxController::prepare() { | |
| : tr::lng_manage_peer_requests()); | ||
| setDescriptionText(tr::lng_contacts_loading(tr::now)); | ||
| setSearchNoResultsText(tr::lng_blocked_list_not_found(tr::now)); | ||
| delegate()->peerListSetAboveWidget(createBatchActionsWidget()); | ||
| loadMoreRows(); | ||
| } | ||
|
|
||
| object_ptr<Ui::RpWidget> RequestsBoxController::createBatchActionsWidget() { | ||
| auto result = object_ptr<Ui::RpWidget>(static_cast<QWidget*>(nullptr)); | ||
| const auto container = result.data(); | ||
|
|
||
| const auto dismissAll = Ui::CreateChild<Ui::RoundButton>( | ||
| container, | ||
| tr::lng_group_requests_dismiss_all(), | ||
| st::requestsRejectButton); | ||
| dismissAll->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); | ||
| dismissAll->setClickedCallback([=] { | ||
| dismissAllRequests(); | ||
| }); | ||
|
|
||
| const auto banAll = Ui::CreateChild<Ui::RoundButton>( | ||
| container, | ||
| tr::lng_group_requests_ban_all(), | ||
| st::requestsBanAllButton); | ||
| banAll->setTextTransform(Ui::RoundButton::TextTransform::NoTransform); | ||
| banAll->setClickedCallback([=] { | ||
| banAllRequests(); | ||
| }); | ||
|
|
||
| container->widthValue( | ||
| ) | rpl::start_with_next([=](int width) { | ||
| const auto padding = st::requestButtonsSkip * 2; | ||
| const auto buttonWidth = (width - padding * 3) / 2; | ||
| const auto height = st::requestsAcceptButton.height + st::requestButtonsSkip * 2; | ||
| container->resize(width, height); | ||
| dismissAll->setGeometry( | ||
| padding, | ||
| st::requestButtonsSkip, | ||
| buttonWidth, | ||
| st::requestsAcceptButton.height); | ||
| banAll->setGeometry( | ||
| padding * 2 + buttonWidth, | ||
| st::requestButtonsSkip, | ||
| buttonWidth, | ||
| st::requestsAcceptButton.height); | ||
| }, container->lifetime()); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| void RequestsBoxController::dismissAllRequests() { | ||
| const auto count = delegate()->peerListFullRowsCount(); | ||
| if (count == 0) { | ||
| return; | ||
| } | ||
|
|
||
| const auto guard = base::make_weak(this); | ||
| delegate()->peerListUiShow()->showBox(Ui::MakeConfirmBox({ | ||
| .text = tr::lng_group_requests_dismiss_all_confirm(tr::now), | ||
| .confirmed = [=] { | ||
| if (!guard) { | ||
| return; | ||
| } | ||
| // Collect all users | ||
| std::vector<not_null<UserData*>> users; | ||
| const auto fullCount = delegate()->peerListFullRowsCount(); | ||
| for (auto i = 0; i < fullCount; ++i) { | ||
|
Comment on lines
+464
to
+466
|
||
| const auto row = delegate()->peerListRowAt(i); | ||
| if (const auto user = row->peer()->asUser()) { | ||
| users.push_back(user); | ||
| } | ||
| } | ||
|
|
||
| // Process all requests | ||
| for (const auto user : users) { | ||
| processRequest(user, false, false); | ||
| } | ||
|
Comment on lines
+463
to
+476
|
||
| } | ||
| })); | ||
| } | ||
|
|
||
| void RequestsBoxController::banAllRequests() { | ||
| const auto count = delegate()->peerListFullRowsCount(); | ||
| if (count == 0) { | ||
| return; | ||
| } | ||
|
|
||
| if (count >= 20) { | ||
| delegate()->peerListUiShow()->showBox(Ui::MakeConfirmBox({ | ||
| .text = tr::lng_group_requests_ban_too_much_users(tr::now), | ||
| .inform = true | ||
| })); | ||
| return; | ||
| } | ||
|
|
||
| const auto guard = base::make_weak(this); | ||
| delegate()->peerListUiShow()->showBox(Ui::MakeConfirmBox({ | ||
| .text = tr::lng_group_requests_ban_all_confirm(tr::now), | ||
| .confirmed = [=] { | ||
| if (!guard) { | ||
| return; | ||
| } | ||
| // Collect all users | ||
| std::vector<not_null<UserData*>> users; | ||
| const auto fullCount = delegate()->peerListFullRowsCount(); | ||
| for (auto i = 0; i < fullCount; ++i) { | ||
| const auto row = delegate()->peerListRowAt(i); | ||
| if (const auto user = row->peer()->asUser()) { | ||
| users.push_back(user); | ||
| } | ||
| } | ||
|
|
||
| // Process all requests | ||
| for (const auto user : users) { | ||
| processRequest(user, false, true); | ||
| } | ||
| } | ||
| })); | ||
| } | ||
|
|
||
| void RequestsBoxController::loadMoreRows() { | ||
| if (searchController() && searchController()->loadMoreRows()) { | ||
| return; | ||
|
|
@@ -589,7 +705,6 @@ void RequestsBoxController::RowHelper::rowPaintBan( | |
| std::unique_ptr<Ui::RippleAnimation> &ripple, | ||
| int outerWidth, | ||
| bool over) { | ||
| _banRect.setColor(st::banButtonBg); | ||
| paintButton( | ||
| p, | ||
| geometry, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation: this line uses spaces while surrounding lines use tabs. Should use tabs to match the file's indentation style.