2018-02-07 12:40:37 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "info/feed/info_feed_channels_controllers.h"
|
|
|
|
|
|
|
|
#include "data/data_feed.h"
|
|
|
|
#include "data/data_session.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_channel.h"
|
2018-02-07 12:40:37 +00:00
|
|
|
#include "info/info_controller.h"
|
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "history/history.h"
|
2018-02-08 09:20:14 +00:00
|
|
|
#include "window/window_peer_menu.h"
|
2018-02-12 11:10:40 +00:00
|
|
|
#include "ui/widgets/popup_menu.h"
|
2018-02-20 16:56:41 +00:00
|
|
|
#include "ui/toast/toast.h"
|
2018-02-08 09:20:14 +00:00
|
|
|
#include "auth_session.h"
|
2018-02-13 16:11:00 +00:00
|
|
|
#include "mainwidget.h"
|
2018-02-16 15:46:24 +00:00
|
|
|
#include "apiwrap.h"
|
2018-02-08 09:20:14 +00:00
|
|
|
#include "styles/style_widgets.h"
|
|
|
|
#include "styles/style_info.h"
|
|
|
|
#include "styles/style_boxes.h"
|
2018-02-07 12:40:37 +00:00
|
|
|
|
|
|
|
namespace Info {
|
|
|
|
namespace FeedProfile {
|
2018-02-20 16:56:41 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr auto kChannelsInFeedMin = 4;
|
|
|
|
|
|
|
|
} // namespace
|
2018-02-07 12:40:37 +00:00
|
|
|
|
2018-02-08 09:20:14 +00:00
|
|
|
class ChannelsController::Row final : public PeerListRow {
|
|
|
|
public:
|
2018-02-12 11:10:40 +00:00
|
|
|
Row(not_null<History*> history);
|
2018-02-08 09:20:14 +00:00
|
|
|
|
|
|
|
QSize actionSize() const override;
|
|
|
|
QMargins actionMargins() const override;
|
|
|
|
void paintAction(
|
|
|
|
Painter &p,
|
|
|
|
TimeMs ms,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
bool selected,
|
|
|
|
bool actionSelected) override;
|
|
|
|
|
2018-02-12 11:10:40 +00:00
|
|
|
not_null<History*> history() const {
|
|
|
|
return _history;
|
2018-02-08 09:20:14 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 11:10:40 +00:00
|
|
|
private:
|
|
|
|
not_null<History*> _history;
|
|
|
|
|
2018-02-08 09:20:14 +00:00
|
|
|
};
|
|
|
|
|
2018-02-12 11:10:40 +00:00
|
|
|
ChannelsController::Row::Row(not_null<History*> history)
|
|
|
|
: PeerListRow(history->peer)
|
|
|
|
, _history(history) {
|
2018-02-08 09:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QSize ChannelsController::Row::actionSize() const {
|
|
|
|
return QRect(
|
|
|
|
QPoint(),
|
|
|
|
st::smallCloseIcon.size()).marginsAdded(
|
|
|
|
st::infoFeedLeaveIconMargins).size();
|
|
|
|
}
|
|
|
|
|
|
|
|
QMargins ChannelsController::Row::actionMargins() const {
|
|
|
|
return QMargins(
|
|
|
|
0,
|
|
|
|
(st::infoCommonGroupsList.item.height - actionSize().height()) / 2,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelsController::Row::paintAction(
|
|
|
|
Painter &p,
|
|
|
|
TimeMs ms,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
bool selected,
|
|
|
|
bool actionSelected) {
|
|
|
|
if (selected) {
|
|
|
|
x += st::infoFeedLeaveIconMargins.left();
|
|
|
|
y += st::infoFeedLeaveIconMargins.top();
|
|
|
|
(actionSelected
|
|
|
|
? st::smallCloseIconOver
|
|
|
|
: st::smallCloseIcon).paint(p, x, y, outerWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-07 12:40:37 +00:00
|
|
|
ChannelsController::ChannelsController(not_null<Controller*> controller)
|
|
|
|
: PeerListController()
|
|
|
|
, _controller(controller)
|
|
|
|
, _feed(_controller->key().feed()) {
|
2018-02-16 15:46:24 +00:00
|
|
|
if (!_feed->channelsLoaded()) {
|
2018-03-06 17:07:42 +00:00
|
|
|
// Auth().api().requestFeedChannels(_feed); // #feed
|
2018-02-16 15:46:24 +00:00
|
|
|
}
|
2018-02-07 12:40:37 +00:00
|
|
|
_controller->setSearchEnabledByContent(false);
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:10:40 +00:00
|
|
|
auto ChannelsController::createRow(not_null<History*> history)
|
2018-02-08 09:20:14 +00:00
|
|
|
-> std::unique_ptr<Row> {
|
2018-02-12 11:10:40 +00:00
|
|
|
auto result = std::make_unique<Row>(history);
|
2018-02-07 12:40:37 +00:00
|
|
|
result->setCustomStatus(QString());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<PeerListRow> ChannelsController::createRestoredRow(
|
|
|
|
not_null<PeerData*> peer) {
|
2018-02-12 11:10:40 +00:00
|
|
|
return createRow(App::history(peer));
|
2018-02-07 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelsController::prepare() {
|
2018-02-22 17:38:00 +00:00
|
|
|
setSearchNoResultsText(lang(lng_feed_channels_not_found));
|
2018-02-07 12:40:37 +00:00
|
|
|
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
|
|
|
|
delegate()->peerListSetTitle(langFactory(lng_info_feed_channels));
|
|
|
|
|
|
|
|
rebuildRows();
|
|
|
|
using Flag = Data::FeedUpdateFlag;
|
2018-02-08 09:20:14 +00:00
|
|
|
Auth().data().feedUpdated(
|
2018-02-07 12:40:37 +00:00
|
|
|
) | rpl::filter([=](const Data::FeedUpdate &update) {
|
|
|
|
return (update.feed == _feed) && (update.flag == Flag::Channels);
|
|
|
|
}) | rpl::filter([=] {
|
|
|
|
return _feed->channelsLoaded();
|
|
|
|
}) | rpl::start_with_next([=] {
|
|
|
|
rebuildRows();
|
|
|
|
}, lifetime());
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelsController::rebuildRows() {
|
|
|
|
if (!_feed->channelsLoaded()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto &channels = _feed->channels();
|
|
|
|
auto count = delegate()->peerListFullRowsCount();
|
|
|
|
for (auto i = 0; i != count;) {
|
|
|
|
const auto row = delegate()->peerListRowAt(i);
|
|
|
|
const auto peer = row->peer();
|
|
|
|
if (ranges::find_if(channels, [=](not_null<History*> history) {
|
|
|
|
return (history->peer == peer);
|
|
|
|
}) != end(channels)) {
|
|
|
|
++i;
|
|
|
|
} else {
|
|
|
|
delegate()->peerListRemoveRow(row);
|
|
|
|
--count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto history : channels) {
|
2018-02-12 11:10:40 +00:00
|
|
|
if (auto row = createRow(history)) {
|
2018-02-07 12:40:37 +00:00
|
|
|
delegate()->peerListAppendRow(std::move(row));
|
|
|
|
}
|
|
|
|
}
|
2018-02-08 09:20:14 +00:00
|
|
|
delegate()->peerListRefreshRows();
|
2018-02-07 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<PeerListState> ChannelsController::saveState() const {
|
|
|
|
auto result = PeerListController::saveState();
|
|
|
|
auto my = std::make_unique<SavedState>();
|
|
|
|
using Flag = Data::FeedUpdateFlag;
|
2018-02-20 17:53:55 +00:00
|
|
|
|
|
|
|
// Must not capture `this` here, because it dies before my->lifetime.
|
2018-02-07 12:40:37 +00:00
|
|
|
Auth().data().feedUpdated(
|
2018-02-20 17:53:55 +00:00
|
|
|
) | rpl::filter([feed = _feed](const Data::FeedUpdate &update) {
|
|
|
|
return (update.feed == feed) && (update.flag == Flag::Channels);
|
2018-02-07 12:40:37 +00:00
|
|
|
}) | rpl::start_with_next([state = result.get()] {
|
|
|
|
state->controllerState = nullptr;
|
|
|
|
}, my->lifetime);
|
|
|
|
result->controllerState = std::move(my);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelsController::restoreState(
|
|
|
|
std::unique_ptr<PeerListState> state) {
|
|
|
|
PeerListController::restoreState(std::move(state));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChannelsController::rowClicked(not_null<PeerListRow*> row) {
|
|
|
|
_controller->parentController()->showPeerHistory(
|
|
|
|
row->peer(),
|
|
|
|
Window::SectionShow::Way::Forward);
|
|
|
|
}
|
|
|
|
|
2018-02-08 09:20:14 +00:00
|
|
|
void ChannelsController::rowActionClicked(not_null<PeerListRow*> row) {
|
|
|
|
Window::DeleteAndLeaveHandler(row->peer())();
|
|
|
|
}
|
|
|
|
|
2018-02-12 11:10:40 +00:00
|
|
|
base::unique_qptr<Ui::PopupMenu> ChannelsController::rowContextMenu(
|
2018-07-19 14:27:09 +00:00
|
|
|
QWidget *parent,
|
2018-02-12 11:10:40 +00:00
|
|
|
not_null<PeerListRow*> row) {
|
|
|
|
auto my = static_cast<Row*>(row.get());
|
|
|
|
auto channel = my->history()->peer->asChannel();
|
|
|
|
|
2018-07-19 14:27:09 +00:00
|
|
|
auto result = base::make_unique_q<Ui::PopupMenu>(parent);
|
2018-02-12 11:10:40 +00:00
|
|
|
Window::PeerMenuAddMuteAction(channel, [&](
|
|
|
|
const QString &text,
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void()> handler) {
|
2018-02-12 11:10:40 +00:00
|
|
|
return result->addAction(text, handler);
|
|
|
|
});
|
2018-03-06 17:07:42 +00:00
|
|
|
//result->addAction( // #feed
|
|
|
|
// lang(lng_feed_ungroup),
|
|
|
|
// [=] { Window::ToggleChannelGrouping(channel, false); });
|
2018-02-12 11:10:40 +00:00
|
|
|
|
|
|
|
result->addAction(
|
|
|
|
lang(lng_profile_leave_channel),
|
|
|
|
Window::DeleteAndLeaveHandler(channel));
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-02-20 16:56:41 +00:00
|
|
|
void NotificationsController::Start(not_null<Data::Feed*> feed) {
|
2018-02-13 16:11:00 +00:00
|
|
|
const auto initBox = [=](not_null<PeerListBox*> box) {
|
|
|
|
box->addButton(langFactory(lng_settings_save), [=] {
|
|
|
|
const auto count = box->peerListFullRowsCount();
|
|
|
|
for (auto i = 0; i != count; ++i) {
|
|
|
|
const auto row = box->peerListRowAt(i);
|
|
|
|
const auto peer = row->peer();
|
|
|
|
const auto muted = !row->checked();
|
2018-04-09 17:48:29 +00:00
|
|
|
if (muted != Auth().data().notifyIsMuted(peer)) {
|
|
|
|
Auth().data().updateNotifySettings(
|
2018-02-13 16:11:00 +00:00
|
|
|
peer,
|
|
|
|
(muted
|
2018-04-09 17:48:29 +00:00
|
|
|
? Data::NotifySettings::kDefaultMutePeriod
|
|
|
|
: 0));
|
2018-02-13 16:11:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
box->closeBox();
|
|
|
|
});
|
|
|
|
box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); });
|
|
|
|
};
|
|
|
|
Ui::show(Box<PeerListBox>(
|
2018-02-20 16:56:41 +00:00
|
|
|
std::make_unique<NotificationsController>(feed),
|
2018-02-13 16:11:00 +00:00
|
|
|
initBox));
|
|
|
|
}
|
|
|
|
|
2018-02-20 16:56:41 +00:00
|
|
|
NotificationsController::NotificationsController(
|
2018-02-13 16:11:00 +00:00
|
|
|
not_null<Data::Feed*> feed)
|
|
|
|
: _feed(feed) {
|
|
|
|
}
|
|
|
|
|
2018-02-20 16:56:41 +00:00
|
|
|
void NotificationsController::prepare() {
|
2018-02-22 17:38:00 +00:00
|
|
|
setSearchNoResultsText(lang(lng_feed_channels_not_found));
|
2018-02-13 16:11:00 +00:00
|
|
|
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
|
|
|
|
delegate()->peerListSetTitle(langFactory(lng_feed_notifications));
|
|
|
|
|
|
|
|
loadMoreRows();
|
|
|
|
}
|
|
|
|
|
2018-02-20 16:56:41 +00:00
|
|
|
void NotificationsController::loadMoreRows() {
|
2018-02-13 16:11:00 +00:00
|
|
|
if (_preloadRequestId || _allLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
2018-06-26 13:58:29 +00:00
|
|
|
// const auto hash = 0;
|
2018-03-06 17:07:42 +00:00
|
|
|
//_preloadRequestId = request(MTPmessages_GetDialogs( // #feed
|
|
|
|
// MTP_flags(MTPmessages_GetDialogs::Flag::f_feed_id),
|
|
|
|
// MTP_int(_feed->id()),
|
|
|
|
// MTP_int(_preloadOffsetDate),
|
|
|
|
// MTP_int(_preloadOffsetId),
|
|
|
|
// _preloadPeer ? _preloadPeer->input : MTP_inputPeerEmpty(),
|
2018-06-26 13:58:29 +00:00
|
|
|
// MTP_int(Data::Feed::kChannelsLimit),
|
|
|
|
// MTP_int(hash)
|
2018-03-06 17:07:42 +00:00
|
|
|
//)).done([=](const MTPmessages_Dialogs &result) {
|
|
|
|
// applyFeedDialogs(result);
|
|
|
|
// _preloadRequestId = 0;
|
|
|
|
//}).fail([=](const RPCError &error) {
|
|
|
|
// _preloadRequestId = 0;
|
|
|
|
//}).send();
|
2018-02-13 16:11:00 +00:00
|
|
|
}
|
|
|
|
|
2018-02-20 16:56:41 +00:00
|
|
|
void NotificationsController::applyFeedDialogs(
|
2018-02-13 16:11:00 +00:00
|
|
|
const MTPmessages_Dialogs &result) {
|
|
|
|
const auto [dialogsList, messagesList] = [&] {
|
|
|
|
const auto process = [&](const auto &data) {
|
|
|
|
App::feedUsers(data.vusers);
|
|
|
|
App::feedChats(data.vchats);
|
|
|
|
return std::make_tuple(&data.vdialogs.v, &data.vmessages.v);
|
|
|
|
};
|
|
|
|
switch (result.type()) {
|
|
|
|
case mtpc_messages_dialogs:
|
|
|
|
_allLoaded = true;
|
|
|
|
return process(result.c_messages_dialogs());
|
|
|
|
|
|
|
|
case mtpc_messages_dialogsSlice:
|
|
|
|
LOG(("API Error: "
|
|
|
|
"Unexpected dialogsSlice in feed dialogs list."));
|
|
|
|
return process(result.c_messages_dialogsSlice());
|
|
|
|
}
|
2018-02-20 16:56:41 +00:00
|
|
|
Unexpected("Type in NotificationsController::applyFeedDialogs");
|
2018-02-13 16:11:00 +00:00
|
|
|
}();
|
|
|
|
|
|
|
|
App::feedMsgs(*messagesList, NewMessageLast);
|
|
|
|
|
|
|
|
if (dialogsList->empty()) {
|
|
|
|
_allLoaded = true;
|
|
|
|
}
|
|
|
|
auto channels = std::vector<not_null<ChannelData*>>();
|
|
|
|
channels.reserve(dialogsList->size());
|
|
|
|
for (const auto &dialog : *dialogsList) {
|
|
|
|
switch (dialog.type()) {
|
|
|
|
case mtpc_dialog: {
|
|
|
|
if (const auto peerId = peerFromMTP(dialog.c_dialog().vpeer)) {
|
|
|
|
if (peerIsChannel(peerId)) {
|
|
|
|
const auto history = App::history(peerId);
|
|
|
|
const auto channel = history->peer->asChannel();
|
|
|
|
history->applyDialog(dialog.c_dialog());
|
2019-01-16 09:01:38 +00:00
|
|
|
channels.emplace_back(channel);
|
2018-02-13 16:11:00 +00:00
|
|
|
} else {
|
|
|
|
LOG(("API Error: "
|
|
|
|
"Unexpected non-channel in feed dialogs list."));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
2018-03-06 17:07:42 +00:00
|
|
|
//case mtpc_dialogFeed: { // #feed
|
|
|
|
// LOG(("API Error: Unexpected dialogFeed in feed dialogs list."));
|
|
|
|
//} break;
|
2018-02-13 16:11:00 +00:00
|
|
|
default: Unexpected("Type in DialogsInner::dialogsReceived");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!channels.empty()) {
|
|
|
|
auto notMutedChannels = ranges::view::all(
|
|
|
|
channels
|
|
|
|
) | ranges::view::filter([](not_null<ChannelData*> channel) {
|
2018-04-09 17:48:29 +00:00
|
|
|
return !Auth().data().notifyIsMuted(channel);
|
2018-02-13 16:11:00 +00:00
|
|
|
});
|
|
|
|
delegate()->peerListAddSelectedRows(notMutedChannels);
|
|
|
|
for (const auto channel : channels) {
|
|
|
|
delegate()->peerListAppendRow(createRow(channel));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delegate()->peerListRefreshRows();
|
|
|
|
}
|
|
|
|
|
2018-02-20 16:56:41 +00:00
|
|
|
void NotificationsController::rowClicked(not_null<PeerListRow*> row) {
|
|
|
|
delegate()->peerListSetRowChecked(row, !row->checked());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<PeerListRow> NotificationsController::createRow(
|
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
return std::make_unique<PeerListRow>(channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditController::Start(
|
|
|
|
not_null<Data::Feed*> feed,
|
|
|
|
ChannelData *channel) {
|
|
|
|
const auto initBox = [=](not_null<PeerListBox*> box) {
|
|
|
|
box->addButton(langFactory(lng_settings_save), [=] {
|
|
|
|
auto channels = std::vector<not_null<ChannelData*>>();
|
|
|
|
const auto main = App::main();
|
|
|
|
const auto count = box->peerListFullRowsCount();
|
|
|
|
for (auto i = 0; i != count; ++i) {
|
|
|
|
const auto row = box->peerListRowAt(i);
|
|
|
|
if (row->checked()) {
|
|
|
|
channels.push_back(row->peer()->asChannel());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (channels.size() < kChannelsInFeedMin) {
|
|
|
|
Ui::Toast::Show(lng_feed_select_more_channels(
|
|
|
|
lt_count,
|
|
|
|
kChannelsInFeedMin));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
box->closeBox();
|
2018-03-06 17:07:42 +00:00
|
|
|
//Auth().api().setFeedChannels(feed, channels); // #feed
|
2018-02-20 16:56:41 +00:00
|
|
|
});
|
|
|
|
box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); });
|
|
|
|
};
|
|
|
|
Ui::show(Box<PeerListBox>(
|
|
|
|
std::make_unique<EditController>(feed, channel),
|
|
|
|
initBox));
|
|
|
|
}
|
|
|
|
|
|
|
|
EditController::EditController(
|
|
|
|
not_null<Data::Feed*> feed,
|
|
|
|
ChannelData *channel)
|
2018-03-06 17:07:42 +00:00
|
|
|
: _feed(feed) {
|
|
|
|
//, _startWithChannel(channel) { // #feed
|
2018-02-20 16:56:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EditController::prepare() {
|
2018-02-22 17:38:00 +00:00
|
|
|
setSearchNoResultsText(lang(lng_feed_channels_not_found));
|
2018-02-20 16:56:41 +00:00
|
|
|
delegate()->peerListSetSearchMode(PeerListSearchMode::Enabled);
|
2018-02-22 17:38:00 +00:00
|
|
|
delegate()->peerListSetTitle(langFactory(
|
|
|
|
(_feed->channels().size() < kChannelsInFeedMin
|
|
|
|
? lng_feed_create_new
|
|
|
|
: lng_feed_edit_title)));
|
2018-02-20 16:56:41 +00:00
|
|
|
|
|
|
|
loadMoreRows();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditController::loadMoreRows() {
|
|
|
|
if (_preloadRequestId || _allLoaded) {
|
|
|
|
return;
|
|
|
|
}
|
2018-03-06 17:07:42 +00:00
|
|
|
//const auto hash = 0; // #feed
|
|
|
|
//_preloadRequestId = request(MTPchannels_GetFeedSources(
|
|
|
|
// MTP_flags(0),
|
|
|
|
// MTP_int(0),
|
|
|
|
// MTP_int(hash)
|
|
|
|
//)).done([=](const MTPchannels_FeedSources &result) {
|
|
|
|
// applyFeedSources(result);
|
|
|
|
// _preloadRequestId = 0;
|
|
|
|
//}).fail([=](const RPCError &error) {
|
|
|
|
// _preloadRequestId = 0;
|
|
|
|
//}).send();
|
2018-02-20 16:56:41 +00:00
|
|
|
}
|
2018-03-06 17:07:42 +00:00
|
|
|
// #feed
|
|
|
|
//void EditController::applyFeedSources(
|
|
|
|
// const MTPchannels_FeedSources &result) {
|
|
|
|
// auto channels = std::vector<not_null<ChannelData*>>();
|
|
|
|
//
|
|
|
|
// switch (result.type()) {
|
|
|
|
// case mtpc_channels_feedSourcesNotModified:
|
|
|
|
// LOG(("API Error: Unexpected channels.feedSourcesNotModified."));
|
|
|
|
// break;
|
|
|
|
//
|
|
|
|
// case mtpc_channels_feedSources: {
|
|
|
|
// const auto &data = result.c_channels_feedSources();
|
|
|
|
// Auth().api().applyFeedSources(data);
|
|
|
|
//
|
|
|
|
// for (const auto &chat : data.vchats.v) {
|
|
|
|
// if (chat.type() == mtpc_channel) {
|
|
|
|
// channels.push_back(App::channel(chat.c_channel().vid.v));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// } break;
|
|
|
|
//
|
|
|
|
// default: Unexpected("Type in channels.getFeedSources response.");
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// _allLoaded = true;
|
|
|
|
// if (channels.size() < kChannelsInFeedMin) {
|
|
|
|
// setDescriptionText(lng_feed_too_few_channels(
|
|
|
|
// lt_count,
|
|
|
|
// kChannelsInFeedMin));
|
|
|
|
// delegate()->peerListSetSearchMode(PeerListSearchMode::Disabled);
|
|
|
|
// } else {
|
|
|
|
// auto alreadyInFeed = ranges::view::all(
|
|
|
|
// channels
|
|
|
|
// ) | ranges::view::filter([&](not_null<ChannelData*> channel) {
|
|
|
|
// return (channel->feed() == _feed)
|
|
|
|
// || (channel == _startWithChannel);
|
|
|
|
// });
|
|
|
|
// delegate()->peerListAddSelectedRows(alreadyInFeed);
|
|
|
|
// for (const auto channel : channels) {
|
|
|
|
// delegate()->peerListAppendRow(createRow(channel));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// delegate()->peerListRefreshRows();
|
|
|
|
//}
|
2018-02-20 16:56:41 +00:00
|
|
|
|
|
|
|
void EditController::rowClicked(not_null<PeerListRow*> row) {
|
2018-02-13 16:11:00 +00:00
|
|
|
delegate()->peerListSetRowChecked(row, !row->checked());
|
|
|
|
}
|
|
|
|
|
2018-02-20 16:56:41 +00:00
|
|
|
std::unique_ptr<PeerListRow> EditController::createRow(
|
2018-02-13 16:11:00 +00:00
|
|
|
not_null<ChannelData*> channel) {
|
|
|
|
return std::make_unique<PeerListRow>(channel);
|
|
|
|
}
|
|
|
|
|
2018-02-07 12:40:37 +00:00
|
|
|
} // namespace FeedProfile
|
|
|
|
} // namespace Info
|