Added all joined channels to list in giveaway box.
This commit is contained in:
parent
9d4e1689fa
commit
135ffb13fd
|
@ -9,9 +9,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_folder.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "dialogs/dialogs_indexed_list.h"
|
||||||
|
#include "history/history.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
@ -156,7 +159,26 @@ MyChannelsListController::MyChannelsListController(
|
||||||
std::make_unique<PeerListGlobalSearchController>(&peer->session()))
|
std::make_unique<PeerListGlobalSearchController>(&peer->session()))
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _show(show)
|
, _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(
|
std::unique_ptr<PeerListRow> MyChannelsListController::createSearchRow(
|
||||||
|
@ -175,6 +197,24 @@ std::unique_ptr<PeerListRow> MyChannelsListController::createRestoredRow(
|
||||||
return nullptr;
|
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) {
|
void MyChannelsListController::rowClicked(not_null<PeerListRow*> row) {
|
||||||
const auto channel = row->peer()->asChannel();
|
const auto channel = row->peer()->asChannel();
|
||||||
const auto checked = !row->checked();
|
const auto checked = !row->checked();
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/peers/edit_participants_box.h"
|
#include "boxes/peers/edit_participants_box.h"
|
||||||
|
|
||||||
|
class ChannelData;
|
||||||
class PeerData;
|
class PeerData;
|
||||||
class PeerListRow;
|
class PeerListRow;
|
||||||
|
|
||||||
|
@ -60,6 +61,7 @@ public:
|
||||||
Main::Session &session() const override;
|
Main::Session &session() const override;
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
void rowClicked(not_null<PeerListRow*> row) override;
|
void rowClicked(not_null<PeerListRow*> row) override;
|
||||||
|
void loadMoreRows() override;
|
||||||
|
|
||||||
std::unique_ptr<PeerListRow> createSearchRow(
|
std::unique_ptr<PeerListRow> createSearchRow(
|
||||||
not_null<PeerData*> peer) override;
|
not_null<PeerData*> peer) override;
|
||||||
|
@ -76,6 +78,8 @@ private:
|
||||||
Fn<bool(int)> _checkErrorCallback;
|
Fn<bool(int)> _checkErrorCallback;
|
||||||
|
|
||||||
std::vector<not_null<PeerData*>> _selected;
|
std::vector<not_null<PeerData*>> _selected;
|
||||||
|
std::unique_ptr<std::vector<not_null<ChannelData*>>> _otherChannels;
|
||||||
|
int _lastAddedIndex = 0;
|
||||||
|
|
||||||
rpl::lifetime _apiLifetime;
|
rpl::lifetime _apiLifetime;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue