Comment out non-folder feed code.

This commit is contained in:
John Preston 2019-04-15 15:54:03 +04:00
parent 905a024aed
commit 9bf8a8108d
57 changed files with 1392 additions and 1459 deletions

View file

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_photo.h" #include "data/data_photo.h"
#include "data/data_web_page.h" #include "data/data_web_page.h"
#include "data/data_poll.h" #include "data/data_poll.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_sparse_ids.h" #include "data/data_sparse_ids.h"
#include "data/data_search_controller.h" #include "data/data_search_controller.h"
@ -32,7 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h" #include "history/history.h"
#include "history/history_message.h" #include "history/history_message.h"
#include "history/history_item_components.h" #include "history/history_item_components.h"
#include "history/feed/history_feed_section.h" //#include "history/feed/history_feed_section.h" // #feed
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "auth_session.h" #include "auth_session.h"
#include "boxes/confirm_box.h" #include "boxes/confirm_box.h"
@ -55,7 +55,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_shared_media.h" #include "storage/storage_shared_media.h"
#include "storage/storage_user_photos.h" #include "storage/storage_user_photos.h"
#include "storage/storage_media_prepare.h" #include "storage/storage_media_prepare.h"
#include "storage/storage_feed_messages.h" //#include "storage/storage_feed_messages.h" // #feed
namespace { namespace {
@ -82,10 +82,10 @@ constexpr auto kUnreadMentionsPreloadIfLess = 5;
constexpr auto kUnreadMentionsFirstRequestLimit = 10; constexpr auto kUnreadMentionsFirstRequestLimit = 10;
constexpr auto kUnreadMentionsNextRequestLimit = 100; constexpr auto kUnreadMentionsNextRequestLimit = 100;
constexpr auto kSharedMediaLimit = 100; constexpr auto kSharedMediaLimit = 100;
constexpr auto kFeedMessagesLimit = 50; //constexpr auto kFeedMessagesLimit = 50; // #feed
constexpr auto kReadFeaturedSetsTimeout = crl::time(1000); constexpr auto kReadFeaturedSetsTimeout = crl::time(1000);
constexpr auto kFileLoaderQueueStopTimeout = crl::time(5000); constexpr auto kFileLoaderQueueStopTimeout = crl::time(5000);
constexpr auto kFeedReadTimeout = crl::time(1000); //constexpr auto kFeedReadTimeout = crl::time(1000); // #feed
constexpr auto kStickersByEmojiInvalidateTimeout = crl::time(60 * 60 * 1000); constexpr auto kStickersByEmojiInvalidateTimeout = crl::time(60 * 60 * 1000);
constexpr auto kNotifySettingSaveTimeout = crl::time(1000); constexpr auto kNotifySettingSaveTimeout = crl::time(1000);
@ -190,7 +190,7 @@ ApiWrap::ApiWrap(not_null<AuthSession*> session)
, _draftsSaveTimer([=] { saveDraftsToCloud(); }) , _draftsSaveTimer([=] { saveDraftsToCloud(); })
, _featuredSetsReadTimer([=] { readFeaturedSets(); }) , _featuredSetsReadTimer([=] { readFeaturedSets(); })
, _fileLoader(std::make_unique<TaskQueue>(kFileLoaderQueueStopTimeout)) , _fileLoader(std::make_unique<TaskQueue>(kFileLoaderQueueStopTimeout))
, _feedReadTimer([=] { readFeeds(); }) //, _feedReadTimer([=] { readFeeds(); }) // #feed
, _proxyPromotionTimer([=] { refreshProxyPromotion(); }) , _proxyPromotionTimer([=] { refreshProxyPromotion(); })
, _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); }) { , _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); }) {
crl::on_main([=] { crl::on_main([=] {
@ -421,8 +421,8 @@ void ApiWrap::savePinnedOrder() {
for (const auto &pinned : ranges::view::reverse(order)) { for (const auto &pinned : ranges::view::reverse(order)) {
if (const auto history = pinned.history()) { if (const auto history = pinned.history()) {
peers.push_back(MTP_inputDialogPeer(history->peer->input)); peers.push_back(MTP_inputDialogPeer(history->peer->input));
} else if (const auto feed = pinned.feed()) { // } else if (const auto feed = pinned.feed()) { // #feed
// peers.push_back(MTP_inputDialogPeerFeed(MTP_int(feed->id()))); // #feed // peers.push_back(MTP_inputDialogPeerFeed(MTP_int(feed->id())));
} }
} }
const auto folderId = 0; const auto folderId = 0;
@ -686,23 +686,23 @@ void ApiWrap::requestContacts() {
}).send(); }).send();
} }
void ApiWrap::requestDialogEntry(not_null<Data::Feed*> feed) { void ApiWrap::requestDialogEntry(not_null<Data::Folder*> folder) {
if (_dialogFeedRequests.contains(feed)) { if (_dialogFolderRequests.contains(folder)) {
return; return;
} }
_dialogFeedRequests.emplace(feed); _dialogFolderRequests.emplace(folder);
//auto peers = QVector<MTPInputDialogPeer>( // #feed auto peers = QVector<MTPInputDialogPeer>(
// 1, 1,
// MTP_inputDialogPeerFeed(MTP_int(feed->id()))); MTP_inputDialogPeerFolder(MTP_int(folder->id())));
//request(MTPmessages_GetPeerDialogs( request(MTPmessages_GetPeerDialogs(
// MTP_vector(std::move(peers)) MTP_vector(std::move(peers))
//)).done([=](const MTPmessages_PeerDialogs &result) { )).done([=](const MTPmessages_PeerDialogs &result) {
// applyPeerDialogs(result); applyPeerDialogs(result);
// _dialogFeedRequests.remove(feed); _dialogFolderRequests.remove(folder);
//}).fail([=](const RPCError &error) { }).fail([=](const RPCError &error) {
// _dialogFeedRequests.remove(feed); _dialogFolderRequests.remove(folder);
//}).send(); }).send();
} }
//void ApiWrap::requestFeedDialogsEntries(not_null<Data::Feed*> feed) { //void ApiWrap::requestFeedDialogsEntries(not_null<Data::Feed*> feed) {
@ -813,63 +813,56 @@ void ApiWrap::applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs) {
_session->data().processChats(data.vchats); _session->data().processChats(data.vchats);
App::feedMsgs(data.vmessages, NewMessageLast); App::feedMsgs(data.vmessages, NewMessageLast);
for (const auto &dialog : data.vdialogs.v) { for (const auto &dialog : data.vdialogs.v) {
switch (dialog.type()) { dialog.match([&](const MTPDdialog &data) {
case mtpc_dialog: { if (const auto peerId = peerFromMTP(data.vpeer)) {
const auto &fields = dialog.c_dialog(); _session->data().history(peerId)->applyDialog(data);
if (const auto peerId = peerFromMTP(fields.vpeer)) {
_session->data().history(peerId)->applyDialog(fields);
} }
} break; }, [&](const MTPDdialogFolder &data) { // #TODO archive
//const auto folder = _session->data().processFolder(data.vfolder);
//case mtpc_dialogFeed: { // #feed //folder->applyDialog(data);
// const auto &fields = dialog.c_dialogFeed(); });
// const auto feed = _session->data().feed(fields.vfeed_id.v);
// feed->applyDialog(fields);
//} break;
}
} }
_session->data().sendHistoryChangeNotifications(); _session->data().sendHistoryChangeNotifications();
} }
// // #feed
void ApiWrap::applyFeedDialogs( //void ApiWrap::applyFeedDialogs(
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
const MTPmessages_Dialogs &dialogs) { // const MTPmessages_Dialogs &dialogs) {
if (dialogs.type() == mtpc_messages_dialogsNotModified) { // if (dialogs.type() == mtpc_messages_dialogsNotModified) {
LOG(("API Error: " // LOG(("API Error: "
"messages.dialogsNotModified in ApiWrap::applyFeedDialogs.")); // "messages.dialogsNotModified in ApiWrap::applyFeedDialogs."));
return; // return;
} // }
// #TODO folders // auto channels = std::vector<not_null<ChannelData*>>();
auto channels = std::vector<not_null<ChannelData*>>(); // dialogs.match([&](const MTPDmessages_dialogsNotModified &) {
dialogs.match([&](const MTPDmessages_dialogsNotModified &) { // Unexpected("Type in ApiWrap::applyFeedDialogs.");
Unexpected("Type in ApiWrap::applyFeedDialogs."); // }, [&](const auto &data) {
}, [&](const auto &data) { // _session->data().processUsers(data.vusers);
_session->data().processUsers(data.vusers); // _session->data().processChats(data.vchats);
_session->data().processChats(data.vchats); // App::feedMsgs(data.vmessages.v, NewMessageLast);
App::feedMsgs(data.vmessages.v, NewMessageLast); // channels.reserve(data.vdialogs.v.size());
channels.reserve(data.vdialogs.v.size()); // for (const auto &dialog : data.vdialogs.v) {
for (const auto &dialog : data.vdialogs.v) { // dialog.match([&](const MTPDdialog &data) {
dialog.match([&](const MTPDdialog &data) { // if (const auto peerId = peerFromMTP(data.vpeer)) {
if (const auto peerId = peerFromMTP(data.vpeer)) { // if (peerIsChannel(peerId)) { // #TODO archive
if (peerIsChannel(peerId)) { // const auto history = _session->data().history(peerId);
const auto history = _session->data().history(peerId); // history->applyDialog(data);
history->applyDialog(dialog.c_dialog()); // channels.emplace_back(history->peer->asChannel());
channels.emplace_back(history->peer->asChannel()); // } else {
} else { // LOG(("API Error: "
LOG(("API Error: " // "Unexpected peer in folder dialogs list."));
"Unexpected peer in folder dialogs list.")); // }
} // }
} // }, [&](const MTPDdialogFolder &data) {
}, [&](const MTPDdialogFolder &data) { // LOG(("API Error: "
LOG(("API Error: " // "Unexpected dialogFolder in folder dialogs list."));
"Unexpected dialogFolder in folder dialogs list.")); // });
}); // }
} // });
}); //
// feed->setChannels(channels);
feed->setChannels(channels); // _session->data().sendHistoryChangeNotifications();
_session->data().sendHistoryChangeNotifications(); //}
}
void ApiWrap::changeDialogUnreadMark( void ApiWrap::changeDialogUnreadMark(
not_null<History*> history, not_null<History*> history,
@ -1539,8 +1532,7 @@ void ApiWrap::applyLastParticipantsList(
channel->mgInfo->creator = user; channel->mgInfo->creator = user;
if (!channel->mgInfo->admins.empty() if (!channel->mgInfo->admins.empty()
&& !channel->mgInfo->admins.contains(userId)) { && !channel->mgInfo->admins.contains(userId)) {
Data::ChannelAdminChanges changes(channel); Data::ChannelAdminChanges(channel).feed(userId, true);
changes.feed(userId, true);
} }
} }
if (!base::contains(channel->mgInfo->lastParticipants, user)) { if (!base::contains(channel->mgInfo->lastParticipants, user)) {
@ -3651,8 +3643,8 @@ void ApiWrap::applyUpdateNoPtsCheck(const MTPUpdate &update) {
void ApiWrap::jumpToDate(Dialogs::Key chat, const QDate &date) { void ApiWrap::jumpToDate(Dialogs::Key chat, const QDate &date) {
if (const auto peer = chat.peer()) { if (const auto peer = chat.peer()) {
jumpToHistoryDate(peer, date); jumpToHistoryDate(peer, date);
} else if (const auto feed = chat.feed()) { //} else if (const auto feed = chat.feed()) { // #feed
jumpToFeedDate(feed, date); // jumpToFeedDate(feed, date);
} }
} }
@ -3746,64 +3738,64 @@ void ApiWrap::jumpToHistoryDate(not_null<PeerData*> peer, const QDate &date) {
jumpToDateInPeer(); jumpToDateInPeer();
} }
} }
// // #feed
template <typename Callback> //template <typename Callback>
void ApiWrap::requestMessageAfterDate( //void ApiWrap::requestMessageAfterDate(
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
const QDate &date, // const QDate &date,
Callback &&callback) { // Callback &&callback) {
const auto offsetId = 0; // const auto offsetId = 0;
const auto offsetDate = static_cast<TimeId>(QDateTime(date).toTime_t()); // const auto offsetDate = static_cast<TimeId>(QDateTime(date).toTime_t());
const auto addOffset = -2; // const auto addOffset = -2;
const auto limit = 1; // const auto limit = 1;
const auto hash = 0; // const auto hash = 0;
//request(MTPchannels_GetFeed( // #feed // request(MTPchannels_GetFeed(
// MTP_flags(MTPchannels_GetFeed::Flag::f_offset_position), // MTP_flags(MTPchannels_GetFeed::Flag::f_offset_position),
// MTP_int(feed->id()), // MTP_int(feed->id()),
// MTP_feedPosition( // MTP_feedPosition(
// MTP_int(offsetDate), // MTP_int(offsetDate),
// MTP_peerUser(MTP_int(_session->userId())), // MTP_peerUser(MTP_int(_session->userId())),
// MTP_int(0)), // MTP_int(0)),
// MTP_int(addOffset), // MTP_int(addOffset),
// MTP_int(limit), // MTP_int(limit),
// MTPfeedPosition(), // max_id // MTPfeedPosition(), // max_id
// MTPfeedPosition(), // min_id // MTPfeedPosition(), // min_id
// MTP_int(hash) // MTP_int(hash)
//)).done([ // )).done([
// =, // =,
// callback = std::forward<Callback>(callback) // callback = std::forward<Callback>(callback)
//](const MTPmessages_FeedMessages &result) { // ](const MTPmessages_FeedMessages &result) {
// if (result.type() == mtpc_messages_feedMessagesNotModified) { // if (result.type() == mtpc_messages_feedMessagesNotModified) {
// LOG(("API Error: " // LOG(("API Error: "
// "Unexpected messages.feedMessagesNotModified.")); // "Unexpected messages.feedMessagesNotModified."));
// callback(Data::UnreadMessagePosition); // callback(Data::UnreadMessagePosition);
// return; // return;
// } // }
// Assert(result.type() == mtpc_messages_feedMessages); // Assert(result.type() == mtpc_messages_feedMessages);
// const auto &data = result.c_messages_feedMessages(); // const auto &data = result.c_messages_feedMessages();
// const auto &messages = data.vmessages.v; // const auto &messages = data.vmessages.v;
// const auto type = NewMessageExisting; // const auto type = NewMessageExisting;
// _session->data().processUsers(data.vusers); // _session->data().processUsers(data.vusers);
// _session->data().processChats(data.vchats); // _session->data().processChats(data.vchats);
// for (const auto &msg : messages) { // for (const auto &msg : messages) {
// if (const auto item = _session->data().addNewMessage(msg, type)) { // if (const auto item = _session->data().addNewMessage(msg, type)) {
// if (item->date() >= offsetDate || true) { // if (item->date() >= offsetDate || true) {
// callback(item->position()); // callback(item->position());
// return; // return;
// } // }
// } // }
// } // }
// callback(Data::UnreadMessagePosition); // callback(Data::UnreadMessagePosition);
//}).send(); // }).send();
} //}
//
void ApiWrap::jumpToFeedDate(not_null<Data::Feed*> feed, const QDate &date) { //void ApiWrap::jumpToFeedDate(not_null<Data::Feed*> feed, const QDate &date) {
requestMessageAfterDate(feed, date, [=](Data::MessagePosition result) { // requestMessageAfterDate(feed, date, [=](Data::MessagePosition result) {
Ui::hideLayer(); // Ui::hideLayer();
App::wnd()->controller()->showSection( // App::wnd()->controller()->showSection(
HistoryFeed::Memento(feed, result)); // HistoryFeed::Memento(feed, result));
}); // });
} //}
void ApiWrap::preloadEnoughUnreadMentions(not_null<History*> history) { void ApiWrap::preloadEnoughUnreadMentions(not_null<History*> history) {
auto fullCount = history->getUnreadMentionsCount(); auto fullCount = history->getUnreadMentionsCount();
@ -5849,59 +5841,59 @@ void ApiWrap::readServerHistoryForce(not_null<History*> history) {
sendReadRequest(peer, upTo); sendReadRequest(peer, upTo);
} }
} }
// // #feed
void ApiWrap::readFeed( //void ApiWrap::readFeed(
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
Data::MessagePosition position) { // Data::MessagePosition position) {
const auto already = feed->unreadPosition(); // const auto already = feed->unreadPosition();
if (already && already >= position) { // if (already && already >= position) {
return; // return;
} // }
feed->setUnreadPosition(position); // feed->setUnreadPosition(position);
if (!_feedReadsDelayed.contains(feed)) { // if (!_feedReadsDelayed.contains(feed)) {
if (_feedReadsDelayed.empty()) { // if (_feedReadsDelayed.empty()) {
_feedReadTimer.callOnce(kFeedReadTimeout); // _feedReadTimer.callOnce(kFeedReadTimeout);
} // }
_feedReadsDelayed.emplace(feed, crl::now() + kFeedReadTimeout); // _feedReadsDelayed.emplace(feed, crl::now() + kFeedReadTimeout);
} // }
} //}
//
void ApiWrap::readFeeds() { //void ApiWrap::readFeeds() {
auto delay = kFeedReadTimeout; // auto delay = kFeedReadTimeout;
const auto now = crl::now(); // const auto now = crl::now();
//for (auto i = begin(_feedReadsDelayed); i != end(_feedReadsDelayed);) { // #feed // for (auto i = begin(_feedReadsDelayed); i != end(_feedReadsDelayed);) {
// const auto feed = i->first; // const auto feed = i->first;
// const auto time = i->second; // const auto time = i->second;
// // Clang fails to capture structure-binded feed to lambda :( // // Clang fails to capture structure-binded feed to lambda :(
// //const auto [feed, time] = *i; // //const auto [feed, time] = *i;
// if (time > now) { // if (time > now) {
// accumulate_min(delay, time - now); // accumulate_min(delay, time - now);
// ++i; // ++i;
// } else if (_feedReadRequests.contains(feed)) { // } else if (_feedReadRequests.contains(feed)) {
// ++i; // ++i;
// } else { // } else {
// const auto position = feed->unreadPosition(); // const auto position = feed->unreadPosition();
// const auto requestId = request(MTPchannels_ReadFeed( // const auto requestId = request(MTPchannels_ReadFeed(
// MTP_int(feed->id()), // MTP_int(feed->id()),
// MTP_feedPosition( // MTP_feedPosition(
// MTP_int(position.date), // MTP_int(position.date),
// MTP_peerChannel(MTP_int(position.fullId.channel)), // MTP_peerChannel(MTP_int(position.fullId.channel)),
// MTP_int(position.fullId.msg)) // MTP_int(position.fullId.msg))
// )).done([=](const MTPUpdates &result) { // )).done([=](const MTPUpdates &result) {
// applyUpdates(result); // applyUpdates(result);
// _feedReadRequests.remove(feed); // _feedReadRequests.remove(feed);
// }).fail([=](const RPCError &error) { // }).fail([=](const RPCError &error) {
// _feedReadRequests.remove(feed); // _feedReadRequests.remove(feed);
// }).send(); // }).send();
// _feedReadRequests.emplace(feed, requestId); // _feedReadRequests.emplace(feed, requestId);
//
// i = _feedReadsDelayed.erase(i); // i = _feedReadsDelayed.erase(i);
// } // }
//} // }
//if (!_feedReadsDelayed.empty()) { // if (!_feedReadsDelayed.empty()) {
// _feedReadTimer.callOnce(delay); // _feedReadTimer.callOnce(delay);
//} // }
} //}
void ApiWrap::sendReadRequest(not_null<PeerData*> peer, MsgId upTo) { void ApiWrap::sendReadRequest(not_null<PeerData*> peer, MsgId upTo) {
const auto requestId = [&] { const auto requestId = [&] {

View file

@ -79,8 +79,8 @@ public:
QString exportDirectMessageLink(not_null<HistoryItem*> item); QString exportDirectMessageLink(not_null<HistoryItem*> item);
void requestContacts(); void requestContacts();
void requestDialogEntry(not_null<Data::Feed*> feed); void requestDialogEntry(not_null<Data::Folder*> folder);
//void requestFeedDialogsEntries(not_null<Data::Feed*> feed); //void requestFeedDialogsEntries(not_null<Data::Feed*> feed); // #feed
void requestDialogEntry( void requestDialogEntry(
not_null<History*> history, not_null<History*> history,
Fn<void()> callback = nullptr); Fn<void()> callback = nullptr);
@ -309,9 +309,9 @@ public:
void shareContact(not_null<UserData*> user, const SendOptions &options); void shareContact(not_null<UserData*> user, const SendOptions &options);
void readServerHistory(not_null<History*> history); void readServerHistory(not_null<History*> history);
void readServerHistoryForce(not_null<History*> history); void readServerHistoryForce(not_null<History*> history);
void readFeed( //void readFeed( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
Data::MessagePosition position); // Data::MessagePosition position);
void sendVoiceMessage( void sendVoiceMessage(
QByteArray result, QByteArray result,
@ -462,9 +462,9 @@ private:
QVector<MTPInputMessage> collectMessageIds(const MessageDataRequests &requests); QVector<MTPInputMessage> collectMessageIds(const MessageDataRequests &requests);
MessageDataRequests *messageDataRequests(ChannelData *channel, bool onlyExisting = false); MessageDataRequests *messageDataRequests(ChannelData *channel, bool onlyExisting = false);
void applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs); void applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs);
void applyFeedDialogs( //void applyFeedDialogs( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
const MTPmessages_Dialogs &dialogs); // const MTPmessages_Dialogs &dialogs);
void gotChatFull( void gotChatFull(
not_null<PeerData*> peer, not_null<PeerData*> peer,
@ -522,17 +522,17 @@ private:
const QVector<MTPChannelParticipant> &participants); const QVector<MTPChannelParticipant> &participants);
void jumpToHistoryDate(not_null<PeerData*> peer, const QDate &date); void jumpToHistoryDate(not_null<PeerData*> peer, const QDate &date);
void jumpToFeedDate(not_null<Data::Feed*> feed, const QDate &date); //void jumpToFeedDate(not_null<Data::Feed*> feed, const QDate &date); // #feed
template <typename Callback> template <typename Callback>
void requestMessageAfterDate( void requestMessageAfterDate(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const QDate &date, const QDate &date,
Callback &&callback); Callback &&callback);
template <typename Callback> //template <typename Callback> // #feed
void requestMessageAfterDate( //void requestMessageAfterDate(
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
const QDate &date, // const QDate &date,
Callback &&callback); // Callback &&callback);
void sharedMediaDone( void sharedMediaDone(
not_null<PeerData*> peer, not_null<PeerData*> peer,
@ -601,7 +601,7 @@ private:
uint64 randomId); uint64 randomId);
FileLoadTo fileLoadTaskOptions(const SendOptions &options) const; FileLoadTo fileLoadTaskOptions(const SendOptions &options) const;
void readFeeds(); //void readFeeds(); // #feed
void getProxyPromotionDelayed(TimeId now, TimeId next); void getProxyPromotionDelayed(TimeId now, TimeId next);
void proxyPromotionDone(const MTPhelp_ProxyData &proxy); void proxyPromotionDone(const MTPhelp_ProxyData &proxy);
@ -701,7 +701,7 @@ private:
mtpRequestId _contactsRequestId = 0; mtpRequestId _contactsRequestId = 0;
mtpRequestId _contactsStatusesRequestId = 0; mtpRequestId _contactsStatusesRequestId = 0;
base::flat_set<not_null<Data::Feed*>> _dialogFeedRequests; base::flat_set<not_null<Data::Folder*>> _dialogFolderRequests;
base::flat_map< base::flat_map<
not_null<History*>, not_null<History*>,
std::vector<Fn<void()>>> _dialogRequests; std::vector<Fn<void()>>> _dialogRequests;
@ -720,19 +720,19 @@ private:
base::flat_map<not_null<UserData*>, mtpRequestId> _userPhotosRequests; base::flat_map<not_null<UserData*>, mtpRequestId> _userPhotosRequests;
base::flat_set<not_null<Data::Feed*>> _feedChannelsGetRequests; //base::flat_set<not_null<Data::Feed*>> _feedChannelsGetRequests; // #feed
base::flat_map< //base::flat_map<
not_null<Data::Feed*>, // not_null<Data::Feed*>,
mtpRequestId> _feedChannelsSetRequests; // mtpRequestId> _feedChannelsSetRequests;
base::flat_set<std::tuple< //base::flat_set<std::tuple<
not_null<Data::Feed*>, // not_null<Data::Feed*>,
Data::MessagePosition, // Data::MessagePosition,
SliceType>> _feedMessagesRequests; // SliceType>> _feedMessagesRequests;
base::flat_set<std::tuple< //base::flat_set<std::tuple<
not_null<Data::Feed*>, // not_null<Data::Feed*>,
Data::MessagePosition, // Data::MessagePosition,
SliceType>> _feedMessagesRequestsPending; // SliceType>> _feedMessagesRequestsPending;
mtpRequestId _saveDefaultFeedIdRequest = 0; //mtpRequestId _saveDefaultFeedIdRequest = 0;
rpl::event_stream<SendOptions> _sendActions; rpl::event_stream<SendOptions> _sendActions;
@ -755,9 +755,10 @@ private:
rpl::event_stream<uint64> _stickerSetInstalled; rpl::event_stream<uint64> _stickerSetInstalled;
base::flat_map<not_null<Data::Feed*>, crl::time> _feedReadsDelayed; // #feed
base::flat_map<not_null<Data::Feed*>, mtpRequestId> _feedReadRequests; //base::flat_map<not_null<Data::Feed*>, crl::time> _feedReadsDelayed;
base::Timer _feedReadTimer; //base::flat_map<not_null<Data::Feed*>, mtpRequestId> _feedReadRequests;
//base::Timer _feedReadTimer;
mtpRequestId _proxyPromotionRequestId = 0; mtpRequestId _proxyPromotionRequestId = 0;
std::pair<QString, uint32> _proxyPromotionKey; std::pair<QString, uint32> _proxyPromotionKey;

View file

@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h" #include "data/data_user.h"
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "observer_peer.h" #include "observer_peer.h"
#include "auth_session.h" #include "auth_session.h"
#include "apiwrap.h" #include "apiwrap.h"
@ -306,27 +306,27 @@ void ChannelData::setAvailableMinId(MsgId availableMinId) {
} }
} }
} }
// #TODO archive
void ChannelData::setFeed(not_null<Data::Feed*> feed) { //void ChannelData::setFeed(not_null<Data::Feed*> feed) {
setFeedPointer(feed); // setFeedPointer(feed);
} //}
//
void ChannelData::clearFeed() { //void ChannelData::clearFeed() {
setFeedPointer(nullptr); // setFeedPointer(nullptr);
} //}
//
void ChannelData::setFeedPointer(Data::Feed *feed) { //void ChannelData::setFeedPointer(Data::Feed *feed) {
if (_feed != feed) { // if (_feed != feed) {
const auto was = _feed; // const auto was = _feed;
_feed = feed; // _feed = feed;
if (was) { // if (was) {
was->unregisterOne(this); // was->unregisterOne(this);
} // }
if (_feed) { // if (_feed) {
_feed->registerOne(this); // _feed->registerOne(this);
} // }
} // }
} //}
bool ChannelData::canBanMembers() const { bool ChannelData::canBanMembers() const {
return amCreator() return amCreator()

View file

@ -327,13 +327,6 @@ public:
} }
void setAvailableMinId(MsgId availableMinId); void setAvailableMinId(MsgId availableMinId);
void setFeed(not_null<Data::Feed*> feed);
void clearFeed();
Data::Feed *feed() const {
return _feed;
}
enum class UpdateStatus { enum class UpdateStatus {
Good, Good,
TooOld, TooOld,
@ -365,7 +358,6 @@ public:
private: private:
bool canEditLastAdmin(not_null<UserData*> user) const; bool canEditLastAdmin(not_null<UserData*> user) const;
void setFeedPointer(Data::Feed *feed);
Flags _flags = Flags(MTPDchannel_ClientFlag::f_forbidden | 0); Flags _flags = Flags(MTPDchannel_ClientFlag::f_forbidden | 0);
FullFlags _fullFlags; FullFlags _fullFlags;
@ -387,7 +379,6 @@ private:
QString _unavailableReason; QString _unavailableReason;
QString _inviteLink; QString _inviteLink;
Data::Feed *_feed = nullptr;
rpl::lifetime _lifetime; rpl::lifetime _lifetime;

View file

@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link: For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_channel.h" #include "data/data_channel.h"
@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h" #include "history/history_item.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "storage/storage_facade.h" #include "storage/storage_facade.h"
#include "storage/storage_feed_messages.h" //#include "storage/storage_feed_messages.h" // #feed
#include "auth_session.h" #include "auth_session.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "mainwidget.h" #include "mainwidget.h"
@ -31,7 +31,7 @@ namespace Data {
// data.vid.v)); // data.vid.v));
//} //}
Feed::Feed(not_null<Data::Session*> owner, FeedId id) Folder::Folder(not_null<Data::Session*> owner, FolderId id)
: Entry(this) : Entry(this)
, _id(id) , _id(id)
, _owner(owner) , _owner(owner)
@ -39,19 +39,19 @@ Feed::Feed(not_null<Data::Session*> owner, FeedId id)
indexNameParts(); indexNameParts();
} }
Data::Session &Feed::owner() const { Data::Session &Folder::owner() const {
return *_owner; return *_owner;
} }
AuthSession &Feed::session() const { AuthSession &Folder::session() const {
return _owner->session(); return _owner->session();
} }
FeedId Feed::id() const { FolderId Folder::id() const {
return _id; return _id;
} }
void Feed::indexNameParts() { void Folder::indexNameParts() {
_nameWords.clear(); _nameWords.clear();
_nameFirstLetters.clear(); _nameFirstLetters.clear();
auto toIndexList = QStringList(); auto toIndexList = QStringList();
@ -77,13 +77,13 @@ void Feed::indexNameParts() {
} }
} }
void Feed::registerOne(not_null<ChannelData*> channel) { void Folder::registerOne(not_null<PeerData*> peer) {
const auto history = owner().history(channel); const auto history = owner().history(peer);
if (!base::contains(_channels, history)) { if (!base::contains(_chats, history)) {
const auto invisible = (_channels.size() < 2); const auto invisible = empty(_chats);
_channels.push_back(history); _chats.push_back(history);
session().storage().invalidate( //session().storage().invalidate( // #feed
Storage::FeedMessagesInvalidate(_id)); // Storage::FeedMessagesInvalidate(_id));
if (history->chatListMessageKnown()) { if (history->chatListMessageKnown()) {
if (const auto last = history->chatListMessage()) { if (const auto last = history->chatListMessage()) {
@ -103,30 +103,30 @@ void Feed::registerOne(not_null<ChannelData*> channel) {
if (const auto count = history->unreadCount()) { if (const auto count = history->unreadCount()) {
unreadCountChanged(count, history->mute() ? count : 0); unreadCountChanged(count, history->mute() ? count : 0);
} }
} else if (!_settingChannels) { } else if (!_settingChats) {
session().api().requestDialogEntry(this); session().api().requestDialogEntry(this);
} }
} }
if (invisible && _channels.size() > 1) { if (invisible && !empty(_chats)) {
updateChatListExistence(); updateChatListExistence();
for (const auto history : _channels) { for (const auto history : _chats) {
history->updateChatListExistence(); history->updateChatListExistence();
} }
} else { } else {
history->updateChatListExistence(); history->updateChatListExistence();
} }
_owner->notifyFeedUpdated(this, FeedUpdateFlag::Channels); _owner->notifyFolderUpdated(this, FolderUpdateFlag::List);
} }
} }
void Feed::unregisterOne(not_null<ChannelData*> channel) { void Folder::unregisterOne(not_null<PeerData*> peer) {
const auto history = owner().history(channel); const auto history = owner().history(peer);
const auto i = ranges::remove(_channels, history); const auto i = ranges::remove(_chats, history);
if (i != end(_channels)) { if (i != end(_chats)) {
const auto visible = (_channels.size() > 1); const auto visible = !empty(_chats);
_channels.erase(i, end(_channels)); _chats.erase(i, end(_chats));
session().storage().remove( //session().storage().remove( // #feed
Storage::FeedMessagesRemoveAll(_id, channel->bareId())); // Storage::FeedMessagesRemoveAll(_id, channel->bareId()));
if (chatListMessageKnown()) { if (chatListMessageKnown()) {
if (const auto last = chatListMessage()) { if (const auto last = chatListMessage()) {
@ -144,19 +144,19 @@ void Feed::unregisterOne(not_null<ChannelData*> channel) {
session().api().requestDialogEntry(this); session().api().requestDialogEntry(this);
} }
} }
if (visible && _channels.size() < 2) { if (visible && empty(_chats)) {
updateChatListExistence(); updateChatListExistence();
for (const auto history : _channels) { for (const auto history : _chats) {
history->updateChatListExistence(); history->updateChatListExistence();
} }
} else { } else {
history->updateChatListExistence(); history->updateChatListExistence();
} }
_owner->notifyFeedUpdated(this, FeedUpdateFlag::Channels); _owner->notifyFolderUpdated(this, FolderUpdateFlag::List);
} }
} }
void Feed::updateChatListMessage(not_null<HistoryItem*> item) { void Folder::updateChatListMessage(not_null<HistoryItem*> item) {
if (justUpdateChatListMessage(item)) { if (justUpdateChatListMessage(item)) {
if (_chatListMessage && *_chatListMessage) { if (_chatListMessage && *_chatListMessage) {
setChatListTimeId((*_chatListMessage)->date()); setChatListTimeId((*_chatListMessage)->date());
@ -164,108 +164,108 @@ void Feed::updateChatListMessage(not_null<HistoryItem*> item) {
} }
} }
void Feed::loadUserpic() { void Folder::loadUserpic() {
constexpr auto kPaintUserpicsCount = 4; //constexpr auto kPaintUserpicsCount = 4; // #feed
auto load = kPaintUserpicsCount; //auto load = kPaintUserpicsCount;
for (const auto channel : _channels) { //for (const auto history : _chats) {
channel->peer->loadUserpic(); // history->peer->loadUserpic();
if (!--load) { // if (!--load) {
break; // break;
} // }
} //}
} }
void Feed::paintUserpic( void Folder::paintUserpic(
Painter &p, Painter &p,
int x, int x,
int y, int y,
int size) const { int size) const {
const auto small = (size - st::lineWidth) / 2; //const auto small = (size - st::lineWidth) / 2; // #feed
const auto delta = size - small; //const auto delta = size - small;
auto index = 0; //auto index = 0;
for (const auto channel : _channels) { //for (const auto history : _chats) {
channel->peer->paintUserpic(p, x, y, small); // history->peer->paintUserpic(p, x, y, small);
switch (++index) { // switch (++index) {
case 1: // case 1:
case 3: x += delta; break; // case 3: x += delta; break;
case 2: x -= delta; y += delta; break; // case 2: x -= delta; y += delta; break;
case 4: return; // case 4: return;
} // }
} //}
} }
const std::vector<not_null<History*>> &Feed::channels() const { const std::vector<not_null<History*>> &Folder::chats() const {
return _channels; return _chats;
} }
int32 Feed::channelsHash() const { int32 Folder::chatsHash() const {
const auto ordered = ranges::view::all( const auto ordered = ranges::view::all(
_channels _chats
) | ranges::view::transform([](not_null<History*> history) { ) | ranges::view::transform([](not_null<History*> history) {
return history->peer->bareId(); return history->peer->bareId();
}) | ranges::to_vector | ranges::action::sort; }) | ranges::to_vector | ranges::action::sort;
return Api::CountHash(ordered); return Api::CountHash(ordered);
} }
bool Feed::channelsLoaded() const { bool Folder::chatsLoaded() const {
return _channelsLoaded; return _chatsLoaded;
} }
void Feed::setChannelsLoaded(bool loaded) { void Folder::setChatsLoaded(bool loaded) {
if (_channelsLoaded != loaded) { if (_chatsLoaded != loaded) {
_channelsLoaded = loaded; _chatsLoaded = loaded;
_owner->notifyFeedUpdated(this, FeedUpdateFlag::Channels); _owner->notifyFolderUpdated(this, FolderUpdateFlag::List);
} }
} }
void Feed::setChannels(std::vector<not_null<ChannelData*>> channels) { void Folder::setChats(std::vector<not_null<PeerData*>> chats) {
const auto remove = ranges::view::all( const auto remove = ranges::view::all(
_channels _chats
) | ranges::view::transform([](not_null<History*> history) { ) | ranges::view::transform([](not_null<History*> history) {
return not_null<ChannelData*>(history->peer->asChannel()); return history->peer;
}) | ranges::view::filter([&](not_null<ChannelData*> channel) { }) | ranges::view::filter([&](not_null<PeerData*> peer) {
return !base::contains(channels, channel); return !base::contains(chats, peer);
}) | ranges::to_vector; }) | ranges::to_vector;
const auto add = ranges::view::all( const auto add = ranges::view::all(
channels chats
) | ranges::view::filter([&](not_null<ChannelData*> channel) { ) | ranges::view::filter([&](not_null<PeerData*> peer) {
return ranges::find( return ranges::find(
_channels, _chats,
channel.get(), peer,
[](auto history) { return history->peer->asChannel(); } [](auto history) { return history->peer; }
) == end(_channels); ) == end(_chats);
}) | ranges::view::transform([](ChannelData *channel) { }) | ranges::view::transform([](PeerData *peer) {
return not_null<ChannelData*>(channel); return not_null<PeerData*>(peer);
}) | ranges::to_vector; }) | ranges::to_vector;
changeChannelsList(add, remove); changeChatsList(add, remove);
setChannelsLoaded(true); setChatsLoaded(true);
} }
void Feed::changeChannelsList( void Folder::changeChatsList(
const std::vector<not_null<ChannelData*>> &add, const std::vector<not_null<PeerData*>> &add,
const std::vector<not_null<ChannelData*>> &remove) { const std::vector<not_null<PeerData*>> &remove) {
_settingChannels = true; _settingChats = true;
const auto restore = gsl::finally([&] { _settingChannels = false; }); const auto restore = gsl::finally([&] { _settingChats = false; });
for (const auto channel : remove) { //for (const auto channel : remove) { // #TODO archive
channel->clearFeed(); // channel->clearFeed();
} //}
// We assume the last message was correct before requesting the list. //// We assume the last message was correct before requesting the list.
// So we save it and don't allow channels from the list to change it. //// So we save it and don't allow channels from the list to change it.
// After that we restore it. //// After that we restore it.
const auto oldChatListMessage = base::take(_chatListMessage); const auto oldChatListMessage = base::take(_chatListMessage);
for (const auto channel : add) { //for (const auto channel : add) {
_chatListMessage = std::nullopt; // _chatListMessage = std::nullopt;
channel->setFeed(this); // channel->setFeed(this);
} //}
_chatListMessage = oldChatListMessage; _chatListMessage = oldChatListMessage;
} }
bool Feed::justUpdateChatListMessage(not_null<HistoryItem*> item) { bool Folder::justUpdateChatListMessage(not_null<HistoryItem*> item) {
if (!_chatListMessage) { if (!_chatListMessage) {
return false; return false;
} else if (*_chatListMessage } else if (*_chatListMessage
@ -276,13 +276,13 @@ bool Feed::justUpdateChatListMessage(not_null<HistoryItem*> item) {
return true; return true;
} }
void Feed::messageRemoved(not_null<HistoryItem*> item) { void Folder::messageRemoved(not_null<HistoryItem*> item) {
if (chatListMessage() == item) { if (chatListMessage() == item) {
recountChatListMessage(); recountChatListMessage();
} }
} }
void Feed::historyCleared(not_null<History*> history) { void Folder::historyCleared(not_null<History*> history) {
if (const auto last = chatListMessage()) { if (const auto last = chatListMessage()) {
if (last->history() == history) { if (last->history() == history) {
messageRemoved(last); messageRemoved(last);
@ -290,15 +290,15 @@ void Feed::historyCleared(not_null<History*> history) {
} }
} }
void Feed::requestChatListMessage() { void Folder::requestChatListMessage() {
if (!chatListMessageKnown()) { if (!chatListMessageKnown()) {
session().api().requestDialogEntry(this); session().api().requestDialogEntry(this);
} }
} }
void Feed::recountChatListMessage() { void Folder::recountChatListMessage() {
_chatListMessage = std::nullopt; _chatListMessage = std::nullopt;
for (const auto history : _channels) { for (const auto history : _chats) {
if (!history->chatListMessageKnown()) { if (!history->chatListMessageKnown()) {
requestChatListMessage(); requestChatListMessage();
return; return;
@ -307,9 +307,9 @@ void Feed::recountChatListMessage() {
setChatListMessageFromChannels(); setChatListMessageFromChannels();
} }
void Feed::setChatListMessageFromChannels() { void Folder::setChatListMessageFromChannels() {
_chatListMessage = nullptr; _chatListMessage = nullptr;
for (const auto history : _channels) { for (const auto history : _chats) {
if (const auto last = history->chatListMessage()) { if (const auto last = history->chatListMessage()) {
justUpdateChatListMessage(last); justUpdateChatListMessage(last);
} }
@ -317,27 +317,27 @@ void Feed::setChatListMessageFromChannels() {
updateChatListDate(); updateChatListDate();
} }
void Feed::updateChatListDate() { void Folder::updateChatListDate() {
if (_chatListMessage && *_chatListMessage) { if (_chatListMessage && *_chatListMessage) {
setChatListTimeId((*_chatListMessage)->date()); setChatListTimeId((*_chatListMessage)->date());
} }
} }
int Feed::unreadCount() const { int Folder::unreadCount() const {
return _unreadCount ? *_unreadCount : 0; return _unreadCount ? *_unreadCount : 0;
} }
rpl::producer<int> Feed::unreadCountValue() const { rpl::producer<int> Folder::unreadCountValue() const {
return rpl::single( return rpl::single(
unreadCount() unreadCount()
) | rpl::then(_unreadCountChanges.events()); ) | rpl::then(_unreadCountChanges.events());
} }
bool Feed::unreadCountKnown() const { bool Folder::unreadCountKnown() const {
return !!_unreadCount; return !!_unreadCount;
} }
// #feed // #feed
//void Feed::applyDialog(const MTPDdialogFeed &data) { //void Folder::applyDialog(const MTPDdialogFeed &data) {
// const auto addChannel = [&](ChannelId channelId) { // const auto addChannel = [&](ChannelId channelId) {
// if (const auto channel = owner().channelLoaded(channelId)) { // if (const auto channel = owner().channelLoaded(channelId)) {
// channel->setFeed(this); // channel->setFeed(this);
@ -367,7 +367,7 @@ bool Feed::unreadCountKnown() const {
// } // }
//} //}
void Feed::changedInChatListHook(Dialogs::Mode list, bool added) { void Folder::changedInChatListHook(Dialogs::Mode list, bool added) {
if (list != Dialogs::Mode::All) { if (list != Dialogs::Mode::All) {
return; return;
} }
@ -391,7 +391,7 @@ void Feed::changedInChatListHook(Dialogs::Mode list, bool added) {
} }
template <typename PerformUpdate> template <typename PerformUpdate>
void Feed::updateUnreadCounts(PerformUpdate &&performUpdate) { void Folder::updateUnreadCounts(PerformUpdate &&performUpdate) {
const auto wasUnreadCount = _unreadCount ? *_unreadCount : 0; const auto wasUnreadCount = _unreadCount ? *_unreadCount : 0;
const auto wasUnreadMutedCount = _unreadMutedCount; const auto wasUnreadMutedCount = _unreadMutedCount;
const auto wasFullMuted = (wasUnreadMutedCount > 0) const auto wasFullMuted = (wasUnreadMutedCount > 0)
@ -433,7 +433,7 @@ void Feed::updateUnreadCounts(PerformUpdate &&performUpdate) {
} }
} }
void Feed::setUnreadCounts(int unreadNonMutedCount, int unreadMutedCount) { void Folder::setUnreadCounts(int unreadNonMutedCount, int unreadMutedCount) {
if (unreadCountKnown() if (unreadCountKnown()
&& (*_unreadCount == unreadNonMutedCount + unreadMutedCount) && (*_unreadCount == unreadNonMutedCount + unreadMutedCount)
&& (_unreadMutedCount == unreadMutedCount)) { && (_unreadMutedCount == unreadMutedCount)) {
@ -445,13 +445,13 @@ void Feed::setUnreadCounts(int unreadNonMutedCount, int unreadMutedCount) {
}); });
} }
void Feed::setUnreadPosition(const MessagePosition &position) { void Folder::setUnreadPosition(const MessagePosition &position) {
if (_unreadPosition.current() < position) { if (_unreadPosition.current() < position) {
_unreadPosition = position; _unreadPosition = position;
} }
} }
void Feed::unreadCountChanged(int unreadCountDelta, int mutedCountDelta) { void Folder::unreadCountChanged(int unreadCountDelta, int mutedCountDelta) {
if (!unreadCountKnown()) { if (!unreadCountKnown()) {
return; return;
} }
@ -467,55 +467,55 @@ void Feed::unreadCountChanged(int unreadCountDelta, int mutedCountDelta) {
}); });
} }
MessagePosition Feed::unreadPosition() const { MessagePosition Folder::unreadPosition() const {
return _unreadPosition.current(); return _unreadPosition.current();
} }
rpl::producer<MessagePosition> Feed::unreadPositionChanges() const { rpl::producer<MessagePosition> Folder::unreadPositionChanges() const {
return _unreadPosition.changes(); return _unreadPosition.changes();
} }
bool Feed::toImportant() const { bool Folder::toImportant() const {
return false; // TODO feeds workmode return false; // TODO feeds workmode
} }
bool Feed::useProxyPromotion() const { bool Folder::useProxyPromotion() const {
return false; return false;
} }
bool Feed::shouldBeInChatList() const { bool Folder::shouldBeInChatList() const {
return _channels.size() > 1; return !empty(_chats);
} }
int Feed::chatListUnreadCount() const { int Folder::chatListUnreadCount() const {
return unreadCount(); return unreadCount();
} }
bool Feed::chatListUnreadMark() const { bool Folder::chatListUnreadMark() const {
return false; // #feed unread mark return false; // #feed unread mark
} }
bool Feed::chatListMutedBadge() const { bool Folder::chatListMutedBadge() const {
return _unreadCount ? (*_unreadCount <= _unreadMutedCount) : false; return _unreadCount ? (*_unreadCount <= _unreadMutedCount) : false;
} }
HistoryItem *Feed::chatListMessage() const { HistoryItem *Folder::chatListMessage() const {
return _chatListMessage ? *_chatListMessage : nullptr; return _chatListMessage ? *_chatListMessage : nullptr;
} }
bool Feed::chatListMessageKnown() const { bool Folder::chatListMessageKnown() const {
return _chatListMessage.has_value(); return _chatListMessage.has_value();
} }
const QString &Feed::chatListName() const { const QString &Folder::chatListName() const {
return _name; return _name;
} }
const base::flat_set<QString> &Feed::chatListNameWords() const { const base::flat_set<QString> &Folder::chatListNameWords() const {
return _nameWords; return _nameWords;
} }
const base::flat_set<QChar> &Feed::chatListFirstLetters() const { const base::flat_set<QChar> &Folder::chatListFirstLetters() const {
return _nameFirstLetters; return _nameFirstLetters;
} }

View file

@ -16,35 +16,33 @@ class AuthSession;
namespace Data { namespace Data {
class Session; class Session;
class Feed; class Folder;
enum class FeedUpdateFlag { enum class FolderUpdateFlag {
Channels, List,
ChannelPhoto,
}; };
struct FeedUpdate { struct FolderUpdate {
not_null<Data::Feed*> feed; not_null<Data::Folder*> folder;
FeedUpdateFlag flag; FolderUpdateFlag flag;
}; };
//MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed //MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed
class Feed : public Dialogs::Entry { class Folder : public Dialogs::Entry {
public: public:
static constexpr auto kId = 1; static constexpr auto kId = 1;
static constexpr auto kChannelsLimit = 1000;
Feed(not_null<Data::Session*> owner, FeedId id); Folder(not_null<Data::Session*> owner, FolderId id);
Feed(const Feed &) = delete; Folder(const Folder &) = delete;
Feed &operator=(const Feed &) = delete; Folder &operator=(const Folder &) = delete;
Data::Session &owner() const; Data::Session &owner() const;
AuthSession &session() const; AuthSession &session() const;
FeedId id() const; FolderId id() const;
void registerOne(not_null<ChannelData*> channel); void registerOne(not_null<PeerData*> peer);
void unregisterOne(not_null<ChannelData*> channel); void unregisterOne(not_null<PeerData*> peer);
void updateChatListMessage(not_null<HistoryItem*> item); void updateChatListMessage(not_null<HistoryItem*> item);
void messageRemoved(not_null<HistoryItem*> item); void messageRemoved(not_null<HistoryItem*> item);
@ -84,11 +82,11 @@ public:
int y, int y,
int size) const override; int size) const override;
const std::vector<not_null<History*>> &channels() const; const std::vector<not_null<History*>> &chats() const;
int32 channelsHash() const; int32 chatsHash() const;
bool channelsLoaded() const; bool chatsLoaded() const;
void setChannelsLoaded(bool loaded); void setChatsLoaded(bool loaded);
void setChannels(std::vector<not_null<ChannelData*>> channels); void setChats(std::vector<not_null<PeerData*>> chats);
private: private:
void indexNameParts(); void indexNameParts();
@ -96,18 +94,18 @@ private:
void setChatListMessageFromChannels(); void setChatListMessageFromChannels();
bool justUpdateChatListMessage(not_null<HistoryItem*> item); bool justUpdateChatListMessage(not_null<HistoryItem*> item);
void updateChatListDate(); void updateChatListDate();
void changeChannelsList( void changeChatsList(
const std::vector<not_null<ChannelData*>> &add, const std::vector<not_null<PeerData*>> &add,
const std::vector<not_null<ChannelData*>> &remove); const std::vector<not_null<PeerData*>> &remove);
template <typename PerformUpdate> template <typename PerformUpdate>
void updateUnreadCounts(PerformUpdate &&performUpdate); void updateUnreadCounts(PerformUpdate &&performUpdate);
FeedId _id = 0; FolderId _id = 0;
not_null<Data::Session*> _owner; not_null<Data::Session*> _owner;
std::vector<not_null<History*>> _channels; std::vector<not_null<History*>> _chats;
bool _settingChannels = false; bool _settingChats = false;
bool _channelsLoaded = false; bool _chatsLoaded = false;
QString _name; QString _name;
base::flat_set<QString> _nameWords; base::flat_set<QString> _nameWords;

View file

@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link: For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "data/data_feed_messages.h" #include "data/data_messages.h"
namespace Data { namespace Data {

View file

@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_photo.h" #include "data/data_photo.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "observer_peer.h" #include "observer_peer.h"
@ -356,13 +356,13 @@ void PeerData::setUserpicChecked(
|| _userpicLocation != location) { || _userpicLocation != location) {
setUserpic(photoId, location, userpic); setUserpic(photoId, location, userpic);
Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged); Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged);
if (const auto channel = asChannel()) { //if (const auto channel = asChannel()) { // #feed
if (const auto feed = channel->feed()) { // if (const auto feed = channel->feed()) {
owner().notifyFeedUpdated( // owner().notifyFeedUpdated(
feed, // feed,
Data::FeedUpdateFlag::ChannelPhoto); // Data::FeedUpdateFlag::ChannelPhoto);
} // }
} //}
} }
} }
@ -576,13 +576,6 @@ not_null<const PeerData*> PeerData::migrateToOrMe() const {
return this; return this;
} }
Data::Feed *PeerData::feed() const {
if (const auto channel = asChannel()) {
return channel->feed();
}
return nullptr;
}
const Text &PeerData::dialogName() const { const Text &PeerData::dialogName() const {
return migrateTo() return migrateTo()
? migrateTo()->dialogName() ? migrateTo()->dialogName()

View file

@ -25,7 +25,6 @@ class ChannelData;
namespace Data { namespace Data {
class Feed;
class Session; class Session;
int PeerColorIndex(PeerId peerId); int PeerColorIndex(PeerId peerId);
@ -179,7 +178,6 @@ public:
[[nodiscard]] ChannelData *migrateTo() const; [[nodiscard]] ChannelData *migrateTo() const;
[[nodiscard]] not_null<PeerData*> migrateToOrMe(); [[nodiscard]] not_null<PeerData*> migrateToOrMe();
[[nodiscard]] not_null<const PeerData*> migrateToOrMe() const; [[nodiscard]] not_null<const PeerData*> migrateToOrMe() const;
[[nodiscard]] Data::Feed *feed() const;
void updateFull(); void updateFull();
void updateFullForced(); void updateFullForced();

View file

@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/themes/window_theme.h" #include "window/themes/window_theme.h"
#include "lang/lang_keys.h" // for lang(lng_deleted) in user name. #include "lang/lang_keys.h" // for lang(lng_deleted) in user name.
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_user.h" #include "data/data_user.h"
@ -910,7 +910,7 @@ void Session::setupChannelLeavingViewer() {
return (channel != nullptr) return (channel != nullptr)
&& !(channel->amIn()); && !(channel->amIn());
}) | rpl::start_with_next([=](not_null<ChannelData*> channel) { }) | rpl::start_with_next([=](not_null<ChannelData*> channel) {
channel->clearFeed(); // channel->clearFeed(); // #feed
if (const auto history = historyLoaded(channel->id)) { if (const auto history = historyLoaded(channel->id)) {
history->removeJoinedMessage(); history->removeJoinedMessage();
history->updateChatListExistence(); history->updateChatListExistence();
@ -1206,14 +1206,14 @@ rpl::producer<not_null<UserData*>> Session::megagroupParticipantAdded(
}); });
} }
void Session::notifyFeedUpdated( void Session::notifyFolderUpdated(
not_null<Feed*> feed, not_null<Folder*> folder,
FeedUpdateFlag update) { FolderUpdateFlag update) {
_feedUpdates.fire({ feed, update }); _folderUpdates.fire({ folder, update });
} }
rpl::producer<FeedUpdate> Session::feedUpdated() const { rpl::producer<FolderUpdate> Session::folderUpdated() const {
return _feedUpdates.events(); return _folderUpdates.events();
} }
void Session::notifyStickersUpdated() { void Session::notifyStickersUpdated() {
@ -1277,43 +1277,27 @@ void Session::setPinnedDialog(const Dialogs::Key &key, bool pinned) {
void Session::applyPinnedDialogs(const QVector<MTPDialog> &list) { void Session::applyPinnedDialogs(const QVector<MTPDialog> &list) {
clearPinnedDialogs(); clearPinnedDialogs();
for (auto i = list.size(); i != 0;) { for (auto i = list.size(); i != 0;) {
const auto &dialog = list[--i]; list[--i].match([&](const MTPDdialog &data) {
switch (dialog.type()) { if (const auto peer = peerFromMTP(data.vpeer)) {
case mtpc_dialog: {
const auto &dialogData = dialog.c_dialog();
if (const auto peer = peerFromMTP(dialogData.vpeer)) {
setPinnedDialog(history(peer), true); setPinnedDialog(history(peer), true);
} }
} break; }, [&](const MTPDdialogFolder &data) { // #TODO archive
//setPinnedDialog(processFolder(data.vfolder), true);
//case mtpc_dialogFeed: { // #feed });
// const auto &feedData = dialog.c_dialogFeed();
// const auto feedId = feedData.vfeed_id.v;
// setPinnedDialog(feed(feedId), true);
//} break;
default: Unexpected("Type in ApiWrap::applyDialogsPinned.");
}
} }
} }
void Session::applyPinnedDialogs(const QVector<MTPDialogPeer> &list) { void Session::applyPinnedDialogs(const QVector<MTPDialogPeer> &list) {
clearPinnedDialogs(); clearPinnedDialogs();
for (auto i = list.size(); i != 0;) { for (auto i = list.size(); i != 0;) {
const auto &dialogPeer = list[--i]; list[--i].match([&](const MTPDdialogPeer &data) {
switch (dialogPeer.type()) { if (const auto peerId = peerFromMTP(data.vpeer)) {
case mtpc_dialogPeer: {
const auto &peerData = dialogPeer.c_dialogPeer();
if (const auto peerId = peerFromMTP(peerData.vpeer)) {
setPinnedDialog(history(peerId), true); setPinnedDialog(history(peerId), true);
} }
} break; }, [&](const MTPDdialogPeerFolder &data) { // #TODO archive
//case mtpc_dialogPeerFeed: { // #feed //const auto folderId = data.vfolder_id.v;
// const auto &feedData = dialogPeer.c_dialogPeerFeed(); //setPinnedDialog(folder(folderId), true);
// const auto feedId = feedData.vfeed_id.v; });
// setPinnedDialog(feed(feedId), true);
//} break;
}
} }
} }
@ -2803,32 +2787,32 @@ void Session::unregisterItemView(not_null<ViewElement*> view) {
} }
} }
not_null<Feed*> Session::feed(FeedId id) { not_null<Folder*> Session::folder(FolderId id) {
if (const auto result = feedLoaded(id)) { if (const auto result = folderLoaded(id)) {
return result; return result;
} }
const auto [it, ok] = _feeds.emplace( const auto [it, ok] = _folders.emplace(
id, id,
std::make_unique<Feed>(this, id)); std::make_unique<Folder>(this, id));
return it->second.get(); return it->second.get();
} }
Feed *Session::feedLoaded(FeedId id) { Folder *Session::folderLoaded(FolderId id) {
const auto it = _feeds.find(id); const auto it = _folders.find(id);
return (it == end(_feeds)) ? nullptr : it->second.get(); return (it == end(_folders)) ? nullptr : it->second.get();
}
void Session::setDefaultFeedId(FeedId id) {
_defaultFeedId = id;
}
FeedId Session::defaultFeedId() const {
return _defaultFeedId.current();
}
rpl::producer<FeedId> Session::defaultFeedIdValue() const {
return _defaultFeedId.value();
} }
// // #feed
//void Session::setDefaultFeedId(FeedId id) {
// _defaultFeedId = id;
//}
//
//FeedId Session::defaultFeedId() const {
// return _defaultFeedId.current();
//}
//
//rpl::producer<FeedId> Session::defaultFeedIdValue() const {
// return _defaultFeedId.value();
//}
void Session::requestNotifySettings(not_null<PeerData*> peer) { void Session::requestNotifySettings(not_null<PeerData*> peer) {
if (peer->notifySettingsUnknown()) { if (peer->notifySettingsUnknown()) {

View file

@ -48,9 +48,9 @@ struct SavedCredentials;
namespace Data { namespace Data {
class Feed; class Folder;
enum class FeedUpdateFlag; enum class FolderUpdateFlag;
struct FeedUpdate; struct FolderUpdate;
class WallPaper; class WallPaper;
@ -203,8 +203,8 @@ public:
[[nodiscard]] rpl::producer<not_null<UserData*>> megagroupParticipantAdded( [[nodiscard]] rpl::producer<not_null<UserData*>> megagroupParticipantAdded(
not_null<ChannelData*> channel) const; not_null<ChannelData*> channel) const;
void notifyFeedUpdated(not_null<Feed*> feed, FeedUpdateFlag update); void notifyFolderUpdated(not_null<Folder*> folder, FolderUpdateFlag update);
[[nodiscard]] rpl::producer<FeedUpdate> feedUpdated() const; [[nodiscard]] rpl::producer<FolderUpdate> folderUpdated() const;
void notifyStickersUpdated(); void notifyStickersUpdated();
[[nodiscard]] rpl::producer<> stickersUpdated() const; [[nodiscard]] rpl::producer<> stickersUpdated() const;
@ -500,11 +500,13 @@ public:
void registerItemView(not_null<ViewElement*> view); void registerItemView(not_null<ViewElement*> view);
void unregisterItemView(not_null<ViewElement*> view); void unregisterItemView(not_null<ViewElement*> view);
not_null<Feed*> feed(FeedId id); [[nodiscard]] not_null<Folder*> folder(FolderId id);
Feed *feedLoaded(FeedId id); [[nodiscard]] Folder *folderLoaded(FolderId id);
void setDefaultFeedId(FeedId id); not_null<Folder*> processFolder(const MTPFolder &data);
FeedId defaultFeedId() const; not_null<Folder*> processFolder(const MTPDfolder &data);
rpl::producer<FeedId> defaultFeedIdValue() const; //void setDefaultFeedId(FeedId id); // #feed
//FeedId defaultFeedId() const;
//rpl::producer<FeedId> defaultFeedIdValue() const;
void requestNotifySettings(not_null<PeerData*> peer); void requestNotifySettings(not_null<PeerData*> peer);
void applyNotifySetting( void applyNotifySetting(
@ -644,6 +646,10 @@ private:
PhotoData *photo, PhotoData *photo,
DocumentData *document); DocumentData *document);
void folderApplyFields(
not_null<Folder*> folder,
const MTPDfolder &data);
bool stickersUpdateNeeded(crl::time lastUpdate, crl::time now) const { bool stickersUpdateNeeded(crl::time lastUpdate, crl::time now) const {
constexpr auto kStickersUpdateTimeout = crl::time(3600'000); constexpr auto kStickersUpdateTimeout = crl::time(3600'000);
return (lastUpdate == 0) return (lastUpdate == 0)
@ -708,7 +714,7 @@ private:
rpl::event_stream<not_null<History*>> _historyChanged; rpl::event_stream<not_null<History*>> _historyChanged;
rpl::event_stream<MegagroupParticipant> _megagroupParticipantRemoved; rpl::event_stream<MegagroupParticipant> _megagroupParticipantRemoved;
rpl::event_stream<MegagroupParticipant> _megagroupParticipantAdded; rpl::event_stream<MegagroupParticipant> _megagroupParticipantAdded;
rpl::event_stream<FeedUpdate> _feedUpdates; rpl::event_stream<FolderUpdate> _folderUpdates;
rpl::event_stream<> _stickersUpdated; rpl::event_stream<> _stickersUpdated;
rpl::event_stream<> _savedGifsUpdated; rpl::event_stream<> _savedGifsUpdated;
@ -787,8 +793,8 @@ private:
base::flat_set<not_null<PollData*>> _pollsUpdated; base::flat_set<not_null<PollData*>> _pollsUpdated;
std::deque<Dialogs::Key> _pinnedDialogs; std::deque<Dialogs::Key> _pinnedDialogs;
base::flat_map<FeedId, std::unique_ptr<Feed>> _feeds; base::flat_map<FolderId, std::unique_ptr<Folder>> _folders;
rpl::variable<FeedId> _defaultFeedId = FeedId(); //rpl::variable<FeedId> _defaultFeedId = FeedId(); // #feed
Groups _groups; Groups _groups;
std::unordered_map< std::unordered_map<
not_null<const HistoryItem*>, not_null<const HistoryItem*>,

View file

@ -122,13 +122,13 @@ class BotCommand;
struct BotInfo; struct BotInfo;
namespace Data { namespace Data {
class Feed; class Folder;
} // namespace Data } // namespace Data
using UserId = int32; using UserId = int32;
using ChatId = int32; using ChatId = int32;
using ChannelId = int32; using ChannelId = int32;
using FeedId = int32; using FolderId = int32;
constexpr auto NoChannel = ChannelId(0); constexpr auto NoChannel = ChannelId(0);

View file

@ -151,9 +151,9 @@ dialogsChannelIconActive: icon {{ "dialogs_channel", dialogsChatIconFgActive, po
dialogsBotIcon: icon {{ "dialogs_bot", dialogsChatIconFg, point(1px, 3px) }}; dialogsBotIcon: icon {{ "dialogs_bot", dialogsChatIconFg, point(1px, 3px) }};
dialogsBotIconOver: icon {{ "dialogs_bot", dialogsChatIconFgOver, point(1px, 3px) }}; dialogsBotIconOver: icon {{ "dialogs_bot", dialogsChatIconFgOver, point(1px, 3px) }};
dialogsBotIconActive: icon {{ "dialogs_bot", dialogsChatIconFgActive, point(1px, 3px) }}; dialogsBotIconActive: icon {{ "dialogs_bot", dialogsChatIconFgActive, point(1px, 3px) }};
dialogsFeedIcon: icon {{ "dialogs_feed", dialogsChatIconFg, point(4px, 4px) }}; //dialogsFeedIcon: icon {{ "dialogs_feed", dialogsChatIconFg, point(4px, 4px) }}; // #feed
dialogsFeedIconOver: icon {{ "dialogs_feed", dialogsChatIconFgOver, point(4px, 4px) }}; //dialogsFeedIconOver: icon {{ "dialogs_feed", dialogsChatIconFgOver, point(4px, 4px) }};
dialogsFeedIconActive: icon {{ "dialogs_feed", dialogsChatIconFgActive, point(4px, 4px) }}; //dialogsFeedIconActive: icon {{ "dialogs_feed", dialogsChatIconFgActive, point(4px, 4px) }};
dialogsSendStateSkip: 20px; dialogsSendStateSkip: 20px;
dialogsSendingIcon: icon {{ "dialogs_sending", dialogsSendingIconFg, point(8px, 4px) }}; dialogsSendingIcon: icon {{ "dialogs_sending", dialogsSendingIconFg, point(8px, 4px) }};

View file

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_indexed_list.h" #include "dialogs/dialogs_indexed_list.h"
#include "dialogs/dialogs_layout.h" #include "dialogs/dialogs_layout.h"
#include "dialogs/dialogs_search_from_controllers.h" #include "dialogs/dialogs_search_from_controllers.h"
#include "history/feed/history_feed_section.h" //#include "history/feed/history_feed_section.h" // #feed
#include "history/history.h" #include "history/history.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "core/shortcuts.h" #include "core/shortcuts.h"
@ -18,7 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/text_options.h" #include "ui/text_options.h"
#include "data/data_drafts.h" #include "data/data_drafts.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
@ -108,11 +108,11 @@ DialogsInner::DialogsInner(QWidget *parent, not_null<Window::Controller*> contro
if (history->textCachedFor == item) { if (history->textCachedFor == item) {
history->updateChatListEntry(); history->updateChatListEntry();
} }
if (const auto feed = history->peer->feed()) { //if (const auto folder = history->peer->folder()) { // #TODO archive
if (feed->textCachedFor == item) { // if (folder->textCachedFor == item) {
feed->updateChatListEntry(); // folder->updateChatListEntry();
} // }
} //}
}, lifetime()); }, lifetime());
Auth().data().sendActionAnimationUpdated( Auth().data().sendActionAnimationUpdated(
@ -165,9 +165,9 @@ DialogsInner::DialogsInner(QWidget *parent, not_null<Window::Controller*> contro
} }
} }
})); }));
Auth().data().feedUpdated( Auth().data().folderUpdated(
) | rpl::start_with_next([=](const Data::FeedUpdate &update) { ) | rpl::start_with_next([=](const Data::FolderUpdate &update) {
updateDialogRow({ update.feed, FullMsgId() }); updateDialogRow({ update.folder, FullMsgId() });
}, lifetime()); }, lifetime());
_controller->activeChatEntryValue( _controller->activeChatEntryValue(
@ -629,8 +629,8 @@ void DialogsInner::paintSearchInChat(
} else { } else {
paintSearchInPeer(p, peer, top, fullWidth, _searchInChatText); paintSearchInPeer(p, peer, top, fullWidth, _searchInChatText);
} }
} else if (const auto feed = _searchInChat.feed()) { //} else if (const auto feed = _searchInChat.feed()) { // #feed
paintSearchInFeed(p, feed, top, fullWidth, _searchInChatText); // paintSearchInFeed(p, feed, top, fullWidth, _searchInChatText);
} else { } else {
Unexpected("Empty Dialogs::Key in paintSearchInChat."); Unexpected("Empty Dialogs::Key in paintSearchInChat.");
} }
@ -705,19 +705,19 @@ void DialogsInner::paintSearchInSaved(
paintSearchInFilter(p, paintUserpic, top, fullWidth, nullptr, text); paintSearchInFilter(p, paintUserpic, top, fullWidth, nullptr, text);
} }
void DialogsInner::paintSearchInFeed( //void DialogsInner::paintSearchInFeed( // #feed
Painter &p, // Painter &p,
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
int top, // int top,
int fullWidth, // int fullWidth,
const Text &text) const { // const Text &text) const {
const auto paintUserpic = [&](Painter &p, int x, int y, int size) { // const auto paintUserpic = [&](Painter &p, int x, int y, int size) {
feed->paintUserpicLeft(p, x, y, fullWidth, size); // feed->paintUserpicLeft(p, x, y, fullWidth, size);
}; // };
const auto icon = Dialogs::Layout::FeedTypeIcon(feed, false, false); // const auto icon = Dialogs::Layout::FeedTypeIcon(feed, false, false);
paintSearchInFilter(p, paintUserpic, top, fullWidth, icon, text); // paintSearchInFilter(p, paintUserpic, top, fullWidth, icon, text);
} //}
//
void DialogsInner::activate() { void DialogsInner::activate() {
} }
@ -1600,14 +1600,14 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) {
return _menu->addAction(text, std::move(callback)); return _menu->addAction(text, std::move(callback));
}, },
Window::PeerMenuSource::ChatsList); Window::PeerMenuSource::ChatsList);
} else if (const auto feed = row.key.feed()) { } else if (const auto folder = row.key.folder()) {
Window::FillFeedMenu( //Window::FillFolderMenu( // #TODO archive
_controller, // _controller,
feed, // folder,
[&](const QString &text, Fn<void()> callback) { // [&](const QString &text, Fn<void()> callback) {
return _menu->addAction(text, std::move(callback)); // return _menu->addAction(text, std::move(callback));
}, // },
Window::PeerMenuSource::ChatsList); // Window::PeerMenuSource::ChatsList);
} }
connect(_menu.get(), &QObject::destroyed, [=] { connect(_menu.get(), &QObject::destroyed, [=] {
if (_menuRow.key) { if (_menuRow.key) {
@ -1850,11 +1850,11 @@ void DialogsInner::itemRemoved(not_null<const HistoryItem*> item) {
void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) { void DialogsInner::dialogsReceived(const QVector<MTPDialog> &added) {
for (const auto &dialog : added) { for (const auto &dialog : added) {
switch (dialog.type()) { dialog.match([&](const MTPDdialog &data) {
case mtpc_dialog: applyDialog(dialog.c_dialog()); break; applyDialog(data);
//case mtpc_dialogFeed: applyFeedDialog(dialog.c_dialogFeed()); break; // #feed }, [&](const MTPDdialogFolder &data) {
default: Unexpected("Type in DialogsInner::dialogsReceived"); //applyFolderDialog(data); // #TODO archive
} });
} }
refresh(); refresh();
} }
@ -2241,8 +2241,8 @@ void DialogsInner::refreshSearchInChatLabel() {
return lang(lng_saved_messages); return lang(lng_saved_messages);
} }
return peer->name; return peer->name;
} else if (const auto feed = _searchInChat.feed()) { //} else if (const auto feed = _searchInChat.feed()) { // #feed
return feed->chatListName(); // return feed->chatListName();
} }
return QString(); return QString();
}(); }();
@ -2563,17 +2563,17 @@ DialogsInner::ChosenRow DialogsInner::computeChosenRow() const {
}; };
} else if (base::in_range(_searchedSelected, 0, _searchResults.size())) { } else if (base::in_range(_searchedSelected, 0, _searchResults.size())) {
const auto result = _searchResults[_searchedSelected].get(); const auto result = _searchResults[_searchedSelected].get();
if (const auto feed = result->searchInChat().feed()) { //if (const auto feed = result->searchInChat().feed()) { // #feed
return { // return {
feed, // feed,
result->item()->position() // result->item()->position()
}; // };
} else { //} else {
return { return {
result->item()->history(), result->item()->history(),
result->item()->position() result->item()->position()
}; };
} //}
} }
} }
return ChosenRow(); return ChosenRow();
@ -2599,10 +2599,11 @@ bool DialogsInner::chooseRow() {
(uniqueSearchResults() (uniqueSearchResults()
? ShowAtUnreadMsgId ? ShowAtUnreadMsgId
: chosen.message.fullId.msg)); : chosen.message.fullId.msg));
} else if (const auto feed = chosen.key.feed()) { } else if (const auto folder = chosen.key.folder()) {
_controller->showSection( // #TODO archive
HistoryFeed::Memento(feed, chosen.message), //_controller->showSection(
Window::SectionShow::Way::ClearStack); // HistoryFeed::Memento(feed, chosen.message),
// Window::SectionShow::Way::ClearStack);
} }
if (openSearchResult && !Auth().supportMode()) { if (openSearchResult && !Auth().supportMode()) {
emit clearSearchQuery(); emit clearSearchQuery();

View file

@ -252,12 +252,12 @@ private:
int top, int top,
int fullWidth, int fullWidth,
const Text &text) const; const Text &text) const;
void paintSearchInFeed( //void paintSearchInFeed( // #feed
Painter &p, // Painter &p,
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
int top, // int top,
int fullWidth, // int fullWidth,
const Text &text) const; // const Text &text) const;
template <typename PaintUserpic> template <typename PaintUserpic>
void paintSearchInFilter( void paintSearchInFilter(
Painter &p, Painter &p,

View file

@ -7,15 +7,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "dialogs/dialogs_key.h" #include "dialogs/dialogs_key.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "history/history.h" #include "history/history.h"
namespace Dialogs { namespace Dialogs {
namespace {
using Folder = Data::Folder;
} // namespace
not_null<Entry*> Key::entry() const { not_null<Entry*> Key::entry() const {
if (const auto p = base::get_if<not_null<History*>>(&_value)) { if (const auto p = base::get_if<not_null<History*>>(&_value)) {
return *p; return *p;
} else if (const auto p = base::get_if<not_null<Data::Feed*>>(&_value)) { } else if (const auto p = base::get_if<not_null<Folder*>>(&_value)) {
return *p; return *p;
} }
Unexpected("Empty Dialogs::Key in Key::entry()."); Unexpected("Empty Dialogs::Key in Key::entry().");
@ -28,8 +33,8 @@ History *Key::history() const {
return nullptr; return nullptr;
} }
Data::Feed *Key::feed() const { Folder *Key::folder() const {
if (const auto p = base::get_if<not_null<Data::Feed*>>(&_value)) { if (const auto p = base::get_if<not_null<Folder*>>(&_value)) {
return *p; return *p;
} }
return nullptr; return nullptr;

View file

@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
class History; class History;
namespace Data { namespace Data {
class Feed; class Folder;
} // namespace Data } // namespace Data
namespace Dialogs { namespace Dialogs {
@ -26,9 +26,9 @@ public:
} }
Key(not_null<History*> history) : _value(history) { Key(not_null<History*> history) : _value(history) {
} }
Key(Data::Feed *feed) : _value(feed) { Key(Data::Folder *folder) : _value(folder) {
} }
Key(not_null<Data::Feed*> feed) : _value(feed) { Key(not_null<Data::Folder*> folder) : _value(folder) {
} }
explicit operator bool() const { explicit operator bool() const {
@ -36,7 +36,7 @@ public:
} }
not_null<Entry*> entry() const; not_null<Entry*> entry() const;
History *history() const; History *history() const;
Data::Feed *feed() const; Data::Folder *folder() const;
PeerData *peer() const; PeerData *peer() const;
inline bool operator<(const Key &other) const { inline bool operator<(const Key &other) const {
@ -60,7 +60,7 @@ public:
base::optional_variant< base::optional_variant<
not_null<History*>, not_null<History*>,
not_null<Data::Feed*>> raw() const { not_null<Data::Folder*>> raw() const {
return _value; return _value;
} }
@ -70,7 +70,9 @@ public:
//} //}
private: private:
base::optional_variant<not_null<History*>, not_null<Data::Feed*>> _value; base::optional_variant<
not_null<History*>,
not_null<Data::Folder*>> _value;
}; };

View file

@ -165,7 +165,7 @@ enum class Flag {
OnlyBackground = 0x04, OnlyBackground = 0x04,
SearchResult = 0x08, SearchResult = 0x08,
SavedMessages = 0x10, SavedMessages = 0x10,
FeedSearchResult = 0x20, //FeedSearchResult = 0x20, // #feed
}; };
inline constexpr bool is_flag_type(Flag) { return true; } inline constexpr bool is_flag_type(Flag) { return true; }
@ -257,20 +257,20 @@ void paintRow(
st::msgNameFont->height); st::msgNameFont->height);
const auto promoted = chat.entry()->useProxyPromotion() const auto promoted = chat.entry()->useProxyPromotion()
&& !(flags & (Flag::SearchResult | Flag::FeedSearchResult)); && !(flags & (Flag::SearchResult/* | Flag::FeedSearchResult*/)); // #feed
if (promoted) { if (promoted) {
const auto text = lang(lng_proxy_sponsor); const auto text = lang(lng_proxy_sponsor);
paintRowTopRight(p, text, rectForName, active, selected); paintRowTopRight(p, text, rectForName, active, selected);
} else if (from && !(flags & Flag::FeedSearchResult)) { } else if (from/* && !(flags & Flag::FeedSearchResult)*/) { // #feed
if (const auto chatTypeIcon = ChatTypeIcon(from, active, selected)) { if (const auto chatTypeIcon = ChatTypeIcon(from, active, selected)) {
chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth); chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
} }
} else if (const auto feed = chat.feed()) { //} else if (const auto feed = chat.feed()) { // #feed
if (const auto feedTypeIcon = FeedTypeIcon(feed, active, selected)) { // if (const auto feedTypeIcon = FeedTypeIcon(feed, active, selected)) {
feedTypeIcon->paint(p, rectForName.topLeft(), fullWidth); // feedTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); // rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip);
} // }
} }
auto texttop = st::dialogsPadding.y() auto texttop = st::dialogsPadding.y()
+ st::msgNameFont->height + st::msgNameFont->height
@ -462,14 +462,14 @@ const style::icon *ChatTypeIcon(
return nullptr; return nullptr;
} }
const style::icon *FeedTypeIcon( //const style::icon *FeedTypeIcon( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
bool active, // bool active,
bool selected) { // bool selected) {
return &(active ? st::dialogsFeedIconActive // return &(active ? st::dialogsFeedIconActive
: (selected ? st::dialogsFeedIconOver : st::dialogsFeedIcon)); // : (selected ? st::dialogsFeedIconOver : st::dialogsFeedIcon));
} //}
//
void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st) { void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st) {
Assert(rect.height() == st.size); Assert(rect.height() == st.size);
@ -789,8 +789,8 @@ void RowPainter::paint(
| (selected ? Flag::Selected : Flag(0)) | (selected ? Flag::Selected : Flag(0))
| (onlyBackground ? Flag::OnlyBackground : Flag(0)) | (onlyBackground ? Flag::OnlyBackground : Flag(0))
| Flag::SearchResult | Flag::SearchResult
| (showSavedMessages ? Flag::SavedMessages : Flag(0)) | (showSavedMessages ? Flag::SavedMessages : Flag(0))/* // #feed
| (row->searchInChat().feed() ? Flag::FeedSearchResult : Flag(0)); | (row->searchInChat().feed() ? Flag::FeedSearchResult : Flag(0))*/;
paintRow( paintRow(
p, p,
row, row,

View file

@ -7,10 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#pragma once #pragma once
namespace Data {
class Feed;
} // namespace Data
namespace Dialogs { namespace Dialogs {
class Row; class Row;
@ -22,10 +18,10 @@ const style::icon *ChatTypeIcon(
not_null<PeerData*> peer, not_null<PeerData*> peer,
bool active, bool active,
bool selected); bool selected);
const style::icon *FeedTypeIcon( //const style::icon *FeedTypeIcon( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
bool active, // bool active,
bool selected); // bool selected);
class RowPainter { class RowPainter {
public: public:

View file

@ -55,8 +55,8 @@ public:
History *history() const { History *history() const {
return _id.history(); return _id.history();
} }
Data::Feed *feed() const { Data::Folder *folder() const {
return _id.feed(); return _id.folder();
} }
not_null<Entry*> entry() const { not_null<Entry*> entry() const {
return _id.entry(); return _id.entry();

View file

@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_key.h" #include "dialogs/dialogs_key.h"
#include "dialogs/dialogs_entry.h" #include "dialogs/dialogs_entry.h"
#include "history/history.h" #include "history/history.h"
#include "history/feed/history_feed_section.h" //#include "history/feed/history_feed_section.h" // #feed
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/wrap/fade_wrap.h" #include "ui/wrap/fade_wrap.h"
@ -752,17 +752,17 @@ bool DialogsWidget::onSearchMessages(bool searchCache) {
MTP_int(0)), MTP_int(0)),
rpcDone(&DialogsWidget::searchReceived, DialogsSearchPeerFromStart), rpcDone(&DialogsWidget::searchReceived, DialogsSearchPeerFromStart),
rpcFail(&DialogsWidget::searchFailed, DialogsSearchPeerFromStart)); rpcFail(&DialogsWidget::searchFailed, DialogsSearchPeerFromStart));
} else if (const auto feed = _searchInChat.feed()) { //} else if (const auto feed = _searchInChat.feed()) { // #feed
//_searchRequest = MTP::send( // #feed // _searchRequest = MTP::send(
// MTPchannels_SearchFeed( // MTPchannels_SearchFeed(
// MTP_int(feed->id()), // MTP_int(feed->id()),
// MTP_string(_searchQuery), // MTP_string(_searchQuery),
// MTP_int(0), // MTP_int(0),
// MTP_inputPeerEmpty(), // MTP_inputPeerEmpty(),
// MTP_int(0), // MTP_int(0),
// MTP_int(SearchPerPage)), // MTP_int(SearchPerPage)),
// rpcDone(&DialogsWidget::searchReceived, DialogsSearchFromStart), // rpcDone(&DialogsWidget::searchReceived, DialogsSearchFromStart),
// rpcFail(&DialogsWidget::searchFailed, DialogsSearchFromStart)); // rpcFail(&DialogsWidget::searchFailed, DialogsSearchFromStart));
} else { } else {
_searchRequest = MTP::send( _searchRequest = MTP::send(
MTPmessages_SearchGlobal( MTPmessages_SearchGlobal(
@ -888,19 +888,19 @@ void DialogsWidget::onSearchMore() {
MTP_int(0)), MTP_int(0)),
rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart), rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart),
rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart)); rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart));
} else if (const auto feed = _searchInChat.feed()) { //} else if (const auto feed = _searchInChat.feed()) { // #feed
//_searchRequest = MTP::send( // #feed // _searchRequest = MTP::send(
// MTPchannels_SearchFeed( // MTPchannels_SearchFeed(
// MTP_int(feed->id()), // MTP_int(feed->id()),
// MTP_string(_searchQuery), // MTP_string(_searchQuery),
// MTP_int(offsetDate), // MTP_int(offsetDate),
// offsetPeer // offsetPeer
// ? offsetPeer->input // ? offsetPeer->input
// : MTP_inputPeerEmpty(), // : MTP_inputPeerEmpty(),
// MTP_int(offsetId), // MTP_int(offsetId),
// MTP_int(SearchPerPage)), // MTP_int(SearchPerPage)),
// rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart), // rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart),
// rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart)); // rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart));
} else { } else {
_searchRequest = MTP::send( _searchRequest = MTP::send(
MTPmessages_SearchGlobal( MTPmessages_SearchGlobal(
@ -1599,8 +1599,8 @@ bool DialogsWidget::onCancelSearch() {
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
if (const auto peer = _searchInChat.peer()) { if (const auto peer = _searchInChat.peer()) {
Ui::showPeerHistory(peer, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
} else if (const auto feed = _searchInChat.feed()) { //} else if (const auto feed = _searchInChat.feed()) { // #feed
controller()->showSection(HistoryFeed::Memento(feed)); // controller()->showSection(HistoryFeed::Memento(feed));
} else { } else {
Unexpected("Empty key in onCancelSearch()."); Unexpected("Empty key in onCancelSearch().");
} }
@ -1624,8 +1624,8 @@ void DialogsWidget::onCancelSearchInChat() {
if (Adaptive::OneColumn() && !App::main()->selectingPeer()) { if (Adaptive::OneColumn() && !App::main()->selectingPeer()) {
if (const auto peer = _searchInChat.peer()) { if (const auto peer = _searchInChat.peer()) {
Ui::showPeerHistory(peer, ShowAtUnreadMsgId); Ui::showPeerHistory(peer, ShowAtUnreadMsgId);
} else if (const auto feed = _searchInChat.feed()) { //} else if (const auto feed = _searchInChat.feed()) { // #feed
controller()->showSection(HistoryFeed::Memento(feed)); // controller()->showSection(HistoryFeed::Memento(feed));
} else { } else {
Unexpected("Empty key in onCancelSearchInPeer()."); Unexpected("Empty key in onCancelSearchInPeer().");
} }

View file

@ -1457,6 +1457,7 @@ DialogsInfo ParseDialogsInfo(const MTPmessages_Dialogs &data) {
result.chats.reserve(result.chats.size() + data.vdialogs.v.size()); result.chats.reserve(result.chats.size() + data.vdialogs.v.size());
for (const auto &dialog : data.vdialogs.v) { for (const auto &dialog : data.vdialogs.v) {
if (dialog.type() != mtpc_dialog) { if (dialog.type() != mtpc_dialog) {
LOG(("API Error: Unexpected dialog type in chats export."));
continue; continue;
} }
const auto &fields = dialog.c_dialog(); const auto &fields = dialog.c_dialog();

View file

@ -28,10 +28,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/localstorage.h" #include "storage/localstorage.h"
#include "storage/storage_facade.h" #include "storage/storage_facade.h"
#include "storage/storage_shared_media.h" #include "storage/storage_shared_media.h"
#include "storage/storage_feed_messages.h" //#include "storage/storage_feed_messages.h" // #feed
#include "support/support_helper.h" #include "support/support_helper.h"
#include "data/data_channel_admins.h" #include "data/data_channel_admins.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_photo.h" #include "data/data_photo.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
@ -158,13 +158,13 @@ void History::checkChatListMessageRemoved(not_null<HistoryItem*> item) {
} }
_chatListMessage = std::nullopt; _chatListMessage = std::nullopt;
refreshChatListMessage(); refreshChatListMessage();
if (const auto channel = peer->asChannel()) { //if (const auto channel = peer->asChannel()) { // #feed
if (const auto feed = channel->feed()) { // if (const auto feed = channel->feed()) {
// Must be after history->chatListMessage() is updated. // // Must be after history->chatListMessage() is updated.
// Otherwise feed last message will be this value again. // // Otherwise feed last message will be this value again.
feed->messageRemoved(item); // feed->messageRemoved(item);
} // }
} //}
} }
void History::itemVanished(not_null<HistoryItem*> item) { void History::itemVanished(not_null<HistoryItem*> item) {
@ -1711,12 +1711,12 @@ void History::changeUnreadCount(int delta) {
if (_unreadCount) { if (_unreadCount) {
setUnreadCount(std::max(*_unreadCount + delta, 0)); setUnreadCount(std::max(*_unreadCount + delta, 0));
} }
if (const auto channel = peer->asChannel()) { //if (const auto channel = peer->asChannel()) { // #feed
if (const auto feed = channel->feed()) { // if (const auto feed = channel->feed()) {
const auto mutedCountDelta = mute() ? delta : 0; // const auto mutedCountDelta = mute() ? delta : 0;
feed->unreadCountChanged(delta, mutedCountDelta); // feed->unreadCountChanged(delta, mutedCountDelta);
} // }
} //}
} }
bool History::mute() const { bool History::mute() const {
@ -1729,21 +1729,21 @@ bool History::changeMute(bool newMute) {
} }
_mute = newMute; _mute = newMute;
const auto feed = peer->isChannel() //const auto feed = peer->isChannel() // #feed
? peer->asChannel()->feed() // ? peer->asChannel()->feed()
: nullptr; // : nullptr;
if (feed) { //if (feed) {
if (_unreadCount) { // if (_unreadCount) {
if (*_unreadCount) { // if (*_unreadCount) {
const auto unreadCountDelta = 0; // const auto unreadCountDelta = 0;
const auto mutedCountDelta = _mute ? *_unreadCount : -*_unreadCount; // const auto mutedCountDelta = _mute ? *_unreadCount : -*_unreadCount;
feed->unreadCountChanged(unreadCountDelta, mutedCountDelta); // feed->unreadCountChanged(unreadCountDelta, mutedCountDelta);
} // }
} else { // } else {
session().api().requestDialogEntry(this); // session().api().requestDialogEntry(this);
session().api().requestDialogEntry(feed); // session().api().requestDialogEntry(feed);
} // }
} //}
if (inChatList(Dialogs::Mode::All)) { if (inChatList(Dialogs::Mode::All)) {
if (const auto count = historiesUnreadCount()) { if (const auto count = historiesUnreadCount()) {
_owner->unreadMuteChanged(count, _mute); _owner->unreadMuteChanged(count, _mute);
@ -2135,26 +2135,26 @@ void History::setNotLoadedAtBottom() {
session().storage().invalidate( session().storage().invalidate(
Storage::SharedMediaInvalidateBottom(peer->id)); Storage::SharedMediaInvalidateBottom(peer->id));
if (const auto channel = peer->asChannel()) { //if (const auto channel = peer->asChannel()) { // #feed
if (const auto feed = channel->feed()) { // if (const auto feed = channel->feed()) {
session().storage().invalidate( // session().storage().invalidate(
Storage::FeedMessagesInvalidateBottom( // Storage::FeedMessagesInvalidateBottom(
feed->id())); // feed->id()));
} // }
} //}
} }
void History::clearSharedMedia() { void History::clearSharedMedia() {
session().storage().remove( session().storage().remove(
Storage::SharedMediaRemoveAll(peer->id)); Storage::SharedMediaRemoveAll(peer->id));
if (const auto channel = peer->asChannel()) { //if (const auto channel = peer->asChannel()) { // #feed
if (const auto feed = channel->feed()) { // if (const auto feed = channel->feed()) {
session().storage().remove( // session().storage().remove(
Storage::FeedMessagesRemoveAll( // Storage::FeedMessagesRemoveAll(
feed->id(), // feed->id(),
channel->bareId())); // channel->bareId()));
} // }
} //}
} }
void History::setLastMessage(HistoryItem *item) { void History::setLastMessage(HistoryItem *item) {
@ -2348,15 +2348,15 @@ bool History::lastMessageKnown() const {
void History::updateChatListExistence() { void History::updateChatListExistence() {
Entry::updateChatListExistence(); Entry::updateChatListExistence();
if (const auto channel = peer->asChannel()) { //if (const auto channel = peer->asChannel()) { // #feed
if (!channel->feed()) { // if (!channel->feed()) {
// After ungrouping from a feed we need to load dialog. // // After ungrouping from a feed we need to load dialog.
requestChatListMessage(); // requestChatListMessage();
if (!unreadCountKnown()) { // if (!unreadCountKnown()) {
session().api().requestDialogEntry(this); // session().api().requestDialogEntry(this);
} // }
} // }
} //}
} }
bool History::useProxyPromotion() const { bool History::useProxyPromotion() const {
@ -2376,8 +2376,8 @@ bool History::shouldBeInChatList() const {
} else if (const auto channel = peer->asChannel()) { } else if (const auto channel = peer->asChannel()) {
if (!channel->amIn()) { if (!channel->amIn()) {
return isProxyPromoted(); return isProxyPromoted();
} else if (const auto feed = channel->feed()) { //} else if (const auto feed = channel->feed()) { // #feed
return !feed->needUpdateInChatList(); // return !feed->needUpdateInChatList();
} }
} else if (const auto chat = peer->asChat()) { } else if (const auto chat = peer->asChat()) {
return chat->amIn() return chat->amIn()
@ -2966,10 +2966,10 @@ void History::clear(ClearType type) {
clearLastKeyboard(); clearLastKeyboard();
if (const auto channel = peer->asChannel()) { if (const auto channel = peer->asChannel()) {
channel->clearPinnedMessage(); channel->clearPinnedMessage();
if (const auto feed = channel->feed()) { //if (const auto feed = channel->feed()) { // #feed
// Should be after resetting the _lastMessage. // // Should be after resetting the _lastMessage.
feed->historyCleared(this); // feed->historyCleared(this);
} //}
} }
} }
_owner->notifyHistoryChangeDelayed(this); _owner->notifyHistoryChangeDelayed(this);

View file

@ -23,7 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/file_upload.h" #include "storage/file_upload.h"
#include "storage/storage_facade.h" #include "storage/storage_facade.h"
#include "storage/storage_shared_media.h" #include "storage/storage_shared_media.h"
#include "storage/storage_feed_messages.h" //#include "storage/storage_feed_messages.h" // #feed
#include "auth_session.h" #include "auth_session.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
@ -34,7 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_messages.h" #include "data/data_messages.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_user.h" #include "data/data_user.h"
@ -229,12 +229,12 @@ void HistoryItem::invalidateChatListEntry() {
if (history()->textCachedFor == this) { if (history()->textCachedFor == this) {
history()->textCachedFor = nullptr; history()->textCachedFor = nullptr;
} }
if (const auto feed = history()->peer->feed()) { //if (const auto feed = history()->peer->feed()) { // #TODO archive
if (feed->textCachedFor == this) { // if (feed->textCachedFor == this) {
feed->textCachedFor = nullptr; // feed->textCachedFor = nullptr;
feed->updateChatListEntry(); // feed->updateChatListEntry();
} // }
} //}
} }
void HistoryItem::finishEditionToEmpty() { void HistoryItem::finishEditionToEmpty() {
@ -402,13 +402,13 @@ void HistoryItem::indexAsNewItem() {
types, types,
id)); id));
} }
if (const auto channel = history()->peer->asChannel()) { //if (const auto channel = history()->peer->asChannel()) { // #feed
if (const auto feed = channel->feed()) { // if (const auto feed = channel->feed()) {
_history->session().storage().add(Storage::FeedMessagesAddNew( // _history->session().storage().add(Storage::FeedMessagesAddNew(
feed->id(), // feed->id(),
position())); // position()));
} // }
} //}
} }
} }

View file

@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_message.h" #include "history/history_message.h"
#include "history/history_item_components.h" #include "history/history_item_components.h"
#include "history/view/history_view_service_message.h" #include "history/view/history_view_service_message.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_game.h" #include "data/data_game.h"
@ -722,12 +722,12 @@ void HistoryService::updateDependentText() {
if (history()->textCachedFor == this) { if (history()->textCachedFor == this) {
history()->textCachedFor = nullptr; history()->textCachedFor = nullptr;
} }
if (const auto feed = history()->peer->feed()) { //if (const auto feed = history()->peer->feed()) { // #TODO archive
if (feed->textCachedFor == this) { // if (feed->textCachedFor == this) {
feed->textCachedFor = nullptr; // feed->textCachedFor = nullptr;
feed->updateChatListEntry(); // feed->updateChatListEntry();
} // }
} //}
if (const auto main = App::main()) { if (const auto main = App::main()) {
// #TODO feeds search results // #TODO feeds search results
main->repaintDialogRow({ history(), fullId() }); main->repaintDialogRow({ history(), fullId() });

View file

@ -40,7 +40,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_drag_area.h" #include "history/history_drag_area.h"
#include "history/history_inner_widget.h" #include "history/history_inner_widget.h"
#include "history/history_item_components.h" #include "history/history_item_components.h"
#include "history/feed/history_feed_section.h" //#include "history/feed/history_feed_section.h" // #feed
#include "history/view/history_view_service_message.h" #include "history/view/history_view_service_message.h"
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "profile/profile_block_group_members.h" #include "profile/profile_block_group_members.h"

View file

@ -41,16 +41,16 @@ namespace {
// If we can't cloud-export link for such time we export it locally. // If we can't cloud-export link for such time we export it locally.
constexpr auto kExportLocalTimeout = crl::time(1000); constexpr auto kExportLocalTimeout = crl::time(1000);
void AddToggleGroupingAction( //void AddToggleGroupingAction( // #feed
not_null<Ui::PopupMenu*> menu, // not_null<Ui::PopupMenu*> menu,
not_null<PeerData*> peer) { // not_null<PeerData*> peer) {
if (const auto channel = peer->asChannel()) { // if (const auto channel = peer->asChannel()) {
const auto grouped = (channel->feed() != nullptr); // const auto grouped = (channel->feed() != nullptr);
//menu->addAction( // #feed // menu->addAction( // #feed
// lang(grouped ? lng_feed_ungroup : lng_feed_group), // lang(grouped ? lng_feed_ungroup : lng_feed_group),
// [=] { Window::ToggleChannelGrouping(channel, !grouped); }); // [=] { Window::ToggleChannelGrouping(channel, !grouped); });
} // }
} //}
void SavePhotoToFile(not_null<PhotoData*> photo) { void SavePhotoToFile(not_null<PhotoData*> photo) {
if (photo->isNull() || !photo->loaded()) { if (photo->isNull() || !photo->loaded()) {
@ -469,18 +469,18 @@ base::unique_qptr<Ui::PopupMenu> FillContextMenu(
AddPhotoActions(result, photo); AddPhotoActions(result, photo);
} else if (linkDocument) { } else if (linkDocument) {
AddDocumentActions(result, document, itemId); AddDocumentActions(result, document, itemId);
} else if (linkPeer) { //} else if (linkPeer) { // #feed
const auto peer = linkPeer->peer(); // const auto peer = linkPeer->peer();
if (peer->isChannel() // if (peer->isChannel()
&& peer->asChannel()->feed() != nullptr // && peer->asChannel()->feed() != nullptr
&& (list->delegate()->listContext() == Context::Feed)) { // && (list->delegate()->listContext() == Context::Feed)) {
Window::PeerMenuAddMuteAction(peer, [&]( // Window::PeerMenuAddMuteAction(peer, [&](
const QString &text, // const QString &text,
Fn<void()> handler) { // Fn<void()> handler) {
return result->addAction(text, handler); // return result->addAction(text, handler);
}); // });
AddToggleGroupingAction(result, linkPeer->peer()); // AddToggleGroupingAction(result, linkPeer->peer());
} // }
} else if (!request.overSelection && view && !hasSelection) { } else if (!request.overSelection && view && !hasSelection) {
const auto media = view->media(); const auto media = view->media();
const auto mediaHasTextForCopy = media && media->hasTextForCopy(); const auto mediaHasTextForCopy = media && media->hasTextForCopy();

View file

@ -326,9 +326,10 @@ bool Element::computeIsAttachToPrevious(not_null<Element*> previous) {
const auto prev = previous->data(); const auto prev = previous->data();
const auto possible = !item->serviceMsg() && !prev->serviceMsg() const auto possible = !item->serviceMsg() && !prev->serviceMsg()
&& !item->isEmpty() && !prev->isEmpty() && !item->isEmpty() && !prev->isEmpty()
&& (std::abs(prev->date() - item->date()) < kAttachMessageToPreviousSecondsDelta) && (std::abs(prev->date() - item->date())
&& (_context == Context::Feed < kAttachMessageToPreviousSecondsDelta)
|| (!item->isPost() && !prev->isPost())); && (/*_context == Context::Feed // #feed
|| */(!item->isPost() && !prev->isPost()));
if (possible) { if (possible) {
if (item->history()->peer->isSelf()) { if (item->history()->peer->isSelf()) {
return IsAttachedToPreviousInSavedMessages(prev, item); return IsAttachedToPreviousInSavedMessages(prev, item);

View file

@ -27,7 +27,7 @@ struct TextState;
enum class Context : char { enum class Context : char {
History, History,
Feed, //Feed, // #feed
AdminLog, AdminLog,
ContactPreview ContactPreview
}; };

View file

@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "boxes/peers/edit_participant_box.h" #include "boxes/peers/edit_participant_box.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_document.h" #include "data/data_document.h"
#include "data/data_peer.h" #include "data/data_peer.h"

View file

@ -704,7 +704,7 @@ bool Message::hasFromPhoto() const {
} }
switch (context()) { switch (context()) {
case Context::AdminLog: case Context::AdminLog:
case Context::Feed: //case Context::Feed: // #feed
return true; return true;
case Context::History: { case Context::History: {
const auto item = message(); const auto item = message();
@ -1311,7 +1311,7 @@ HistoryWebPage *Message::logEntryOriginal() const {
bool Message::hasFromName() const { bool Message::hasFromName() const {
switch (context()) { switch (context()) {
case Context::AdminLog: case Context::AdminLog:
case Context::Feed: //case Context::Feed: // #feed
return true; return true;
case Context::History: { case Context::History: {
const auto item = message(); const auto item = message();

View file

@ -376,9 +376,9 @@ QSize Service::performCountOptimalSize() {
} }
bool Service::isHidden() const { bool Service::isHidden() const {
if (context() == Context::Feed) { //if (context() == Context::Feed) { // #feed
return true; // return true;
} //}
return Element::isHidden(); return Element::isHidden();
} }

View file

@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "calls/calls_instance.h" #include "calls/calls_instance.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
@ -219,10 +219,10 @@ void TopBarWidget::showMenu() {
peer, peer,
addAction, addAction,
Window::PeerMenuSource::History); Window::PeerMenuSource::History);
} else if (const auto feed = _activeChat.feed()) { } else if (const auto folder = _activeChat.folder()) {
Window::FillFeedMenu( Window::FillFolderMenu(
_controller, _controller,
feed, folder,
addAction, addAction,
Window::PeerMenuSource::History); Window::PeerMenuSource::History);
} else { } else {
@ -237,13 +237,13 @@ void TopBarWidget::toggleInfoSection() {
&& (Auth().settings().thirdSectionInfoEnabled() && (Auth().settings().thirdSectionInfoEnabled()
|| Auth().settings().tabbedReplacedWithInfo())) { || Auth().settings().tabbedReplacedWithInfo())) {
_controller->closeThirdSection(); _controller->closeThirdSection();
} else if (_activeChat) { } else if (_activeChat.peer()) {
if (_controller->canShowThirdSection()) { if (_controller->canShowThirdSection()) {
Auth().settings().setThirdSectionInfoEnabled(true); Auth().settings().setThirdSectionInfoEnabled(true);
Auth().saveSettingsDelayed(); Auth().saveSettingsDelayed();
if (Adaptive::ThreeColumn()) { if (Adaptive::ThreeColumn()) {
_controller->showSection( _controller->showSection(
Info::Memento::Default(_activeChat), Info::Memento::Default(_activeChat.peer()),
Window::SectionShow().withThirdColumn()); Window::SectionShow().withThirdColumn());
} else { } else {
_controller->resizeForThirdSection(); _controller->resizeForThirdSection();
@ -297,7 +297,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) {
} }
void TopBarWidget::paintTopBar(Painter &p) { void TopBarWidget::paintTopBar(Painter &p) {
if (!_activeChat) { if (!_activeChat.peer()) { // #feed
return; return;
} }
auto nameleft = _leftTaken; auto nameleft = _leftTaken;
@ -308,7 +308,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
auto history = _activeChat.history(); auto history = _activeChat.history();
p.setPen(st::dialogsNameFg); p.setPen(st::dialogsNameFg);
if (const auto feed = _activeChat.feed()) { /*if (const auto feed = _activeChat.feed()) { // #feed
auto text = feed->chatListName(); // TODO feed name emoji auto text = feed->chatListName(); // TODO feed name emoji
auto textWidth = st::historySavedFont->width(text); auto textWidth = st::historySavedFont->width(text);
if (namewidth < textWidth) { if (namewidth < textWidth) {
@ -320,7 +320,7 @@ void TopBarWidget::paintTopBar(Painter &p) {
(height() - st::historySavedFont->height) / 2, (height() - st::historySavedFont->height) / 2,
width(), width(),
text); text);
} else if (_activeChat.peer()->isSelf()) { } else */if (_activeChat.peer()->isSelf()) {
auto text = lang(lng_saved_messages); auto text = lang(lng_saved_messages);
auto textWidth = st::historySavedFont->width(text); auto textWidth = st::historySavedFont->width(text);
if (namewidth < textWidth) { if (namewidth < textWidth) {
@ -411,12 +411,12 @@ void TopBarWidget::mousePressEvent(QMouseEvent *e) {
} }
void TopBarWidget::infoClicked() { void TopBarWidget::infoClicked() {
if (!_activeChat) { if (!_activeChat.peer()) {
return; return;
} else if (const auto feed = _activeChat.feed()) { //} else if (const auto feed = _activeChat.feed()) { // #feed
_controller->showSection(Info::Memento( // _controller->showSection(Info::Memento(
feed, // feed,
Info::Section(Info::Section::Type::Profile))); // Info::Section(Info::Section::Type::Profile)));
} else if (_activeChat.peer()->isSelf()) { } else if (_activeChat.peer()->isSelf()) {
_controller->showSection(Info::Memento( _controller->showSection(Info::Memento(
_activeChat.peer()->id, _activeChat.peer()->id,
@ -458,13 +458,13 @@ void TopBarWidget::refreshInfoButton() {
info->showSavedMessagesOnSelf(true); info->showSavedMessagesOnSelf(true);
_info.destroy(); _info.destroy();
_info = std::move(info); _info = std::move(info);
} else if (const auto feed = _activeChat.feed()) { //} else if (const auto feed = _activeChat.feed()) { // #feed
_info.destroy(); // _info.destroy();
_info = object_ptr<Ui::FeedUserpicButton>( // _info = object_ptr<Ui::FeedUserpicButton>(
this, // this,
_controller, // _controller,
feed, // feed,
st::topBarFeedInfoButton); // st::topBarFeedInfoButton);
} }
if (_info) { if (_info) {
_info->setAttribute(Qt::WA_TransparentForMouseEvents); _info->setAttribute(Qt::WA_TransparentForMouseEvents);

View file

@ -297,25 +297,21 @@ void NotificationsController::applyFeedDialogs(
auto channels = std::vector<not_null<ChannelData*>>(); auto channels = std::vector<not_null<ChannelData*>>();
channels.reserve(dialogsList->size()); channels.reserve(dialogsList->size());
for (const auto &dialog : *dialogsList) { for (const auto &dialog : *dialogsList) {
switch (dialog.type()) { dialog.match([&](const MTPDdialog &data) {
case mtpc_dialog: { if (const auto peerId = peerFromMTP(data.vpeer)) {
if (const auto peerId = peerFromMTP(dialog.c_dialog().vpeer)) { if (peerIsChannel(peerId)) { // #TODO archive
if (peerIsChannel(peerId)) {
const auto history = Auth().data().history(peerId); const auto history = Auth().data().history(peerId);
const auto channel = history->peer->asChannel(); const auto channel = history->peer->asChannel();
history->applyDialog(dialog.c_dialog()); history->applyDialog(data);
channels.emplace_back(channel); channels.emplace_back(channel);
} else { } else {
LOG(("API Error: " LOG(("API Error: "
"Unexpected non-channel in feed dialogs list.")); "Unexpected non-channel in folder dialogs list."));
} }
} }
} break; }, [&](const MTPDdialogFolder &data) {
//case mtpc_dialogFeed: { // #feed LOG(("API Error: Unexpected dialogFolder in folder dialogs list."));
// LOG(("API Error: Unexpected dialogFeed in feed dialogs list.")); });
//} break;
default: Unexpected("Type in DialogsInner::dialogsReceived");
}
} }
if (!channels.empty()) { if (!channels.empty()) {
auto notMutedChannels = ranges::view::all( auto notMutedChannels = ranges::view::all(

View file

@ -262,8 +262,8 @@ void ContentWidget::refreshSearchField(bool shown) {
Key ContentMemento::key() const { Key ContentMemento::key() const {
if (const auto peerId = this->peerId()) { if (const auto peerId = this->peerId()) {
return Key(Auth().data().peer(peerId)); return Key(Auth().data().peer(peerId));
} else if (const auto feed = this->feed()) { //} else if (const auto feed = this->feed()) { // #feed
return Key(feed); // return Key(feed);
} else { } else {
return Settings::Tag{ settingsSelf() }; return Settings::Tag{ settingsSelf() };
} }

View file

@ -23,10 +23,6 @@ template <typename Widget>
class PaddingWrap; class PaddingWrap;
} // namespace Ui } // namespace Ui
namespace Data {
class Feed;
} // namespace Data
namespace Info { namespace Info {
namespace Settings { namespace Settings {
struct Tag; struct Tag;
@ -124,8 +120,8 @@ public:
: _peerId(peerId) : _peerId(peerId)
, _migratedPeerId(migratedPeerId) { , _migratedPeerId(migratedPeerId) {
} }
explicit ContentMemento(not_null<Data::Feed*> feed) : _feed(feed) { //explicit ContentMemento(not_null<Data::Feed*> feed) : _feed(feed) { // #feed
} //}
explicit ContentMemento(Settings::Tag settings); explicit ContentMemento(Settings::Tag settings);
virtual object_ptr<ContentWidget> createWidget( virtual object_ptr<ContentWidget> createWidget(
@ -139,9 +135,9 @@ public:
PeerId migratedPeerId() const { PeerId migratedPeerId() const {
return _migratedPeerId; return _migratedPeerId;
} }
Data::Feed *feed() const { //Data::Feed *feed() const { // #feed
return _feed; // return _feed;
} //}
UserData *settingsSelf() const { UserData *settingsSelf() const {
return _settingsSelf; return _settingsSelf;
} }
@ -179,7 +175,7 @@ public:
private: private:
const PeerId _peerId = 0; const PeerId _peerId = 0;
const PeerId _migratedPeerId = 0; const PeerId _migratedPeerId = 0;
Data::Feed * const _feed = nullptr; //Data::Feed * const _feed = nullptr; // #feed
UserData * const _settingsSelf = nullptr; UserData * const _settingsSelf = nullptr;
int _scrollTop = 0; int _scrollTop = 0;
QString _searchFieldQuery; QString _searchFieldQuery;

View file

@ -40,8 +40,8 @@ not_null<PeerData*> CorrectPeer(PeerId peerId) {
Key::Key(not_null<PeerData*> peer) : _value(peer) { Key::Key(not_null<PeerData*> peer) : _value(peer) {
} }
Key::Key(not_null<Data::Feed*> feed) : _value(feed) { //Key::Key(not_null<Data::Feed*> feed) : _value(feed) { // #feed
} //}
Key::Key(Settings::Tag settings) : _value(settings) { Key::Key(Settings::Tag settings) : _value(settings) {
} }
@ -53,12 +53,12 @@ PeerData *Key::peer() const {
return nullptr; return nullptr;
} }
Data::Feed *Key::feed() const { //Data::Feed *Key::feed() const { // #feed
if (const auto feed = base::get_if<not_null<Data::Feed*>>(&_value)) { // if (const auto feed = base::get_if<not_null<Data::Feed*>>(&_value)) {
return *feed; // return *feed;
} // }
return nullptr; // return nullptr;
} //}
UserData *Key::settingsSelf() const { UserData *Key::settingsSelf() const {
if (const auto tag = base::get_if<Settings::Tag>(&_value)) { if (const auto tag = base::get_if<Settings::Tag>(&_value)) {
@ -167,7 +167,7 @@ bool Controller::validateMementoPeer(
not_null<ContentMemento*> memento) const { not_null<ContentMemento*> memento) const {
return memento->peerId() == peerId() return memento->peerId() == peerId()
&& memento->migratedPeerId() == migratedPeerId() && memento->migratedPeerId() == migratedPeerId()
&& memento->feed() == feed() //&& memento->feed() == feed() // #feed
&& memento->settingsSelf() == settingsSelf(); && memento->settingsSelf() == settingsSelf();
} }
@ -190,8 +190,8 @@ void Controller::updateSearchControllers(
= (type == Type::CommonGroups); = (type == Type::CommonGroups);
auto hasMembersSearch auto hasMembersSearch
= (type == Type::Members = (type == Type::Members
|| type == Type::Profile || type == Type::Profile/* // #feed
|| type == Type::Channels); || type == Type::Channels*/);
auto searchQuery = memento->searchFieldQuery(); auto searchQuery = memento->searchFieldQuery();
if (isMedia) { if (isMedia) {
_searchController _searchController

View file

@ -31,17 +31,17 @@ struct Tag {
class Key { class Key {
public: public:
Key(not_null<PeerData*> peer); Key(not_null<PeerData*> peer);
Key(not_null<Data::Feed*> feed); //Key(not_null<Data::Feed*> feed); // #feed
Key(Settings::Tag settings); Key(Settings::Tag settings);
PeerData *peer() const; PeerData *peer() const;
Data::Feed *feed() const; //Data::Feed *feed() const; // #feed
UserData *settingsSelf() const; UserData *settingsSelf() const;
private: private:
base::variant< base::variant<
not_null<PeerData*>, not_null<PeerData*>,
not_null<Data::Feed*>, //not_null<Data::Feed*>, // #feed
Settings::Tag> _value; Settings::Tag> _value;
}; };
@ -58,7 +58,7 @@ public:
Media, Media,
CommonGroups, CommonGroups,
Members, Members,
Channels, //Channels, // #feed
Settings, Settings,
}; };
using SettingsType = ::Settings::Type; using SettingsType = ::Settings::Type;
@ -107,9 +107,9 @@ public:
PeerId peerId() const; PeerId peerId() const;
PeerId migratedPeerId() const; PeerId migratedPeerId() const;
Data::Feed *feed() const { //Data::Feed *feed() const { // #feed
return key().feed(); // return key().feed();
} //}
UserData *settingsSelf() const { UserData *settingsSelf() const {
return key().settingsSelf(); return key().settingsSelf();
} }

View file

@ -10,9 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "info/profile/info_profile_widget.h" #include "info/profile/info_profile_widget.h"
#include "info/media/info_media_widget.h" #include "info/media/info_media_widget.h"
#include "info/members/info_members_widget.h" #include "info/members/info_members_widget.h"
#include "info/channels/info_channels_widget.h" //#include "info/channels/info_channels_widget.h" // #feed
#include "info/common_groups/info_common_groups_widget.h" #include "info/common_groups/info_common_groups_widget.h"
#include "info/feed/info_feed_profile_widget.h" //#include "info/feed/info_feed_profile_widget.h" // #feed
#include "info/settings/info_settings_widget.h" #include "info/settings/info_settings_widget.h"
#include "info/info_section_widget.h" #include "info/info_section_widget.h"
#include "info/info_layer_widget.h" #include "info/info_layer_widget.h"
@ -33,10 +33,10 @@ Memento::Memento(PeerId peerId, Section section)
: Memento(DefaultStack(peerId, section)) { : Memento(DefaultStack(peerId, section)) {
} }
Memento::Memento(not_null<Data::Feed*> feed, Section section) //Memento::Memento(not_null<Data::Feed*> feed, Section section) // #feed
: Memento(DefaultStack(feed, section)) { //: Memento(DefaultStack(feed, section)) {
} //}
//
Memento::Memento(Settings::Tag settings, Section section) Memento::Memento(Settings::Tag settings, Section section)
: Memento(DefaultStack(settings, section)) { : Memento(DefaultStack(settings, section)) {
} }
@ -53,14 +53,14 @@ std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack(
return result; return result;
} }
std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( //std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
Section section) { // Section section) {
auto result = std::vector<std::unique_ptr<ContentMemento>>(); // auto result = std::vector<std::unique_ptr<ContentMemento>>();
result.push_back(DefaultContent(feed, section)); // result.push_back(DefaultContent(feed, section));
return result; // return result;
} //}
//
std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack( std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack(
Settings::Tag settings, Settings::Tag settings,
Section section) { Section section) {
@ -71,21 +71,32 @@ std::vector<std::unique_ptr<ContentMemento>> Memento::DefaultStack(
return result; return result;
} }
Section Memento::DefaultSection(Dialogs::Key key) { Section Memento::DefaultSection(not_null<PeerData*> peer) {
if (const auto peer = key.peer()) { if (peer->isSelf()) {
if (peer->isSelf()) { return Section(Section::MediaType::Photo);
return Section(Section::MediaType::Photo);
}
} }
return Section(Section::Type::Profile); return Section(Section::Type::Profile);
} }
// // #feed
//Section Memento::DefaultSection(Dialogs::Key key) {
// if (const auto peer = key.peer()) {
// if (peer->isSelf()) {
// return Section(Section::MediaType::Photo);
// }
// }
// return Section(Section::Type::Profile);
//}
Memento Memento::Default(Dialogs::Key key) { Memento Memento::Default(not_null<PeerData*> peer) {
if (const auto peer = key.peer()) { return Memento(peer->id, DefaultSection(peer));
return Memento(peer->id, DefaultSection(key));
}
return Memento(key.feed(), DefaultSection(key));
} }
// // #feed
//Memento Memento::Default(Dialogs::Key key) {
// if (const auto peer = key.peer()) {
// return Memento(peer->id, DefaultSection(key));
// }
// return Memento(key.feed(), DefaultSection(key));
//}
std::unique_ptr<ContentMemento> Memento::DefaultContent( std::unique_ptr<ContentMemento> Memento::DefaultContent(
PeerId peerId, PeerId peerId,
@ -121,18 +132,18 @@ std::unique_ptr<ContentMemento> Memento::DefaultContent(
} }
Unexpected("Wrong section type in Info::Memento::DefaultContent()"); Unexpected("Wrong section type in Info::Memento::DefaultContent()");
} }
//
std::unique_ptr<ContentMemento> Memento::DefaultContent( //std::unique_ptr<ContentMemento> Memento::DefaultContent( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
Section section) { // Section section) {
switch (section.type()) { // switch (section.type()) {
case Section::Type::Profile: // case Section::Type::Profile:
return std::make_unique<FeedProfile::Memento>(feed); // return std::make_unique<FeedProfile::Memento>(feed);
case Section::Type::Channels: // case Section::Type::Channels:
return std::make_unique<Channels::Memento>(feed); // return std::make_unique<Channels::Memento>(feed);
} // }
Unexpected("Wrong feed section in Info::Memento::DefaultContent()"); // Unexpected("Wrong feed section in Info::Memento::DefaultContent()");
} //}
object_ptr<Window::SectionWidget> Memento::createWidget( object_ptr<Window::SectionWidget> Memento::createWidget(
QWidget *parent, QWidget *parent,

View file

@ -16,10 +16,6 @@ namespace Storage {
enum class SharedMediaType : signed char; enum class SharedMediaType : signed char;
} // namespace Storage } // namespace Storage
namespace Data {
class Feed;
} // namespace Data
namespace Ui { namespace Ui {
class ScrollArea; class ScrollArea;
struct ScrollToRequest; struct ScrollToRequest;
@ -37,7 +33,7 @@ class Memento final : public Window::SectionMemento {
public: public:
explicit Memento(PeerId peerId); explicit Memento(PeerId peerId);
Memento(PeerId peerId, Section section); Memento(PeerId peerId, Section section);
Memento(not_null<Data::Feed*> feed, Section section); //Memento(not_null<Data::Feed*> feed, Section section); // #feed
Memento(Settings::Tag settings, Section section); Memento(Settings::Tag settings, Section section);
explicit Memento(std::vector<std::unique_ptr<ContentMemento>> stack); explicit Memento(std::vector<std::unique_ptr<ContentMemento>> stack);
@ -62,8 +58,10 @@ public:
return _stack.back().get(); return _stack.back().get();
} }
static Section DefaultSection(Dialogs::Key key); static Section DefaultSection(not_null<PeerData*> peer);
static Memento Default(Dialogs::Key key); //static Section DefaultSection(Dialogs::Key key); // #feed
static Memento Default(not_null<PeerData*> peer);
//static Memento Default(Dialogs::Key key); // #feed
~Memento(); ~Memento();
@ -71,15 +69,15 @@ private:
static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( static std::vector<std::unique_ptr<ContentMemento>> DefaultStack(
PeerId peerId, PeerId peerId,
Section section); Section section);
static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( //static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
Section section); // Section section);
static std::vector<std::unique_ptr<ContentMemento>> DefaultStack( static std::vector<std::unique_ptr<ContentMemento>> DefaultStack(
Settings::Tag settings, Settings::Tag settings,
Section section); Section section);
static std::unique_ptr<ContentMemento> DefaultContent( //static std::unique_ptr<ContentMemento> DefaultContent( // #feed
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
Section section); // Section section);
static std::unique_ptr<ContentMemento> DefaultContent( static std::unique_ptr<ContentMemento> DefaultContent(
PeerId peerId, PeerId peerId,

View file

@ -554,9 +554,9 @@ rpl::producer<QString> TitleValue(
switch (section.type()) { switch (section.type()) {
case Section::Type::Profile: case Section::Type::Profile:
if (const auto feed = key.feed()) { /*if (const auto feed = key.feed()) {
return lng_info_feed_title; return lng_info_feed_title;
} else if (const auto user = peer->asUser()) { } else */if (const auto user = peer->asUser()) {
return (user->isBot() && !user->isSupport()) return (user->isBot() && !user->isSupport())
? lng_info_bot_title ? lng_info_bot_title
: lng_info_user_title; : lng_info_user_title;
@ -597,8 +597,8 @@ rpl::producer<QString> TitleValue(
case Section::Type::Members: case Section::Type::Members:
return lng_profile_participants_section; return lng_profile_participants_section;
case Section::Type::Channels: //case Section::Type::Channels: // #feed
return lng_info_feed_channels; // return lng_info_feed_channels;
case Section::Type::Settings: case Section::Type::Settings:
switch (section.settingsType()) { switch (section.settingsType()) {

View file

@ -131,8 +131,8 @@ void WrapWidget::startInjectingActivePeerProfiles() {
void WrapWidget::injectActiveProfile(Dialogs::Key key) { void WrapWidget::injectActiveProfile(Dialogs::Key key) {
if (const auto peer = key.peer()) { if (const auto peer = key.peer()) {
injectActivePeerProfile(peer); injectActivePeerProfile(peer);
} else if (const auto feed = key.feed()) { //} else if (const auto feed = key.feed()) { // #feed
injectActiveFeedProfile(feed); // injectActiveFeedProfile(feed);
} }
} }
@ -167,22 +167,22 @@ void WrapWidget::injectActivePeerProfile(not_null<PeerData*> peer) {
Memento(peer->id, section).takeStack().front())); Memento(peer->id, section).takeStack().front()));
} }
} }
// // #feed
void WrapWidget::injectActiveFeedProfile(not_null<Data::Feed*> feed) { //void WrapWidget::injectActiveFeedProfile(not_null<Data::Feed*> feed) {
const auto firstFeed = hasStackHistory() // const auto firstFeed = hasStackHistory()
? _historyStack.front().section->feed() // ? _historyStack.front().section->feed()
: _controller->feed(); // : _controller->feed();
const auto firstSectionType = hasStackHistory() // const auto firstSectionType = hasStackHistory()
? _historyStack.front().section->section().type() // ? _historyStack.front().section->section().type()
: _controller->section().type(); // : _controller->section().type();
const auto expectedType = Section::Type::Profile; // const auto expectedType = Section::Type::Profile;
if (firstSectionType != expectedType // if (firstSectionType != expectedType
|| firstFeed != feed) { // || firstFeed != feed) {
auto section = Section(Section::Type::Profile); // auto section = Section(Section::Type::Profile);
injectActiveProfileMemento(std::move( // injectActiveProfileMemento(std::move(
Memento(feed, section).takeStack().front())); // Memento(feed, section).takeStack().front()));
} // }
} //}
void WrapWidget::injectActiveProfileMemento( void WrapWidget::injectActiveProfileMemento(
std::unique_ptr<ContentMemento> memento) { std::unique_ptr<ContentMemento> memento) {
@ -214,8 +214,8 @@ Key WrapWidget::key() const {
Dialogs::RowDescriptor WrapWidget::activeChat() const { Dialogs::RowDescriptor WrapWidget::activeChat() const {
if (const auto peer = key().peer()) { if (const auto peer = key().peer()) {
return Dialogs::RowDescriptor(peer->owner().history(peer), FullMsgId()); return Dialogs::RowDescriptor(peer->owner().history(peer), FullMsgId());
} else if (const auto feed = key().feed()) { //} else if (const auto feed = key().feed()) { // #feed
return Dialogs::RowDescriptor(feed, FullMsgId()); // return Dialogs::RowDescriptor(feed, FullMsgId());
} else if (key().settingsSelf()) { } else if (key().settingsSelf()) {
return Dialogs::RowDescriptor(); return Dialogs::RowDescriptor();
} }
@ -570,12 +570,12 @@ void WrapWidget::showTopBarMenu() {
peer, peer,
addAction, addAction,
Window::PeerMenuSource::Profile); Window::PeerMenuSource::Profile);
} else if (const auto feed = key().feed()) { //} else if (const auto feed = key().feed()) { // #feed
Window::FillFeedMenu( // Window::FillFeedMenu(
_controller->parentController(), // _controller->parentController(),
feed, // feed,
addAction, // addAction,
Window::PeerMenuSource::Profile); // Window::PeerMenuSource::Profile);
} else if (const auto self = key().settingsSelf()) { } else if (const auto self = key().settingsSelf()) {
const auto showOther = [=](::Settings::Type type) { const auto showOther = [=](::Settings::Type type) {
const auto controller = _controller.get(); const auto controller = _controller.get();

View file

@ -14,10 +14,6 @@ namespace Storage {
enum class SharedMediaType : signed char; enum class SharedMediaType : signed char;
} // namespace Storage } // namespace Storage
namespace Data {
class Feed;
} // namespace Data
namespace Ui { namespace Ui {
class SettingsSlider; class SettingsSlider;
class FadeShadow; class FadeShadow;
@ -148,7 +144,7 @@ private:
void startInjectingActivePeerProfiles(); void startInjectingActivePeerProfiles();
void injectActiveProfile(Dialogs::Key key); void injectActiveProfile(Dialogs::Key key);
void injectActivePeerProfile(not_null<PeerData*> peer); void injectActivePeerProfile(not_null<PeerData*> peer);
void injectActiveFeedProfile(not_null<Data::Feed*> feed); //void injectActiveFeedProfile(not_null<Data::Feed*> feed); // #feed
void injectActiveProfileMemento( void injectActiveProfileMemento(
std::unique_ptr<ContentMemento> memento); std::unique_ptr<ContentMemento> memento);
void checkBeforeClose(Fn<void()> close); void checkBeforeClose(Fn<void()> close);

View file

@ -7,11 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "info/profile/info_profile_actions.h" #include "info/profile/info_profile_actions.h"
#include <rpl/flatten_latest.h>
#include <rpl/combine.h>
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_user.h" #include "data/data_user.h"
#include "ui/wrap/vertical_layout.h" #include "ui/wrap/vertical_layout.h"
@ -167,37 +165,37 @@ private:
object_ptr<Ui::VerticalLayout> _wrap = { nullptr }; object_ptr<Ui::VerticalLayout> _wrap = { nullptr };
}; };
// // #feed
class FeedDetailsFiller { //class FeedDetailsFiller {
public: //public:
FeedDetailsFiller( // FeedDetailsFiller(
not_null<Controller*> controller, // not_null<Controller*> controller,
not_null<Ui::RpWidget*> parent, // not_null<Ui::RpWidget*> parent,
not_null<Data::Feed*> feed); // not_null<Data::Feed*> feed);
//
object_ptr<Ui::RpWidget> fill(); // object_ptr<Ui::RpWidget> fill();
//
private: //private:
object_ptr<Ui::RpWidget> setupDefaultToggle(); // object_ptr<Ui::RpWidget> setupDefaultToggle();
//
template < // template <
typename Widget, // typename Widget,
typename = std::enable_if_t< // typename = std::enable_if_t<
std::is_base_of_v<Ui::RpWidget, Widget>>> // std::is_base_of_v<Ui::RpWidget, Widget>>>
Widget *add( // Widget *add(
object_ptr<Widget> &&child, // object_ptr<Widget> &&child,
const style::margins &margin = style::margins()) { // const style::margins &margin = style::margins()) {
return _wrap->add( // return _wrap->add(
std::move(child), // std::move(child),
margin); // margin);
} // }
//
not_null<Controller*> _controller; // not_null<Controller*> _controller;
not_null<Ui::RpWidget*> _parent; // not_null<Ui::RpWidget*> _parent;
not_null<Data::Feed*> _feed; // not_null<Data::Feed*> _feed;
object_ptr<Ui::VerticalLayout> _wrap; // object_ptr<Ui::VerticalLayout> _wrap;
//
}; //};
DetailsFiller::DetailsFiller( DetailsFiller::DetailsFiller(
not_null<Controller*> controller, not_null<Controller*> controller,
@ -703,47 +701,47 @@ object_ptr<Ui::RpWidget> ActionsFiller::fill() {
} }
return { nullptr }; return { nullptr };
} }
// // #feed
FeedDetailsFiller::FeedDetailsFiller( //FeedDetailsFiller::FeedDetailsFiller(
not_null<Controller*> controller, // not_null<Controller*> controller,
not_null<Ui::RpWidget*> parent, // not_null<Ui::RpWidget*> parent,
not_null<Data::Feed*> feed) // not_null<Data::Feed*> feed)
: _controller(controller) //: _controller(controller)
, _parent(parent) //, _parent(parent)
, _feed(feed) //, _feed(feed)
, _wrap(_parent) { //, _wrap(_parent) {
} //}
//
object_ptr<Ui::RpWidget> FeedDetailsFiller::fill() { //object_ptr<Ui::RpWidget> FeedDetailsFiller::fill() {
add(object_ptr<BoxContentDivider>(_wrap)); // add(object_ptr<BoxContentDivider>(_wrap));
add(CreateSkipWidget(_wrap)); // add(CreateSkipWidget(_wrap));
add(setupDefaultToggle()); // add(setupDefaultToggle());
add(CreateSkipWidget(_wrap)); // add(CreateSkipWidget(_wrap));
return std::move(_wrap); // return std::move(_wrap);
} //}
//
object_ptr<Ui::RpWidget> FeedDetailsFiller::setupDefaultToggle() { //object_ptr<Ui::RpWidget> FeedDetailsFiller::setupDefaultToggle() {
using namespace rpl::mappers; // using namespace rpl::mappers;
const auto feedId = _feed->id(); // const auto feedId = _feed->id();
auto result = object_ptr<Button>( // auto result = object_ptr<Button>(
_wrap, // _wrap,
Lang::Viewer(lng_info_feed_is_default), // Lang::Viewer(lng_info_feed_is_default),
st::infoNotificationsButton); // st::infoNotificationsButton);
result->toggleOn( // result->toggleOn(
Auth().data().defaultFeedIdValue( // Auth().data().defaultFeedIdValue(
) | rpl::map(_1 == feedId) // ) | rpl::map(_1 == feedId)
)->addClickHandler([=] { // )->addClickHandler([=] {
const auto makeDefault = (Auth().data().defaultFeedId() != feedId); // const auto makeDefault = (Auth().data().defaultFeedId() != feedId);
const auto defaultFeedId = makeDefault ? feedId : 0; // const auto defaultFeedId = makeDefault ? feedId : 0;
Auth().data().setDefaultFeedId(defaultFeedId); // Auth().data().setDefaultFeedId(defaultFeedId);
// Auth().api().saveDefaultFeedId(feedId, makeDefault); // #feed //// Auth().api().saveDefaultFeedId(feedId, makeDefault); // #feed
}); // });
object_ptr<FloatingIcon>( // object_ptr<FloatingIcon>(
result, // result,
st::infoIconNotifications, // st::infoIconNotifications,
st::infoNotificationsIconPosition); // st::infoNotificationsIconPosition);
return std::move(result); // return std::move(result);
} //}
} // namespace } // namespace
@ -840,14 +838,14 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
return std::move(result); return std::move(result);
} }
// // #feed
object_ptr<Ui::RpWidget> SetupFeedDetails( //object_ptr<Ui::RpWidget> SetupFeedDetails(
not_null<Controller*> controller, // not_null<Controller*> controller,
not_null<Ui::RpWidget*> parent, // not_null<Ui::RpWidget*> parent,
not_null<Data::Feed*> feed) { // not_null<Data::Feed*> feed) {
FeedDetailsFiller filler(controller, parent, feed); // FeedDetailsFiller filler(controller, parent, feed);
return filler.fill(); // return filler.fill();
} //}
} // namespace Profile } // namespace Profile
} // namespace Info } // namespace Info

View file

@ -7,10 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#pragma once #pragma once
namespace Data {
class Feed;
} // namespace Data
namespace Ui { namespace Ui {
class RpWidget; class RpWidget;
} // namespace Ui } // namespace Ui
@ -35,11 +31,11 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
not_null<Controller*> controller, not_null<Controller*> controller,
not_null<Ui::RpWidget*> parent, not_null<Ui::RpWidget*> parent,
not_null<PeerData*> peer); not_null<PeerData*> peer);
// // #feed
object_ptr<Ui::RpWidget> SetupFeedDetails( //object_ptr<Ui::RpWidget> SetupFeedDetails(
not_null<Controller*> controller, // not_null<Controller*> controller,
not_null<Ui::RpWidget*> parent, // not_null<Ui::RpWidget*> parent,
not_null<Data::Feed*> feed); // not_null<Data::Feed*> feed);
} // namespace Profile } // namespace Profile
} // namespace Info } // namespace Info

View file

@ -7,17 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#include "info/profile/info_profile_values.h" #include "info/profile/info_profile_values.h"
#include <rpl/filter.h>
#include <rpl/range.h>
#include <rpl/then.h>
#include <rpl/combine.h>
#include "observer_peer.h" #include "observer_peer.h"
#include "core/application.h" #include "core/application.h"
#include "auth_session.h" #include "auth_session.h"
#include "ui/wrap/slide_wrap.h" #include "ui/wrap/slide_wrap.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "data/data_shared_media.h" #include "data/data_shared_media.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_user.h" #include "data/data_user.h"
@ -329,21 +325,21 @@ rpl::producer<bool> VerifiedValue(not_null<PeerData*> peer) {
} }
return rpl::single(false); return rpl::single(false);
} }
// // #feed
rpl::producer<int> FeedChannelsCountValue(not_null<Data::Feed*> feed) { //rpl::producer<int> FeedChannelsCountValue(not_null<Data::Feed*> feed) {
using Flag = Data::FeedUpdateFlag; // using Flag = Data::FeedUpdateFlag;
return rpl::single( // return rpl::single(
Data::FeedUpdate{ feed, Flag::Channels } // Data::FeedUpdate{ feed, Flag::Channels }
) | rpl::then( // ) | rpl::then(
Auth().data().feedUpdated() // Auth().data().feedUpdated()
) | rpl::filter([=](const Data::FeedUpdate &update) { // ) | rpl::filter([=](const Data::FeedUpdate &update) {
return (update.feed == feed) && (update.flag == Flag::Channels); // return (update.feed == feed) && (update.flag == Flag::Channels);
}) | rpl::filter([=] { // }) | rpl::filter([=] {
return feed->channelsLoaded(); // return feed->channelsLoaded();
}) | rpl::map([=] { // }) | rpl::map([=] {
return int(feed->channels().size()); // return int(feed->channels().size());
}) | rpl::distinct_until_changed(); // }) | rpl::distinct_until_changed();
} //}
} // namespace Profile } // namespace Profile
} // namespace Info } // namespace Info

View file

@ -67,7 +67,7 @@ rpl::producer<int> CommonGroupsCountValue(not_null<UserData*> user);
rpl::producer<bool> CanAddMemberValue(not_null<PeerData*> peer); rpl::producer<bool> CanAddMemberValue(not_null<PeerData*> peer);
rpl::producer<bool> VerifiedValue(not_null<PeerData*> peer); rpl::producer<bool> VerifiedValue(not_null<PeerData*> peer);
rpl::producer<int> FeedChannelsCountValue(not_null<Data::Feed*> feed); //rpl::producer<int> FeedChannelsCountValue(not_null<Data::Feed*> feed); // #feed
} // namespace Profile } // namespace Profile
} // namespace Info } // namespace Info

View file

@ -18,7 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_drafts.h" #include "data/data_drafts.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
#include "data/data_user.h" #include "data/data_user.h"
@ -2395,9 +2395,10 @@ void MainWidget::updateControlsGeometry() {
if (session().settings().tabbedSelectorSectionEnabled()) { if (session().settings().tabbedSelectorSectionEnabled()) {
_history->pushTabbedSelectorToThirdSection(params); _history->pushTabbedSelectorToThirdSection(params);
} else if (session().settings().thirdSectionInfoEnabled()) { } else if (session().settings().thirdSectionInfoEnabled()) {
if (const auto key = _controller->activeChatCurrent()) { const auto active = _controller->activeChatCurrent();
if (const auto peer = active.peer()) {
_controller->showSection( _controller->showSection(
Info::Memento::Default(key), Info::Memento::Default(peer),
params.withThirdColumn()); params.withThirdColumn());
} }
} }
@ -2605,11 +2606,11 @@ auto MainWidget::thirdSectionForCurrentMainSection(
} else if (const auto peer = key.peer()) { } else if (const auto peer = key.peer()) {
return std::make_unique<Info::Memento>( return std::make_unique<Info::Memento>(
peer->id, peer->id,
Info::Memento::DefaultSection(key)); Info::Memento::DefaultSection(peer));
} else if (const auto feed = key.feed()) { //} else if (const auto feed = key.feed()) { // #feed
return std::make_unique<Info::Memento>( // return std::make_unique<Info::Memento>(
feed, // feed,
Info::Memento::DefaultSection(key)); // Info::Memento::DefaultSection(key));
} }
Unexpected("Key in MainWidget::thirdSectionForCurrentMainSection()."); Unexpected("Key in MainWidget::thirdSectionForCurrentMainSection().");
} }
@ -4281,35 +4282,17 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
const auto &d = update.c_updatePinnedDialogs(); const auto &d = update.c_updatePinnedDialogs();
if (d.has_order()) { if (d.has_order()) {
const auto &order = d.vorder.v; const auto &order = d.vorder.v;
const auto allLoaded = [&] { const auto notLoaded = [&](const MTPDialogPeer &peer) {
for (const auto &dialogPeer : order) { return peer.match([&](const MTPDdialogPeer &data) {
switch (dialogPeer.type()) { return !session().data().historyLoaded(
case mtpc_dialogPeer: { peerFromMTP(data.vpeer));
const auto &peer = dialogPeer.c_dialogPeer(); }, [&](const MTPDdialogPeerFolder &data) {
const auto peerId = peerFromMTP(peer.vpeer); //return !session().data().folderLoaded(data.vfolder_id.v);
if (!session().data().historyLoaded(peerId)) { return true; // #TODO archive
DEBUG_LOG(("API Error: " });
"pinned chat not loaded for peer %1" };
).arg(peerId const auto allLoaded = ranges::find_if(order, notLoaded)
)); == order.end();
return false;
}
} break;
//case mtpc_dialogPeerFeed: { // #feed
// const auto &feed = dialogPeer.c_dialogPeerFeed();
// const auto feedId = feed.vfeed_id.v;
// if (!session().data().feedLoaded(feedId)) {
// DEBUG_LOG(("API Error: "
// "pinned feed not loaded for feedId %1"
// ).arg(feedId
// ));
// return false;
// }
//} break;
}
}
return true;
}();
if (allLoaded) { if (allLoaded) {
session().data().applyPinnedDialogs(order); session().data().applyPinnedDialogs(order);
} else { } else {
@ -4322,32 +4305,30 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
case mtpc_updateDialogPinned: { case mtpc_updateDialogPinned: {
const auto &d = update.c_updateDialogPinned(); const auto &d = update.c_updateDialogPinned();
switch (d.vpeer.type()) { d.vpeer.match([&](const MTPDdialogPeer &data) {
case mtpc_dialogPeer: { const auto id = peerFromMTP(data.vpeer);
const auto peerId = peerFromMTP(d.vpeer.c_dialogPeer().vpeer); if (const auto history = session().data().historyLoaded(id)) {
if (const auto history = session().data().historyLoaded(peerId)) {
session().data().setPinnedDialog(history, d.is_pinned()); session().data().setPinnedDialog(history, d.is_pinned());
} else { } else {
DEBUG_LOG(("API Error: " DEBUG_LOG(("API Error: "
"pinned chat not loaded for peer %1" "pinned chat not loaded for peer %1"
).arg(peerId ).arg(id
)); ));
_dialogs->loadPinnedDialogs(); _dialogs->loadPinnedDialogs();
} }
} break; }, [&](const MTPDdialogPeerFolder &data) {
//case mtpc_dialogPeerFeed: { // #feed // #TODO archive
// const auto feedId = d.vpeer.c_dialogPeerFeed().vfeed_id.v; //const auto id = data.vfolder_id.v;
// if (const auto feed = session().data().feedLoaded(feedId)) { //if (const auto folder = session().data().folderLoaded(id)) {
// session().data().setPinnedDialog(feed, d.is_pinned()); // session().data().setPinnedDialog(folder, d.is_pinned());
// } else { //} else {
// DEBUG_LOG(("API Error: " // DEBUG_LOG(("API Error: "
// "pinned feed not loaded for feedId %1" // "pinned folder not loaded for feedId %1"
// ).arg(feedId // ).arg(folderId
// )); // ));
// _dialogs->loadPinnedDialogs(); // _dialogs->loadPinnedDialogs();
// } //}
//} break; });
}
} break; } break;
case mtpc_updateChannel: { case mtpc_updateChannel: {
@ -4356,17 +4337,17 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
channel->inviter = UserId(0); channel->inviter = UserId(0);
if (channel->amIn()) { if (channel->amIn()) {
const auto history = channel->owner().history(channel); const auto history = channel->owner().history(channel);
if (const auto feed = channel->feed()) { //if (const auto feed = channel->feed()) { // #feed
feed->requestChatListMessage(); // feed->requestChatListMessage();
if (!feed->unreadCountKnown()) { // if (!feed->unreadCountKnown()) {
feed->session().api().requestDialogEntry(feed); // feed->session().api().requestDialogEntry(feed);
} // }
} else { //} else {
history->requestChatListMessage(); history->requestChatListMessage();
if (!history->unreadCountKnown()) { if (!history->unreadCountKnown()) {
history->session().api().requestDialogEntry(history); history->session().api().requestDialogEntry(history);
} }
} //}
if (!channel->amCreator()) { if (!channel->amCreator()) {
session().api().requestSelfParticipant(channel); session().api().requestSelfParticipant(channel);
} }

View file

@ -9,7 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_shared_media.h" #include "storage/storage_shared_media.h"
#include "storage/storage_user_photos.h" #include "storage/storage_user_photos.h"
#include "storage/storage_feed_messages.h" //#include "storage/storage_feed_messages.h" // #feed
namespace Storage { namespace Storage {
@ -34,24 +34,24 @@ public:
rpl::producer<UserPhotosResult> query(UserPhotosQuery &&query) const; rpl::producer<UserPhotosResult> query(UserPhotosQuery &&query) const;
rpl::producer<UserPhotosSliceUpdate> userPhotosSliceUpdated() const; rpl::producer<UserPhotosSliceUpdate> userPhotosSliceUpdated() const;
void add(FeedMessagesAddNew &&query); //void add(FeedMessagesAddNew &&query); // #feed
void add(FeedMessagesAddSlice &&query); //void add(FeedMessagesAddSlice &&query);
void remove(FeedMessagesRemoveOne &&query); //void remove(FeedMessagesRemoveOne &&query);
void remove(FeedMessagesRemoveAll &&query); //void remove(FeedMessagesRemoveAll &&query);
void invalidate(FeedMessagesInvalidate &&query); //void invalidate(FeedMessagesInvalidate &&query);
void invalidate(FeedMessagesInvalidateBottom &&query); //void invalidate(FeedMessagesInvalidateBottom &&query);
rpl::producer<FeedMessagesResult> query( //rpl::producer<FeedMessagesResult> query(
FeedMessagesQuery &&query) const; // FeedMessagesQuery &&query) const;
rpl::producer<FeedMessagesSliceUpdate> feedMessagesSliceUpdated() const; //rpl::producer<FeedMessagesSliceUpdate> feedMessagesSliceUpdated() const;
rpl::producer<FeedMessagesRemoveOne> feedMessagesOneRemoved() const; //rpl::producer<FeedMessagesRemoveOne> feedMessagesOneRemoved() const;
rpl::producer<FeedMessagesRemoveAll> feedMessagesAllRemoved() const; //rpl::producer<FeedMessagesRemoveAll> feedMessagesAllRemoved() const;
rpl::producer<FeedMessagesInvalidate> feedMessagesInvalidated() const; //rpl::producer<FeedMessagesInvalidate> feedMessagesInvalidated() const;
rpl::producer<FeedMessagesInvalidateBottom> feedMessagesBottomInvalidated() const; //rpl::producer<FeedMessagesInvalidateBottom> feedMessagesBottomInvalidated() const;
private: private:
SharedMedia _sharedMedia; SharedMedia _sharedMedia;
UserPhotos _userPhotos; UserPhotos _userPhotos;
FeedMessages _feedMessages; //FeedMessages _feedMessages; // #feed
}; };
@ -122,55 +122,55 @@ rpl::producer<UserPhotosResult> Facade::Impl::query(UserPhotosQuery &&query) con
rpl::producer<UserPhotosSliceUpdate> Facade::Impl::userPhotosSliceUpdated() const { rpl::producer<UserPhotosSliceUpdate> Facade::Impl::userPhotosSliceUpdated() const {
return _userPhotos.sliceUpdated(); return _userPhotos.sliceUpdated();
} }
// // #feed
void Facade::Impl::add(FeedMessagesAddNew &&query) { //void Facade::Impl::add(FeedMessagesAddNew &&query) {
return _feedMessages.add(std::move(query)); // return _feedMessages.add(std::move(query));
} //}
//
void Facade::Impl::add(FeedMessagesAddSlice &&query) { //void Facade::Impl::add(FeedMessagesAddSlice &&query) {
return _feedMessages.add(std::move(query)); // return _feedMessages.add(std::move(query));
} //}
//
void Facade::Impl::remove(FeedMessagesRemoveOne &&query) { //void Facade::Impl::remove(FeedMessagesRemoveOne &&query) {
return _feedMessages.remove(std::move(query)); // return _feedMessages.remove(std::move(query));
} //}
//
void Facade::Impl::remove(FeedMessagesRemoveAll &&query) { //void Facade::Impl::remove(FeedMessagesRemoveAll &&query) {
return _feedMessages.remove(std::move(query)); // return _feedMessages.remove(std::move(query));
} //}
//
void Facade::Impl::invalidate(FeedMessagesInvalidate &&query) { //void Facade::Impl::invalidate(FeedMessagesInvalidate &&query) {
return _feedMessages.invalidate(std::move(query)); // return _feedMessages.invalidate(std::move(query));
} //}
//
void Facade::Impl::invalidate(FeedMessagesInvalidateBottom &&query) { //void Facade::Impl::invalidate(FeedMessagesInvalidateBottom &&query) {
return _feedMessages.invalidate(std::move(query)); // return _feedMessages.invalidate(std::move(query));
} //}
//
rpl::producer<FeedMessagesResult> Facade::Impl::query( //rpl::producer<FeedMessagesResult> Facade::Impl::query(
FeedMessagesQuery &&query) const { // FeedMessagesQuery &&query) const {
return _feedMessages.query(std::move(query)); // return _feedMessages.query(std::move(query));
} //}
//
rpl::producer<FeedMessagesSliceUpdate> Facade::Impl::feedMessagesSliceUpdated() const { //rpl::producer<FeedMessagesSliceUpdate> Facade::Impl::feedMessagesSliceUpdated() const {
return _feedMessages.sliceUpdated(); // return _feedMessages.sliceUpdated();
} //}
//
rpl::producer<FeedMessagesRemoveOne> Facade::Impl::feedMessagesOneRemoved() const { //rpl::producer<FeedMessagesRemoveOne> Facade::Impl::feedMessagesOneRemoved() const {
return _feedMessages.oneRemoved(); // return _feedMessages.oneRemoved();
} //}
//
rpl::producer<FeedMessagesRemoveAll> Facade::Impl::feedMessagesAllRemoved() const { //rpl::producer<FeedMessagesRemoveAll> Facade::Impl::feedMessagesAllRemoved() const {
return _feedMessages.allRemoved(); // return _feedMessages.allRemoved();
} //}
//
rpl::producer<FeedMessagesInvalidate> Facade::Impl::feedMessagesInvalidated() const { //rpl::producer<FeedMessagesInvalidate> Facade::Impl::feedMessagesInvalidated() const {
return _feedMessages.invalidated(); // return _feedMessages.invalidated();
} //}
//
rpl::producer<FeedMessagesInvalidateBottom> Facade::Impl::feedMessagesBottomInvalidated() const { //rpl::producer<FeedMessagesInvalidateBottom> Facade::Impl::feedMessagesBottomInvalidated() const {
return _feedMessages.bottomInvalidated(); // return _feedMessages.bottomInvalidated();
} //}
Facade::Facade() : _impl(std::make_unique<Impl>()) { Facade::Facade() : _impl(std::make_unique<Impl>()) {
} }
@ -242,55 +242,55 @@ rpl::producer<UserPhotosResult> Facade::query(UserPhotosQuery &&query) const {
rpl::producer<UserPhotosSliceUpdate> Facade::userPhotosSliceUpdated() const { rpl::producer<UserPhotosSliceUpdate> Facade::userPhotosSliceUpdated() const {
return _impl->userPhotosSliceUpdated(); return _impl->userPhotosSliceUpdated();
} }
// // #feed
void Facade::add(FeedMessagesAddNew &&query) { //void Facade::add(FeedMessagesAddNew &&query) {
return _impl->add(std::move(query)); // return _impl->add(std::move(query));
} //}
//
void Facade::add(FeedMessagesAddSlice &&query) { //void Facade::add(FeedMessagesAddSlice &&query) {
return _impl->add(std::move(query)); // return _impl->add(std::move(query));
} //}
//
void Facade::remove(FeedMessagesRemoveOne &&query) { //void Facade::remove(FeedMessagesRemoveOne &&query) {
return _impl->remove(std::move(query)); // return _impl->remove(std::move(query));
} //}
//
void Facade::remove(FeedMessagesRemoveAll &&query) { //void Facade::remove(FeedMessagesRemoveAll &&query) {
return _impl->remove(std::move(query)); // return _impl->remove(std::move(query));
} //}
//
void Facade::invalidate(FeedMessagesInvalidate &&query) { //void Facade::invalidate(FeedMessagesInvalidate &&query) {
return _impl->invalidate(std::move(query)); // return _impl->invalidate(std::move(query));
} //}
//
void Facade::invalidate(FeedMessagesInvalidateBottom &&query) { //void Facade::invalidate(FeedMessagesInvalidateBottom &&query) {
return _impl->invalidate(std::move(query)); // return _impl->invalidate(std::move(query));
} //}
//
rpl::producer<FeedMessagesResult> Facade::query( //rpl::producer<FeedMessagesResult> Facade::query(
FeedMessagesQuery &&query) const { // FeedMessagesQuery &&query) const {
return _impl->query(std::move(query)); // return _impl->query(std::move(query));
} //}
//
rpl::producer<FeedMessagesSliceUpdate> Facade::feedMessagesSliceUpdated() const { //rpl::producer<FeedMessagesSliceUpdate> Facade::feedMessagesSliceUpdated() const {
return _impl->feedMessagesSliceUpdated(); // return _impl->feedMessagesSliceUpdated();
} //}
//
rpl::producer<FeedMessagesRemoveOne> Facade::feedMessagesOneRemoved() const { //rpl::producer<FeedMessagesRemoveOne> Facade::feedMessagesOneRemoved() const {
return _impl->feedMessagesOneRemoved(); // return _impl->feedMessagesOneRemoved();
} //}
//
rpl::producer<FeedMessagesRemoveAll> Facade::feedMessagesAllRemoved() const { //rpl::producer<FeedMessagesRemoveAll> Facade::feedMessagesAllRemoved() const {
return _impl->feedMessagesAllRemoved(); // return _impl->feedMessagesAllRemoved();
} //}
//
rpl::producer<FeedMessagesInvalidate> Facade::feedMessagesInvalidated() const { //rpl::producer<FeedMessagesInvalidate> Facade::feedMessagesInvalidated() const {
return _impl->feedMessagesInvalidated(); // return _impl->feedMessagesInvalidated();
} //}
//
rpl::producer<FeedMessagesInvalidateBottom> Facade::feedMessagesBottomInvalidated() const { //rpl::producer<FeedMessagesInvalidateBottom> Facade::feedMessagesBottomInvalidated() const {
return _impl->feedMessagesBottomInvalidated(); // return _impl->feedMessagesBottomInvalidated();
} //}
Facade::~Facade() = default; Facade::~Facade() = default;

View file

@ -36,15 +36,15 @@ struct UserPhotosQuery;
struct UserPhotosResult; struct UserPhotosResult;
struct UserPhotosSliceUpdate; struct UserPhotosSliceUpdate;
struct FeedMessagesAddNew; //struct FeedMessagesAddNew; // #feed
struct FeedMessagesAddSlice; //struct FeedMessagesAddSlice;
struct FeedMessagesRemoveOne; //struct FeedMessagesRemoveOne;
struct FeedMessagesRemoveAll; //struct FeedMessagesRemoveAll;
struct FeedMessagesInvalidate; //struct FeedMessagesInvalidate;
struct FeedMessagesInvalidateBottom; //struct FeedMessagesInvalidateBottom;
struct FeedMessagesQuery; //struct FeedMessagesQuery;
using FeedMessagesResult = Data::MessagesResult; //using FeedMessagesResult = Data::MessagesResult;
struct FeedMessagesSliceUpdate; //struct FeedMessagesSliceUpdate;
class Facade { class Facade {
public: public:
@ -71,20 +71,20 @@ public:
rpl::producer<UserPhotosResult> query(UserPhotosQuery &&query) const; rpl::producer<UserPhotosResult> query(UserPhotosQuery &&query) const;
rpl::producer<UserPhotosSliceUpdate> userPhotosSliceUpdated() const; rpl::producer<UserPhotosSliceUpdate> userPhotosSliceUpdated() const;
void add(FeedMessagesAddNew &&query); //void add(FeedMessagesAddNew &&query); // #feed
void add(FeedMessagesAddSlice &&query); //void add(FeedMessagesAddSlice &&query);
void remove(FeedMessagesRemoveOne &&query); //void remove(FeedMessagesRemoveOne &&query);
void remove(FeedMessagesRemoveAll &&query); //void remove(FeedMessagesRemoveAll &&query);
void invalidate(FeedMessagesInvalidate &&query); //void invalidate(FeedMessagesInvalidate &&query);
void invalidate(FeedMessagesInvalidateBottom &&query); //void invalidate(FeedMessagesInvalidateBottom &&query);
rpl::producer<FeedMessagesResult> query( //rpl::producer<FeedMessagesResult> query(
FeedMessagesQuery &&query) const; // FeedMessagesQuery &&query) const;
rpl::producer<FeedMessagesSliceUpdate> feedMessagesSliceUpdated() const; //rpl::producer<FeedMessagesSliceUpdate> feedMessagesSliceUpdated() const;
rpl::producer<FeedMessagesRemoveOne> feedMessagesOneRemoved() const; //rpl::producer<FeedMessagesRemoveOne> feedMessagesOneRemoved() const;
rpl::producer<FeedMessagesRemoveAll> feedMessagesAllRemoved() const; //rpl::producer<FeedMessagesRemoveAll> feedMessagesAllRemoved() const;
rpl::producer<FeedMessagesInvalidate> feedMessagesInvalidated() const; //rpl::producer<FeedMessagesInvalidate> feedMessagesInvalidated() const;
rpl::producer<FeedMessagesInvalidateBottom> feedMessagesBottomInvalidated() const; //rpl::producer<FeedMessagesInvalidateBottom> feedMessagesBottomInvalidated() const;
~Facade(); ~Facade();

View file

@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/empty_userpic.h" #include "ui/empty_userpic.h"
#include "data/data_photo.h" #include "data/data_photo.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "history/history.h" #include "history/history.h"
#include "core/file_utilities.h" #include "core/file_utilities.h"
@ -880,95 +880,95 @@ void UserpicButton::prepareUserpicPixmap() {
? _peer->userpicUniqueKey() ? _peer->userpicUniqueKey()
: InMemoryKey(); : InMemoryKey();
} }
// // #feed
FeedUserpicButton::FeedUserpicButton( //FeedUserpicButton::FeedUserpicButton(
QWidget *parent, // QWidget *parent,
not_null<Window::Controller*> controller, // not_null<Window::Controller*> controller,
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
const style::FeedUserpicButton &st) // const style::FeedUserpicButton &st)
: AbstractButton(parent) //: AbstractButton(parent)
, _st(st) //, _st(st)
, _controller(controller) //, _controller(controller)
, _feed(feed) { //, _feed(feed) {
prepare(); // prepare();
} //}
//
void FeedUserpicButton::prepare() { //void FeedUserpicButton::prepare() {
resize(_st.size); // resize(_st.size);
//
Auth().data().feedUpdated( // Auth().data().feedUpdated(
) | rpl::filter([=](const Data::FeedUpdate &update) { // ) | rpl::filter([=](const Data::FeedUpdate &update) {
return (update.feed == _feed) // return (update.feed == _feed)
&& (update.flag == Data::FeedUpdateFlag::Channels); // && (update.flag == Data::FeedUpdateFlag::Channels);
}) | rpl::start_with_next([=] { // }) | rpl::start_with_next([=] {
crl::on_main(this, [=] { checkParts(); }); // crl::on_main(this, [=] { checkParts(); });
}, lifetime()); // }, lifetime());
//
refreshParts(); // refreshParts();
} //}
//
void FeedUserpicButton::checkParts() { //void FeedUserpicButton::checkParts() {
if (!partsAreValid()) { // if (!partsAreValid()) {
refreshParts(); // refreshParts();
} // }
} //}
//
bool FeedUserpicButton::partsAreValid() const { //bool FeedUserpicButton::partsAreValid() const {
const auto &channels = _feed->channels(); // const auto &channels = _feed->channels();
const auto count = std::min(int(channels.size()), 4); // const auto count = std::min(int(channels.size()), 4);
if (count != _parts.size()) { // if (count != _parts.size()) {
return false; // return false;
} // }
for (auto i = 0; i != count; ++i) { // for (auto i = 0; i != count; ++i) {
if (channels[i]->peer != _parts[i].channel) { // if (channels[i]->peer != _parts[i].channel) {
return false; // return false;
} // }
} // }
return true; // return true;
} //}
//
void FeedUserpicButton::refreshParts() { //void FeedUserpicButton::refreshParts() {
const auto &channels = _feed->channels(); // const auto &channels = _feed->channels();
const auto count = std::min(int(channels.size()), 4); // const auto count = std::min(int(channels.size()), 4);
//
const auto createButton = [&](not_null<ChannelData*> channel) { // const auto createButton = [&](not_null<ChannelData*> channel) {
auto result = base::make_unique_q<Ui::UserpicButton>( // auto result = base::make_unique_q<Ui::UserpicButton>(
this, // this,
_controller, // _controller,
channel, // channel,
Ui::UserpicButton::Role::Custom, // Ui::UserpicButton::Role::Custom,
_st.innerPart); // _st.innerPart);
result->setAttribute(Qt::WA_TransparentForMouseEvents); // result->setAttribute(Qt::WA_TransparentForMouseEvents);
result->show(); // result->show();
return result; // return result;
}; // };
//
const auto position = countInnerPosition(); // const auto position = countInnerPosition();
auto x = position.x(); // auto x = position.x();
auto y = position.y(); // auto y = position.y();
const auto delta = _st.innerSize - _st.innerPart.photoSize; // const auto delta = _st.innerSize - _st.innerPart.photoSize;
_parts.clear(); // _parts.clear();
for (auto i = 0; i != count; ++i) { // for (auto i = 0; i != count; ++i) {
const auto channel = channels[i]->peer->asChannel(); // const auto channel = channels[i]->peer->asChannel();
_parts.push_back({ channel, createButton(channel) }); // _parts.push_back({ channel, createButton(channel) });
_parts.back().button->moveToLeft(x, y); // _parts.back().button->moveToLeft(x, y);
switch (i) { // switch (i) {
case 0: // case 0:
case 2: x += delta; break; // case 2: x += delta; break;
case 1: x -= delta; y += delta; break; // case 1: x -= delta; y += delta; break;
} // }
} // }
} //}
//
QPoint FeedUserpicButton::countInnerPosition() const { //QPoint FeedUserpicButton::countInnerPosition() const {
auto innerLeft = (_st.innerPosition.x() < 0) // auto innerLeft = (_st.innerPosition.x() < 0)
? (width() - _st.innerSize) / 2 // ? (width() - _st.innerSize) / 2
: _st.innerPosition.x(); // : _st.innerPosition.x();
auto innerTop = (_st.innerPosition.y() < 0) // auto innerTop = (_st.innerPosition.y() < 0)
? (height() - _st.innerSize) / 2 // ? (height() - _st.innerSize) / 2
: _st.innerPosition.y(); // : _st.innerPosition.y();
return { innerLeft, innerTop }; // return { innerLeft, innerTop };
} //}
SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel) SilentToggle::SilentToggle(QWidget *parent, not_null<ChannelData*> channel)
: IconButton(parent, st::historySilentToggle) : IconButton(parent, st::historySilentToggle)

View file

@ -19,10 +19,6 @@ namespace Ui {
class InfiniteRadialAnimation; class InfiniteRadialAnimation;
} // namespace Ui } // namespace Ui
namespace Data {
class Feed;
} // namespace Data
namespace Window { namespace Window {
class Controller; class Controller;
} // namespace Window } // namespace Window
@ -225,33 +221,33 @@ private:
Ui::Animations::Simple _changeOverlayShown; Ui::Animations::Simple _changeOverlayShown;
}; };
// // #feed
class FeedUserpicButton : public AbstractButton { //class FeedUserpicButton : public AbstractButton {
public: //public:
FeedUserpicButton( // FeedUserpicButton(
QWidget *parent, // QWidget *parent,
not_null<Window::Controller*> controller, // not_null<Window::Controller*> controller,
not_null<Data::Feed*> feed, // not_null<Data::Feed*> feed,
const style::FeedUserpicButton &st); // const style::FeedUserpicButton &st);
//
private: //private:
struct Part { // struct Part {
not_null<ChannelData*> channel; // not_null<ChannelData*> channel;
base::unique_qptr<UserpicButton> button; // base::unique_qptr<UserpicButton> button;
}; // };
//
void prepare(); // void prepare();
void checkParts(); // void checkParts();
bool partsAreValid() const; // bool partsAreValid() const;
void refreshParts(); // void refreshParts();
QPoint countInnerPosition() const; // QPoint countInnerPosition() const;
//
const style::FeedUserpicButton &_st; // const style::FeedUserpicButton &_st;
not_null<Window::Controller*> _controller; // not_null<Window::Controller*> _controller;
not_null<Data::Feed*> _feed; // not_null<Data::Feed*> _feed;
std::vector<Part> _parts; // std::vector<Part> _parts;
//
}; //};
class SilentToggle : public Ui::IconButton, public Ui::AbstractTooltipShower { class SilentToggle : public Ui::IconButton, public Ui::AbstractTooltipShower {
public: public:

View file

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "media/audio/media_audio.h" #include "media/audio/media_audio.h"
#include "history/history.h" #include "history/history.h"
#include "history/history_item_components.h" #include "history/history_item_components.h"
#include "history/feed/history_feed_section.h" //#include "history/feed/history_feed_section.h" // #feed
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_channel.h" #include "data/data_channel.h"
@ -480,17 +480,17 @@ void Manager::openNotificationMessage(
} }
return true; return true;
}(); }();
const auto messageFeed = [&] { //const auto messageFeed = [&] { // #feed
if (const auto channel = history->peer->asChannel()) { // if (const auto channel = history->peer->asChannel()) {
return channel->feed(); // return channel->feed();
} // }
return (Data::Feed*)nullptr; // return (Data::Feed*)nullptr;
}(); //}();
if (openExactlyMessage) { if (openExactlyMessage) {
Ui::showPeerHistory(history, messageId); Ui::showPeerHistory(history, messageId);
} else if (messageFeed) { //} else if (messageFeed) { // #feed
App::wnd()->controller()->showSection( // App::wnd()->controller()->showSection(
HistoryFeed::Memento(messageFeed)); // HistoryFeed::Memento(messageFeed));
} else { } else {
Ui::showPeerHistory(history, ShowAtUnreadMsgId); Ui::showPeerHistory(history, ShowAtUnreadMsgId);
} }

View file

@ -14,10 +14,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history.h" #include "history/history.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "history/view/history_view_element.h" #include "history/view/history_view_element.h"
#include "history/feed/history_feed_section.h" //#include "history/feed/history_feed_section.h" // #feed
#include "data/data_media_types.h" #include "data/data_media_types.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
#include "passport/passport_form_controller.h" #include "passport/passport_form_controller.h"
@ -160,12 +160,12 @@ bool Controller::jumpToChatListEntry(Dialogs::RowDescriptor row) {
if (const auto history = row.key.history()) { if (const auto history = row.key.history()) {
Ui::showPeerHistory(history, row.fullId.msg); Ui::showPeerHistory(history, row.fullId.msg);
return true; return true;
} else if (const auto feed = row.key.feed()) { //} else if (const auto feed = row.key.feed()) { // #feed
if (const auto item = App::histItemById(row.fullId)) { // if (const auto item = App::histItemById(row.fullId)) {
showSection(HistoryFeed::Memento(feed, item->position())); // showSection(HistoryFeed::Memento(feed, item->position()));
} else { // } else {
showSection(HistoryFeed::Memento(feed)); // showSection(HistoryFeed::Memento(feed));
} // }
} }
return false; return false;
} }
@ -465,12 +465,12 @@ void Controller::showJumpToDate(Dialogs::Key chat, QDate requestedDate) {
} else if (history->chatListTimeId() != 0) { } else if (history->chatListTimeId() != 0) {
return ParseDateTime(history->chatListTimeId()).date(); return ParseDateTime(history->chatListTimeId()).date();
} }
} else if (const auto feed = chat.feed()) { //} else if (const auto feed = chat.feed()) { // #feed
/*if (chatScrollPosition(feed)) { // #TODO feeds save position // if (chatScrollPosition(feed)) { // #TODO feeds save position
} else */if (feed->chatListTimeId() != 0) { // } else if (feed->chatListTimeId() != 0) {
return ParseDateTime(feed->chatListTimeId()).date(); // return ParseDateTime(feed->chatListTimeId()).date();
} // }
} }
return QDate::currentDate(); return QDate::currentDate();
}; };
@ -482,10 +482,10 @@ void Controller::showJumpToDate(Dialogs::Key chat, QDate requestedDate) {
if (history && history->chatListTimeId() != 0) { if (history && history->chatListTimeId() != 0) {
return ParseDateTime(history->chatListTimeId()).date(); return ParseDateTime(history->chatListTimeId()).date();
} }
} else if (const auto feed = chat.feed()) { //} else if (const auto feed = chat.feed()) { // #feed
if (feed->chatListTimeId() != 0) { // if (feed->chatListTimeId() != 0) {
return ParseDateTime(feed->chatListTimeId()).date(); // return ParseDateTime(feed->chatListTimeId()).date();
} // }
} }
return QDate::currentDate(); return QDate::currentDate();
}; };
@ -512,8 +512,8 @@ void Controller::showJumpToDate(Dialogs::Key chat, QDate requestedDate) {
} }
return QDate::currentDate(); return QDate::currentDate();
} }
} else if (const auto feed = chat.feed()) { //} else if (const auto feed = chat.feed()) { // #feed
return startDate(); // return startDate();
} }
return startDate(); return startDate();
}; };

View file

@ -26,10 +26,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "support/support_helper.h" #include "support/support_helper.h"
#include "info/info_memento.h" #include "info/info_memento.h"
#include "info/info_controller.h" #include "info/info_controller.h"
#include "info/feed/info_feed_channels_controllers.h" //#include "info/feed/info_feed_channels_controllers.h" // #feed
#include "info/profile/info_profile_values.h" #include "info/profile/info_profile_values.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_feed.h" #include "data/data_folder.h"
#include "data/data_poll.h" #include "data/data_poll.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_chat.h" #include "data/data_chat.h"
@ -68,11 +68,11 @@ private:
}; };
class FeedFiller { class FolderFiller {
public: public:
FeedFiller( FolderFiller(
not_null<Controller*> controller, not_null<Controller*> controller,
not_null<Data::Feed*> feed, not_null<Data::Folder*> folder,
const PeerMenuCallback &addAction, const PeerMenuCallback &addAction,
PeerMenuSource source); PeerMenuSource source);
void fill(); void fill();
@ -86,7 +86,7 @@ private:
void addUngroup(); void addUngroup();
not_null<Controller*> _controller; not_null<Controller*> _controller;
not_null<Data::Feed*> _feed; not_null<Data::Folder*> _folder;
const PeerMenuCallback &_addAction; const PeerMenuCallback &_addAction;
PeerMenuSource _source; PeerMenuSource _source;
@ -386,15 +386,15 @@ void Filler::addChatActions(not_null<ChatData*> chat) {
void Filler::addChannelActions(not_null<ChannelData*> channel) { void Filler::addChannelActions(not_null<ChannelData*> channel) {
auto isGroup = channel->isMegagroup(); auto isGroup = channel->isMegagroup();
if (!isGroup) { //if (!isGroup) { // #feed
const auto feed = channel->feed(); // const auto feed = channel->feed();
const auto grouped = (feed != nullptr); // const auto grouped = (feed != nullptr);
if (!grouped || feed->channels().size() > 1) { // if (!grouped || feed->channels().size() > 1) {
//_addAction( // #feed // _addAction( // #feed
// lang(grouped ? lng_feed_ungroup : lng_feed_group), // lang(grouped ? lng_feed_ungroup : lng_feed_group),
// [=] { ToggleChannelGrouping(channel, !grouped); }); // [=] { ToggleChannelGrouping(channel, !grouped); });
} // }
} //}
if (_source != PeerMenuSource::ChatsList) { if (_source != PeerMenuSource::ChatsList) {
if (EditPeerInfoBox::Available(channel)) { if (EditPeerInfoBox::Available(channel)) {
const auto text = lang(isGroup const auto text = lang(isGroup
@ -479,89 +479,89 @@ void Filler::fill() {
} }
} }
FeedFiller::FeedFiller( FolderFiller::FolderFiller(
not_null<Controller*> controller, not_null<Controller*> controller,
not_null<Data::Feed*> feed, not_null<Data::Folder*> folder,
const PeerMenuCallback &addAction, const PeerMenuCallback &addAction,
PeerMenuSource source) PeerMenuSource source)
: _controller(controller) : _controller(controller)
, _feed(feed) , _folder(folder)
, _addAction(addAction) , _addAction(addAction)
, _source(source) { , _source(source) {
} }
void FeedFiller::fill() { void FolderFiller::fill() { // #TODO archive
if (_source == PeerMenuSource::ChatsList) { //if (_source == PeerMenuSource::ChatsList) {
addPinToggle(); // addPinToggle();
} //}
if (showInfo()) { //if (showInfo()) {
addInfo(); // addInfo();
} //}
addNotifications(); //addNotifications();
if (_source == PeerMenuSource::ChatsList) { //if (_source == PeerMenuSource::ChatsList) {
addSearch(); // addSearch();
} //}
addUngroup(); //addUngroup();
}
bool FeedFiller::showInfo() {
if (_source == PeerMenuSource::Profile) {
return false;
} else if (_controller->activeChatCurrent().feed() != _feed) {
return true;
} else if (!Adaptive::ThreeColumn()) {
return true;
} else if (
!Auth().settings().thirdSectionInfoEnabled() &&
!Auth().settings().tabbedReplacedWithInfo()) {
return true;
}
return false;
}
void FeedFiller::addPinToggle() {
const auto feed = _feed;
const auto isPinned = feed->isPinnedDialog();
const auto pinText = [](bool isPinned) {
return lang(isPinned
? lng_context_unpin_from_top
: lng_context_pin_to_top);
};
_addAction(pinText(isPinned), [=] {
TogglePinnedDialog(feed);
});
}
void FeedFiller::addInfo() {
auto controller = _controller;
auto feed = _feed;
_addAction(lang(lng_context_view_feed_info), [=] {
controller->showSection(Info::Memento(
feed,
Info::Section(Info::Section::Type::Profile)));
});
}
void FeedFiller::addNotifications() {
const auto feed = _feed;
_addAction(lang(lng_feed_notifications), [=] {
Info::FeedProfile::NotificationsController::Start(feed);
});
}
void FeedFiller::addSearch() {
const auto feed = _feed;
_addAction(lang(lng_profile_search_messages), [=] {
App::main()->searchInChat(feed);
});
}
void FeedFiller::addUngroup() {
const auto feed = _feed;
//_addAction(lang(lng_feed_ungroup_all), [=] { // #feed
// PeerMenuUngroupFeed(feed);
//});
} }
//
//bool FolderFiller::showInfo() {
// if (_source == PeerMenuSource::Profile) {
// return false;
// } else if (_controller->activeChatCurrent().feed() != _feed) {
// return true;
// } else if (!Adaptive::ThreeColumn()) {
// return true;
// } else if (
// !Auth().settings().thirdSectionInfoEnabled() &&
// !Auth().settings().tabbedReplacedWithInfo()) {
// return true;
// }
// return false;
//}
//
//void FolderFiller::addPinToggle() {
// const auto feed = _feed;
// const auto isPinned = feed->isPinnedDialog();
// const auto pinText = [](bool isPinned) {
// return lang(isPinned
// ? lng_context_unpin_from_top
// : lng_context_pin_to_top);
// };
// _addAction(pinText(isPinned), [=] {
// TogglePinnedDialog(feed);
// });
//}
//
//void FolderFiller::addInfo() {
// auto controller = _controller;
// auto feed = _feed;
// _addAction(lang(lng_context_view_feed_info), [=] {
// controller->showSection(Info::Memento(
// feed,
// Info::Section(Info::Section::Type::Profile)));
// });
//}
//
//void FolderFiller::addNotifications() {
// const auto feed = _feed;
// _addAction(lang(lng_feed_notifications), [=] {
// Info::FeedProfile::NotificationsController::Start(feed);
// });
//}
//
//void FolderFiller::addSearch() {
// const auto feed = _feed;
// _addAction(lang(lng_profile_search_messages), [=] {
// App::main()->searchInChat(feed);
// });
//}
//
//void FolderFiller::addUngroup() {
// const auto feed = _feed;
// //_addAction(lang(lng_feed_ungroup_all), [=] { // #feed
// // PeerMenuUngroupFeed(feed);
// //});
//}
} // namespace } // namespace
@ -807,12 +807,12 @@ void FillPeerMenu(
filler.fill(); filler.fill();
} }
void FillFeedMenu( void FillFolderMenu(
not_null<Controller*> controller, not_null<Controller*> controller,
not_null<Data::Feed*> feed, not_null<Data::Folder*> folder,
const PeerMenuCallback &callback, const PeerMenuCallback &callback,
PeerMenuSource source) { PeerMenuSource source) {
FeedFiller filler(controller, feed, callback, source); FolderFiller filler(controller, folder, callback, source);
filler.fill(); filler.fill();
} }

View file

@ -12,7 +12,7 @@ class RpWidget;
} // namespace Ui } // namespace Ui
namespace Data { namespace Data {
class Feed; class Folder;
} // namespace Data } // namespace Data
namespace Window { namespace Window {
@ -34,9 +34,9 @@ void FillPeerMenu(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const PeerMenuCallback &addAction, const PeerMenuCallback &addAction,
PeerMenuSource source); PeerMenuSource source);
void FillFeedMenu( void FillFolderMenu(
not_null<Controller*> controller, not_null<Controller*> controller,
not_null<Data::Feed*> feed, not_null<Data::Folder*> folder,
const PeerMenuCallback &addAction, const PeerMenuCallback &addAction,
PeerMenuSource source); PeerMenuSource source);

View file

@ -172,10 +172,10 @@
<(src_loc)/data/data_document_good_thumbnail.h <(src_loc)/data/data_document_good_thumbnail.h
<(src_loc)/data/data_drafts.cpp <(src_loc)/data/data_drafts.cpp
<(src_loc)/data/data_drafts.h <(src_loc)/data/data_drafts.h
<(src_loc)/data/data_feed.cpp <(src_loc)/data/data_folder.cpp
<(src_loc)/data/data_feed.h <(src_loc)/data/data_folder.h
<(src_loc)/data/data_feed_messages.cpp //<(src_loc)/data/data_feed_messages.cpp
<(src_loc)/data/data_feed_messages.h //<(src_loc)/data/data_feed_messages.h
<(src_loc)/data/data_file_origin.cpp <(src_loc)/data/data_file_origin.cpp
<(src_loc)/data/data_file_origin.h <(src_loc)/data/data_file_origin.h
<(src_loc)/data/data_flags.h <(src_loc)/data/data_flags.h
@ -252,8 +252,8 @@
<(src_loc)/history/admin_log/history_admin_log_item.h <(src_loc)/history/admin_log/history_admin_log_item.h
<(src_loc)/history/admin_log/history_admin_log_section.cpp <(src_loc)/history/admin_log/history_admin_log_section.cpp
<(src_loc)/history/admin_log/history_admin_log_section.h <(src_loc)/history/admin_log/history_admin_log_section.h
<(src_loc)/history/feed/history_feed_section.cpp //<(src_loc)/history/feed/history_feed_section.cpp
<(src_loc)/history/feed/history_feed_section.h //<(src_loc)/history/feed/history_feed_section.h
<(src_loc)/history/media/history_media.h <(src_loc)/history/media/history_media.h
<(src_loc)/history/media/history_media.cpp <(src_loc)/history/media/history_media.cpp
<(src_loc)/history/media/history_media_call.h <(src_loc)/history/media/history_media_call.h
@ -337,22 +337,22 @@
<(src_loc)/info/info_top_bar.h <(src_loc)/info/info_top_bar.h
<(src_loc)/info/info_wrap_widget.cpp <(src_loc)/info/info_wrap_widget.cpp
<(src_loc)/info/info_wrap_widget.h <(src_loc)/info/info_wrap_widget.h
<(src_loc)/info/channels/info_channels_widget.cpp //<(src_loc)/info/channels/info_channels_widget.cpp
<(src_loc)/info/channels/info_channels_widget.h //<(src_loc)/info/channels/info_channels_widget.h
<(src_loc)/info/common_groups/info_common_groups_inner_widget.cpp <(src_loc)/info/common_groups/info_common_groups_inner_widget.cpp
<(src_loc)/info/common_groups/info_common_groups_inner_widget.h <(src_loc)/info/common_groups/info_common_groups_inner_widget.h
<(src_loc)/info/common_groups/info_common_groups_widget.cpp <(src_loc)/info/common_groups/info_common_groups_widget.cpp
<(src_loc)/info/common_groups/info_common_groups_widget.h <(src_loc)/info/common_groups/info_common_groups_widget.h
<(src_loc)/info/feed/info_feed_channels.cpp //<(src_loc)/info/feed/info_feed_channels.cpp
<(src_loc)/info/feed/info_feed_channels.h //<(src_loc)/info/feed/info_feed_channels.h
<(src_loc)/info/feed/info_feed_channels_controllers.cpp //<(src_loc)/info/feed/info_feed_channels_controllers.cpp
<(src_loc)/info/feed/info_feed_channels_controllers.h //<(src_loc)/info/feed/info_feed_channels_controllers.h
<(src_loc)/info/feed/info_feed_cover.cpp //<(src_loc)/info/feed/info_feed_cover.cpp
<(src_loc)/info/feed/info_feed_cover.h //<(src_loc)/info/feed/info_feed_cover.h
<(src_loc)/info/feed/info_feed_profile_inner_widget.cpp //<(src_loc)/info/feed/info_feed_profile_inner_widget.cpp
<(src_loc)/info/feed/info_feed_profile_inner_widget.h //<(src_loc)/info/feed/info_feed_profile_inner_widget.h
<(src_loc)/info/feed/info_feed_profile_widget.cpp //<(src_loc)/info/feed/info_feed_profile_widget.cpp
<(src_loc)/info/feed/info_feed_profile_widget.h //<(src_loc)/info/feed/info_feed_profile_widget.h
<(src_loc)/info/media/info_media_buttons.h <(src_loc)/info/media/info_media_buttons.h
<(src_loc)/info/media/info_media_empty_widget.cpp <(src_loc)/info/media/info_media_empty_widget.cpp
<(src_loc)/info/media/info_media_empty_widget.h <(src_loc)/info/media/info_media_empty_widget.h
@ -656,8 +656,8 @@
<(src_loc)/storage/serialize_document.h <(src_loc)/storage/serialize_document.h
<(src_loc)/storage/storage_facade.cpp <(src_loc)/storage/storage_facade.cpp
<(src_loc)/storage/storage_facade.h <(src_loc)/storage/storage_facade.h
<(src_loc)/storage/storage_feed_messages.cpp //<(src_loc)/storage/storage_feed_messages.cpp
<(src_loc)/storage/storage_feed_messages.h //<(src_loc)/storage/storage_feed_messages.h
<(src_loc)/storage/storage_media_prepare.cpp <(src_loc)/storage/storage_media_prepare.cpp
<(src_loc)/storage/storage_media_prepare.h <(src_loc)/storage/storage_media_prepare.h
<(src_loc)/storage/storage_shared_media.cpp <(src_loc)/storage/storage_shared_media.cpp