mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Allow processing requests from full list.
This commit is contained in:
parent
9dfbc96274
commit
0dfbd5fa6e
9 changed files with 124 additions and 32 deletions
|
@ -1349,6 +1349,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_group_requests_add_channel" = "Add to Channel";
|
"lng_group_requests_add_channel" = "Add to Channel";
|
||||||
"lng_group_requests_dismiss" = "Dismiss";
|
"lng_group_requests_dismiss" = "Dismiss";
|
||||||
"lng_group_requests_was_added" = "{user} has been added to the group.";
|
"lng_group_requests_was_added" = "{user} has been added to the group.";
|
||||||
|
"lng_group_requests_was_added_channel" = "{user} has been added to the channel.";
|
||||||
"lng_group_requests_none" = "No member requests";
|
"lng_group_requests_none" = "No member requests";
|
||||||
"lng_group_requests_none_channel" = "No subscriber requests";
|
"lng_group_requests_none_channel" = "No subscriber requests";
|
||||||
|
|
||||||
|
|
|
@ -466,7 +466,18 @@ void InviteLinks::processRequest(
|
||||||
_api->requestParticipantsCountDelayed(channel);
|
_api->requestParticipantsCountDelayed(channel);
|
||||||
}
|
}
|
||||||
_api->applyUpdates(result);
|
_api->applyUpdates(result);
|
||||||
if (approved) {
|
if (link.isEmpty() && approved) {
|
||||||
|
// We don't know the link that was used for this user.
|
||||||
|
// Prune all the cache.
|
||||||
|
for (auto i = begin(_firstJoined); i != end(_firstJoined);) {
|
||||||
|
if (i->first.peer == peer) {
|
||||||
|
i = _firstJoined.erase(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_firstSlices.remove(peer);
|
||||||
|
} else if (approved) {
|
||||||
const auto i = _firstJoined.find({ peer, link });
|
const auto i = _firstJoined.find({ peer, link });
|
||||||
if (i != end(_firstJoined)) {
|
if (i != end(_firstJoined)) {
|
||||||
++i->second.count;
|
++i->second.count;
|
||||||
|
|
|
@ -994,13 +994,27 @@ sponsoredUrlButton: RoundButton(defaultActiveButton) {
|
||||||
|
|
||||||
requestsBoxItem: PeerListItem(peerListBoxItem) {
|
requestsBoxItem: PeerListItem(peerListBoxItem) {
|
||||||
height: 99px;
|
height: 99px;
|
||||||
|
button: OutlineButton(defaultPeerListButton) {
|
||||||
|
textBg: contactsBg;
|
||||||
|
textBgOver: contactsBg;
|
||||||
|
ripple: RippleAnimation(defaultRippleAnimation) {
|
||||||
|
color: contactsBgOver;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
requestsBoxList: PeerList(peerListBox) {
|
requestsBoxList: PeerList(peerListBox) {
|
||||||
|
padding: margins(0px, 12px, 0px, 12px);
|
||||||
item: requestsBoxItem;
|
item: requestsBoxItem;
|
||||||
}
|
}
|
||||||
requestsAcceptButton: RoundButton(defaultActiveButton) {
|
requestsAcceptButton: RoundButton(defaultActiveButton) {
|
||||||
|
width: -28px;
|
||||||
|
height: 30px;
|
||||||
|
textTop: 6px;
|
||||||
}
|
}
|
||||||
requestsRejectButton: RoundButton(defaultLightButton) {
|
requestsRejectButton: RoundButton(defaultLightButton) {
|
||||||
|
width: -28px;
|
||||||
|
height: 30px;
|
||||||
|
textTop: 6px;
|
||||||
}
|
}
|
||||||
requestAcceptPosition: point(71px, 58px);
|
requestAcceptPosition: point(71px, 58px);
|
||||||
requestButtonsSkip: 9px;
|
requestButtonsSkip: 9px;
|
||||||
|
|
|
@ -542,6 +542,10 @@ bool PeerListRow::elementDisabled(int element) const {
|
||||||
return (element == 1) && rightActionDisabled();
|
return (element == 1) && rightActionDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PeerListRow::elementOnlySelect(int element) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void PeerListRow::elementAddRipple(
|
void PeerListRow::elementAddRipple(
|
||||||
int element,
|
int element,
|
||||||
QPoint point,
|
QPoint point,
|
||||||
|
@ -1479,7 +1483,8 @@ crl::time PeerListContent::paintRow(
|
||||||
: (_pressed.index.value >= 0)
|
: (_pressed.index.value >= 0)
|
||||||
? _pressed
|
? _pressed
|
||||||
: _selected;
|
: _selected;
|
||||||
const auto selected = (active.index == index);
|
const auto selected = (active.index == index)
|
||||||
|
&& (!active.element || !row->elementOnlySelect(active.element));
|
||||||
|
|
||||||
if (_mode == Mode::Custom) {
|
if (_mode == Mode::Custom) {
|
||||||
_controller->customRowPaint(p, now, row, selected);
|
_controller->customRowPaint(p, now, row, selected);
|
||||||
|
@ -1557,7 +1562,11 @@ crl::time PeerListContent::paintRow(
|
||||||
row->paintStatusText(p, _st.item, _st.item.statusPosition.x(), _st.item.statusPosition.y(), statusw, width(), selected);
|
row->paintStatusText(p, _st.item, _st.item.statusPosition.x(), _st.item.statusPosition.y(), statusw, width(), selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
row->elementsPaint(p, width(), selected, selected ? active.element : 0);
|
row->elementsPaint(
|
||||||
|
p,
|
||||||
|
width(),
|
||||||
|
selected,
|
||||||
|
(active.index == index) ? active.element : 0);
|
||||||
|
|
||||||
return refreshStatusIn;
|
return refreshStatusIn;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ public:
|
||||||
virtual int elementsCount() const;
|
virtual int elementsCount() const;
|
||||||
virtual QRect elementGeometry(int element, int outerWidth) const;
|
virtual QRect elementGeometry(int element, int outerWidth) const;
|
||||||
virtual bool elementDisabled(int element) const;
|
virtual bool elementDisabled(int element) const;
|
||||||
|
virtual bool elementOnlySelect(int element) const;
|
||||||
virtual void elementAddRipple(
|
virtual void elementAddRipple(
|
||||||
int element,
|
int element,
|
||||||
QPoint point,
|
QPoint point,
|
||||||
|
|
|
@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/abstract_button.h"
|
#include "ui/abstract_button.h"
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
#include "ui/boxes/edit_invite_link.h"
|
#include "ui/boxes/edit_invite_link.h"
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
|
@ -59,7 +60,7 @@ using LinkData = Api::InviteLink;
|
||||||
|
|
||||||
class RequestedRow final : public PeerListRow {
|
class RequestedRow final : public PeerListRow {
|
||||||
public:
|
public:
|
||||||
explicit RequestedRow(not_null<PeerData*> peer);
|
RequestedRow(not_null<PeerData*> peer, TimeId date);
|
||||||
|
|
||||||
QSize rightActionSize() const override;
|
QSize rightActionSize() const override;
|
||||||
QMargins rightActionMargins() const override;
|
QMargins rightActionMargins() const override;
|
||||||
|
@ -73,8 +74,9 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RequestedRow::RequestedRow(not_null<PeerData*> peer)
|
RequestedRow::RequestedRow(not_null<PeerData*> peer, TimeId date)
|
||||||
: PeerListRow(peer) {
|
: PeerListRow(peer) {
|
||||||
|
setCustomStatus(PrepareRequestedRowStatus(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize RequestedRow::rightActionSize() const {
|
QSize RequestedRow::rightActionSize() const {
|
||||||
|
@ -86,7 +88,7 @@ QSize RequestedRow::rightActionSize() const {
|
||||||
QMargins RequestedRow::rightActionMargins() const {
|
QMargins RequestedRow::rightActionMargins() const {
|
||||||
return QMargins(
|
return QMargins(
|
||||||
0,
|
0,
|
||||||
(st::inviteLinkList.item.height - rightActionSize().height()) / 2,
|
(st::peerListBoxItem.height - rightActionSize().height()) / 2,
|
||||||
st::inviteLinkThreeDotsSkip,
|
st::inviteLinkThreeDotsSkip,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
@ -696,7 +698,7 @@ void Controller::appendSlice(const Api::JoinedByLinkSlice &slice) {
|
||||||
for (const auto &user : slice.users) {
|
for (const auto &user : slice.users) {
|
||||||
_lastUser = user;
|
_lastUser = user;
|
||||||
delegate()->peerListAppendRow((_role == Role::Requested)
|
delegate()->peerListAppendRow((_role == Role::Requested)
|
||||||
? std::make_unique<RequestedRow>(user.user)
|
? std::make_unique<RequestedRow>(user.user, user.date)
|
||||||
: std::make_unique<PeerListRow>(user.user));
|
: std::make_unique<PeerListRow>(user.user));
|
||||||
}
|
}
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
|
@ -764,6 +766,17 @@ void Controller::processRequest(
|
||||||
delegate()->peerListRemoveRow(row);
|
delegate()->peerListRemoveRow(row);
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
}
|
}
|
||||||
|
if (approved) {
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.text = (_peer->isBroadcast()
|
||||||
|
? tr::lng_group_requests_was_added_channel
|
||||||
|
: tr::lng_group_requests_was_added)(
|
||||||
|
tr::now,
|
||||||
|
lt_user,
|
||||||
|
Ui::Text::Bold(user->name),
|
||||||
|
Ui::Text::WithEntities)
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const auto fail = crl::guard(this, [=] {
|
const auto fail = crl::guard(this, [=] {
|
||||||
_processed.fire({ user, false });
|
_processed.fire({ user, false });
|
||||||
|
@ -1288,3 +1301,26 @@ void ShowInviteLinkBox(
|
||||||
std::move(initBox)),
|
std::move(initBox)),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PrepareRequestedRowStatus(TimeId date) {
|
||||||
|
const auto now = QDateTime::currentDateTime();
|
||||||
|
const auto parsed = base::unixtime::parse(date);
|
||||||
|
const auto parsedDate = parsed.date();
|
||||||
|
const auto time = parsed.time().toString(cTimeFormat());
|
||||||
|
const auto dateGeneric = [&] {
|
||||||
|
return tr::lng_mediaview_date_time(
|
||||||
|
tr::now,
|
||||||
|
lt_date,
|
||||||
|
langDayOfMonth(parsedDate),
|
||||||
|
lt_time,
|
||||||
|
time);
|
||||||
|
};
|
||||||
|
const auto dateString = (parsedDate.addDays(1) < now.date())
|
||||||
|
? dateGeneric()
|
||||||
|
: (parsedDate.addDays(1) == now.date())
|
||||||
|
? tr::lng_mediaview_yesterday(tr::now, lt_time, time)
|
||||||
|
: (now.date() == parsedDate)
|
||||||
|
? tr::lng_mediaview_today(tr::now, lt_time, time)
|
||||||
|
: dateGeneric();
|
||||||
|
return tr::lng_group_requests_status(tr::now, lt_date, dateString);
|
||||||
|
}
|
||||||
|
|
|
@ -50,3 +50,5 @@ void DeleteLink(
|
||||||
void ShowInviteLinkBox(
|
void ShowInviteLinkBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const Api::InviteLink &link);
|
const Api::InviteLink &link);
|
||||||
|
|
||||||
|
[[nodiscard]] QString PrepareRequestedRowStatus(TimeId date);
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/ripple_animation.h"
|
#include "ui/effects/ripple_animation.h"
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "boxes/peers/edit_participants_box.h" // SubscribeToMigration
|
#include "boxes/peers/edit_participants_box.h" // SubscribeToMigration
|
||||||
|
#include "boxes/peers/edit_peer_invite_link.h" // PrepareRequestedRowStatus
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
|
@ -18,8 +19,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "ui/toasts/common_toasts.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
#include "apiwrap.h"
|
||||||
|
#include "api/api_invite_links.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -58,6 +63,7 @@ public:
|
||||||
int elementsCount() const override;
|
int elementsCount() const override;
|
||||||
QRect elementGeometry(int element, int outerWidth) const override;
|
QRect elementGeometry(int element, int outerWidth) const override;
|
||||||
bool elementDisabled(int element) const override;
|
bool elementDisabled(int element) const override;
|
||||||
|
bool elementOnlySelect(int element) const override;
|
||||||
void elementAddRipple(
|
void elementAddRipple(
|
||||||
int element,
|
int element,
|
||||||
QPoint point,
|
QPoint point,
|
||||||
|
@ -82,27 +88,7 @@ Row::Row(
|
||||||
TimeId date)
|
TimeId date)
|
||||||
: PeerListRow(user)
|
: PeerListRow(user)
|
||||||
, _delegate(delegate) {
|
, _delegate(delegate) {
|
||||||
const auto now = QDateTime::currentDateTime();
|
setCustomStatus(PrepareRequestedRowStatus(date));
|
||||||
const auto parsed = base::unixtime::parse(date);
|
|
||||||
const auto parsedDate = parsed.date();
|
|
||||||
const auto time = parsed.time().toString(cTimeFormat());
|
|
||||||
const auto dateGeneric = [&] {
|
|
||||||
return tr::lng_group_call_starts_date(
|
|
||||||
tr::now,
|
|
||||||
lt_date,
|
|
||||||
langDayOfMonthFull(parsedDate),
|
|
||||||
lt_time,
|
|
||||||
time);
|
|
||||||
};
|
|
||||||
const auto dateString = (now.date().addDays(1) < parsedDate)
|
|
||||||
? dateGeneric()
|
|
||||||
: (now.date().addDays(1) == parsedDate)
|
|
||||||
? tr::lng_group_call_starts_tomorrow(tr::now, lt_time, time)
|
|
||||||
: (now.date() == parsedDate)
|
|
||||||
? time
|
|
||||||
: dateGeneric();
|
|
||||||
setCustomStatus(
|
|
||||||
tr::lng_group_requests_status(tr::now, lt_date, dateString));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Row::elementsCount() const {
|
int Row::elementsCount() const {
|
||||||
|
@ -131,6 +117,10 @@ bool Row::elementDisabled(int element) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Row::elementOnlySelect(int element) const {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Row::elementAddRipple(
|
void Row::elementAddRipple(
|
||||||
int element,
|
int element,
|
||||||
QPoint point,
|
QPoint point,
|
||||||
|
@ -345,8 +335,8 @@ void RequestsBoxController::refreshDescription() {
|
||||||
setDescriptionText((delegate()->peerListFullRowsCount() > 0)
|
setDescriptionText((delegate()->peerListFullRowsCount() > 0)
|
||||||
? QString()
|
? QString()
|
||||||
: _peer->isBroadcast()
|
: _peer->isBroadcast()
|
||||||
? tr::lng_group_removed_list_about(tr::now)
|
? tr::lng_group_requests_none_channel(tr::now)
|
||||||
: tr::lng_channel_removed_list_about(tr::now));
|
: tr::lng_group_requests_none(tr::now));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestsBoxController::rowClicked(not_null<PeerListRow*> row) {
|
void RequestsBoxController::rowClicked(not_null<PeerListRow*> row) {
|
||||||
|
@ -362,7 +352,32 @@ void RequestsBoxController::rowElementClicked(
|
||||||
void RequestsBoxController::processRequest(
|
void RequestsBoxController::processRequest(
|
||||||
not_null<UserData*> user,
|
not_null<UserData*> user,
|
||||||
bool approved) {
|
bool approved) {
|
||||||
|
const auto done = crl::guard(this, [=] {
|
||||||
|
if (const auto row = delegate()->peerListFindRow(user->id.value)) {
|
||||||
|
delegate()->peerListRemoveRow(row);
|
||||||
|
refreshDescription();
|
||||||
|
delegate()->peerListRefreshRows();
|
||||||
|
}
|
||||||
|
if (approved) {
|
||||||
|
Ui::ShowMultilineToast({
|
||||||
|
.text = (_peer->isBroadcast()
|
||||||
|
? tr::lng_group_requests_was_added_channel
|
||||||
|
: tr::lng_group_requests_was_added)(
|
||||||
|
tr::now,
|
||||||
|
lt_user,
|
||||||
|
Ui::Text::Bold(user->name),
|
||||||
|
Ui::Text::WithEntities)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const auto fail = [] {};
|
||||||
|
session().api().inviteLinks().processRequest(
|
||||||
|
_peer,
|
||||||
|
QString(), // link
|
||||||
|
user,
|
||||||
|
approved,
|
||||||
|
done,
|
||||||
|
fail);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestsBoxController::appendRow(
|
void RequestsBoxController::appendRow(
|
||||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "boxes/peer_list_box.h"
|
#include "boxes/peer_list_box.h"
|
||||||
|
#include "base/weak_ptr.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class SessionNavigation;
|
class SessionNavigation;
|
||||||
|
@ -17,7 +18,9 @@ namespace Ui {
|
||||||
class RippleAnimation;
|
class RippleAnimation;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
class RequestsBoxController final : public PeerListController {
|
class RequestsBoxController final
|
||||||
|
: public PeerListController
|
||||||
|
, public base::has_weak_ptr {
|
||||||
public:
|
public:
|
||||||
RequestsBoxController(
|
RequestsBoxController(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
|
Loading…
Add table
Reference in a new issue