mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added all joined channels to list in giveaway box.
This commit is contained in:
parent
9d4e1689fa
commit
135ffb13fd
2 changed files with 45 additions and 1 deletions
|
@ -9,9 +9,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "apiwrap.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_folder.h"
|
||||
#include "data/data_peer.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_user.h"
|
||||
#include "dialogs/dialogs_indexed_list.h"
|
||||
#include "history/history.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
|
@ -156,7 +159,26 @@ MyChannelsListController::MyChannelsListController(
|
|||
std::make_unique<PeerListGlobalSearchController>(&peer->session()))
|
||||
, _peer(peer)
|
||||
, _show(show)
|
||||
, _selected(std::move(selected)) {
|
||||
, _selected(std::move(selected))
|
||||
, _otherChannels(std::make_unique<std::vector<not_null<ChannelData*>>>()) {
|
||||
{
|
||||
const auto addList = [&](not_null<Dialogs::IndexedList*> list) {
|
||||
for (const auto &row : list->all()) {
|
||||
if (const auto history = row->history()) {
|
||||
const auto channel = history->peer->asChannel();
|
||||
if (channel && !channel->isMegagroup()) {
|
||||
_otherChannels->push_back(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
auto &data = _peer->owner();
|
||||
addList(data.chatsList()->indexed());
|
||||
if (const auto folder = data.folderLoaded(Data::Folder::kId)) {
|
||||
addList(folder->chatsList()->indexed());
|
||||
}
|
||||
addList(data.contactsNoChatsList());
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<PeerListRow> MyChannelsListController::createSearchRow(
|
||||
|
@ -175,6 +197,24 @@ std::unique_ptr<PeerListRow> MyChannelsListController::createRestoredRow(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void MyChannelsListController::loadMoreRows() {
|
||||
if (_apiLifetime || !_otherChannels) {
|
||||
return;
|
||||
} else if (_lastAddedIndex >= _otherChannels->size()) {
|
||||
_otherChannels.release();
|
||||
return;
|
||||
}
|
||||
constexpr auto kPerPage = int(40);
|
||||
const auto till = std::min(
|
||||
int(_otherChannels->size()),
|
||||
_lastAddedIndex + kPerPage);
|
||||
while (_lastAddedIndex < till) {
|
||||
delegate()->peerListAppendRow(
|
||||
createRow(_otherChannels->at(_lastAddedIndex++)));
|
||||
}
|
||||
delegate()->peerListRefreshRows();
|
||||
}
|
||||
|
||||
void MyChannelsListController::rowClicked(not_null<PeerListRow*> row) {
|
||||
const auto channel = row->peer()->asChannel();
|
||||
const auto checked = !row->checked();
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
|
||||
class ChannelData;
|
||||
class PeerData;
|
||||
class PeerListRow;
|
||||
|
||||
|
@ -60,6 +61,7 @@ public:
|
|||
Main::Session &session() const override;
|
||||
void prepare() override;
|
||||
void rowClicked(not_null<PeerListRow*> row) override;
|
||||
void loadMoreRows() override;
|
||||
|
||||
std::unique_ptr<PeerListRow> createSearchRow(
|
||||
not_null<PeerData*> peer) override;
|
||||
|
@ -76,6 +78,8 @@ private:
|
|||
Fn<bool(int)> _checkErrorCallback;
|
||||
|
||||
std::vector<not_null<PeerData*>> _selected;
|
||||
std::unique_ptr<std::vector<not_null<ChannelData*>>> _otherChannels;
|
||||
int _lastAddedIndex = 0;
|
||||
|
||||
rpl::lifetime _apiLifetime;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue