2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Push recent requests from requests box to the bar.

This commit is contained in:
John Preston
2021-10-14 14:47:23 +04:00
parent 7543351bc9
commit 8618f6d7eb
6 changed files with 118 additions and 57 deletions

View File

@@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peer_list_controllers.h"
#include "boxes/peers/edit_participants_box.h" // SubscribeToMigration
#include "boxes/peers/edit_peer_invite_link.h" // PrepareRequestedRowStatus
#include "history/view/history_view_requests_bar.h" // kRecentRequestsLimit
#include "data/data_peer.h"
#include "data/data_user.h"
#include "data/data_chat.h"
@@ -382,6 +383,7 @@ void RequestsBoxController::processRequest(
Ui::Text::WithEntities)
});
}
pushRecentRequests();
});
const auto fail = [] {};
session().api().inviteLinks().processRequest(
@@ -393,6 +395,24 @@ void RequestsBoxController::processRequest(
fail);
}
void RequestsBoxController::pushRecentRequests() {
const auto count = std::min(
delegate()->peerListFullRowsCount(),
HistoryView::kRecentRequestsLimit);
if (!count) {
return;
}
auto requests = std::vector<not_null<UserData*>>();
requests.reserve(count);
for (auto i = 0; i != count; ++i) {
requests.push_back(delegate()->peerListRowAt(i)->peer()->asUser());
}
session().api().inviteLinks().pushRecentRequests({
.peer = _peer,
.users = std::move(requests),
});
}
void RequestsBoxController::appendRow(
not_null<UserData*> user,
TimeId date) {

View File

@@ -58,6 +58,7 @@ private:
void appendRow(not_null<UserData*> user, TimeId date);
void refreshDescription();
void processRequest(not_null<UserData*> user, bool approved);
void pushRecentRequests();
void subscribeToMigration();
void migrate(not_null<ChatData*> chat, not_null<ChannelData*> channel);