diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 650ac53fb..11172e889 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_photo.h" #include "data/data_web_page.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_sparse_ids.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_message.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 "auth_session.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_user_photos.h" #include "storage/storage_media_prepare.h" -#include "storage/storage_feed_messages.h" +//#include "storage/storage_feed_messages.h" // #feed namespace { @@ -82,10 +82,10 @@ constexpr auto kUnreadMentionsPreloadIfLess = 5; constexpr auto kUnreadMentionsFirstRequestLimit = 10; constexpr auto kUnreadMentionsNextRequestLimit = 100; constexpr auto kSharedMediaLimit = 100; -constexpr auto kFeedMessagesLimit = 50; +//constexpr auto kFeedMessagesLimit = 50; // #feed constexpr auto kReadFeaturedSetsTimeout = crl::time(1000); 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 kNotifySettingSaveTimeout = crl::time(1000); @@ -190,7 +190,7 @@ ApiWrap::ApiWrap(not_null session) , _draftsSaveTimer([=] { saveDraftsToCloud(); }) , _featuredSetsReadTimer([=] { readFeaturedSets(); }) , _fileLoader(std::make_unique(kFileLoaderQueueStopTimeout)) -, _feedReadTimer([=] { readFeeds(); }) +//, _feedReadTimer([=] { readFeeds(); }) // #feed , _proxyPromotionTimer([=] { refreshProxyPromotion(); }) , _updateNotifySettingsTimer([=] { sendNotifySettingsUpdates(); }) { crl::on_main([=] { @@ -421,8 +421,8 @@ void ApiWrap::savePinnedOrder() { for (const auto &pinned : ranges::view::reverse(order)) { if (const auto history = pinned.history()) { peers.push_back(MTP_inputDialogPeer(history->peer->input)); - } else if (const auto feed = pinned.feed()) { -// peers.push_back(MTP_inputDialogPeerFeed(MTP_int(feed->id()))); // #feed +// } else if (const auto feed = pinned.feed()) { // #feed +// peers.push_back(MTP_inputDialogPeerFeed(MTP_int(feed->id()))); } } const auto folderId = 0; @@ -686,23 +686,23 @@ void ApiWrap::requestContacts() { }).send(); } -void ApiWrap::requestDialogEntry(not_null feed) { - if (_dialogFeedRequests.contains(feed)) { +void ApiWrap::requestDialogEntry(not_null folder) { + if (_dialogFolderRequests.contains(folder)) { return; } - _dialogFeedRequests.emplace(feed); + _dialogFolderRequests.emplace(folder); - //auto peers = QVector( // #feed - // 1, - // MTP_inputDialogPeerFeed(MTP_int(feed->id()))); - //request(MTPmessages_GetPeerDialogs( - // MTP_vector(std::move(peers)) - //)).done([=](const MTPmessages_PeerDialogs &result) { - // applyPeerDialogs(result); - // _dialogFeedRequests.remove(feed); - //}).fail([=](const RPCError &error) { - // _dialogFeedRequests.remove(feed); - //}).send(); + auto peers = QVector( + 1, + MTP_inputDialogPeerFolder(MTP_int(folder->id()))); + request(MTPmessages_GetPeerDialogs( + MTP_vector(std::move(peers)) + )).done([=](const MTPmessages_PeerDialogs &result) { + applyPeerDialogs(result); + _dialogFolderRequests.remove(folder); + }).fail([=](const RPCError &error) { + _dialogFolderRequests.remove(folder); + }).send(); } //void ApiWrap::requestFeedDialogsEntries(not_null feed) { @@ -813,63 +813,56 @@ void ApiWrap::applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs) { _session->data().processChats(data.vchats); App::feedMsgs(data.vmessages, NewMessageLast); for (const auto &dialog : data.vdialogs.v) { - switch (dialog.type()) { - case mtpc_dialog: { - const auto &fields = dialog.c_dialog(); - if (const auto peerId = peerFromMTP(fields.vpeer)) { - _session->data().history(peerId)->applyDialog(fields); + dialog.match([&](const MTPDdialog &data) { + if (const auto peerId = peerFromMTP(data.vpeer)) { + _session->data().history(peerId)->applyDialog(data); } - } break; - - //case mtpc_dialogFeed: { // #feed - // const auto &fields = dialog.c_dialogFeed(); - // const auto feed = _session->data().feed(fields.vfeed_id.v); - // feed->applyDialog(fields); - //} break; - } + }, [&](const MTPDdialogFolder &data) { // #TODO archive + //const auto folder = _session->data().processFolder(data.vfolder); + //folder->applyDialog(data); + }); } _session->data().sendHistoryChangeNotifications(); } - -void ApiWrap::applyFeedDialogs( - not_null feed, - const MTPmessages_Dialogs &dialogs) { - if (dialogs.type() == mtpc_messages_dialogsNotModified) { - LOG(("API Error: " - "messages.dialogsNotModified in ApiWrap::applyFeedDialogs.")); - return; - } - // #TODO folders - auto channels = std::vector>(); - dialogs.match([&](const MTPDmessages_dialogsNotModified &) { - Unexpected("Type in ApiWrap::applyFeedDialogs."); - }, [&](const auto &data) { - _session->data().processUsers(data.vusers); - _session->data().processChats(data.vchats); - App::feedMsgs(data.vmessages.v, NewMessageLast); - channels.reserve(data.vdialogs.v.size()); - for (const auto &dialog : data.vdialogs.v) { - dialog.match([&](const MTPDdialog &data) { - if (const auto peerId = peerFromMTP(data.vpeer)) { - if (peerIsChannel(peerId)) { - const auto history = _session->data().history(peerId); - history->applyDialog(dialog.c_dialog()); - channels.emplace_back(history->peer->asChannel()); - } else { - LOG(("API Error: " - "Unexpected peer in folder dialogs list.")); - } - } - }, [&](const MTPDdialogFolder &data) { - LOG(("API Error: " - "Unexpected dialogFolder in folder dialogs list.")); - }); - } - }); - - feed->setChannels(channels); - _session->data().sendHistoryChangeNotifications(); -} +// // #feed +//void ApiWrap::applyFeedDialogs( +// not_null feed, +// const MTPmessages_Dialogs &dialogs) { +// if (dialogs.type() == mtpc_messages_dialogsNotModified) { +// LOG(("API Error: " +// "messages.dialogsNotModified in ApiWrap::applyFeedDialogs.")); +// return; +// } +// auto channels = std::vector>(); +// dialogs.match([&](const MTPDmessages_dialogsNotModified &) { +// Unexpected("Type in ApiWrap::applyFeedDialogs."); +// }, [&](const auto &data) { +// _session->data().processUsers(data.vusers); +// _session->data().processChats(data.vchats); +// App::feedMsgs(data.vmessages.v, NewMessageLast); +// channels.reserve(data.vdialogs.v.size()); +// for (const auto &dialog : data.vdialogs.v) { +// dialog.match([&](const MTPDdialog &data) { +// if (const auto peerId = peerFromMTP(data.vpeer)) { +// if (peerIsChannel(peerId)) { // #TODO archive +// const auto history = _session->data().history(peerId); +// history->applyDialog(data); +// channels.emplace_back(history->peer->asChannel()); +// } else { +// LOG(("API Error: " +// "Unexpected peer in folder dialogs list.")); +// } +// } +// }, [&](const MTPDdialogFolder &data) { +// LOG(("API Error: " +// "Unexpected dialogFolder in folder dialogs list.")); +// }); +// } +// }); +// +// feed->setChannels(channels); +// _session->data().sendHistoryChangeNotifications(); +//} void ApiWrap::changeDialogUnreadMark( not_null history, @@ -1539,8 +1532,7 @@ void ApiWrap::applyLastParticipantsList( channel->mgInfo->creator = user; if (!channel->mgInfo->admins.empty() && !channel->mgInfo->admins.contains(userId)) { - Data::ChannelAdminChanges changes(channel); - changes.feed(userId, true); + Data::ChannelAdminChanges(channel).feed(userId, true); } } 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) { if (const auto peer = chat.peer()) { jumpToHistoryDate(peer, date); - } else if (const auto feed = chat.feed()) { - jumpToFeedDate(feed, date); + //} else if (const auto feed = chat.feed()) { // #feed + // jumpToFeedDate(feed, date); } } @@ -3746,64 +3738,64 @@ void ApiWrap::jumpToHistoryDate(not_null peer, const QDate &date) { jumpToDateInPeer(); } } - -template -void ApiWrap::requestMessageAfterDate( - not_null feed, - const QDate &date, - Callback &&callback) { - const auto offsetId = 0; - const auto offsetDate = static_cast(QDateTime(date).toTime_t()); - const auto addOffset = -2; - const auto limit = 1; - const auto hash = 0; - //request(MTPchannels_GetFeed( // #feed - // MTP_flags(MTPchannels_GetFeed::Flag::f_offset_position), - // MTP_int(feed->id()), - // MTP_feedPosition( - // MTP_int(offsetDate), - // MTP_peerUser(MTP_int(_session->userId())), - // MTP_int(0)), - // MTP_int(addOffset), - // MTP_int(limit), - // MTPfeedPosition(), // max_id - // MTPfeedPosition(), // min_id - // MTP_int(hash) - //)).done([ - // =, - // callback = std::forward(callback) - //](const MTPmessages_FeedMessages &result) { - // if (result.type() == mtpc_messages_feedMessagesNotModified) { - // LOG(("API Error: " - // "Unexpected messages.feedMessagesNotModified.")); - // callback(Data::UnreadMessagePosition); - // return; - // } - // Assert(result.type() == mtpc_messages_feedMessages); - // const auto &data = result.c_messages_feedMessages(); - // const auto &messages = data.vmessages.v; - // const auto type = NewMessageExisting; - // _session->data().processUsers(data.vusers); - // _session->data().processChats(data.vchats); - // for (const auto &msg : messages) { - // if (const auto item = _session->data().addNewMessage(msg, type)) { - // if (item->date() >= offsetDate || true) { - // callback(item->position()); - // return; - // } - // } - // } - // callback(Data::UnreadMessagePosition); - //}).send(); -} - -void ApiWrap::jumpToFeedDate(not_null feed, const QDate &date) { - requestMessageAfterDate(feed, date, [=](Data::MessagePosition result) { - Ui::hideLayer(); - App::wnd()->controller()->showSection( - HistoryFeed::Memento(feed, result)); - }); -} +// // #feed +//template +//void ApiWrap::requestMessageAfterDate( +// not_null feed, +// const QDate &date, +// Callback &&callback) { +// const auto offsetId = 0; +// const auto offsetDate = static_cast(QDateTime(date).toTime_t()); +// const auto addOffset = -2; +// const auto limit = 1; +// const auto hash = 0; +// request(MTPchannels_GetFeed( +// MTP_flags(MTPchannels_GetFeed::Flag::f_offset_position), +// MTP_int(feed->id()), +// MTP_feedPosition( +// MTP_int(offsetDate), +// MTP_peerUser(MTP_int(_session->userId())), +// MTP_int(0)), +// MTP_int(addOffset), +// MTP_int(limit), +// MTPfeedPosition(), // max_id +// MTPfeedPosition(), // min_id +// MTP_int(hash) +// )).done([ +// =, +// callback = std::forward(callback) +// ](const MTPmessages_FeedMessages &result) { +// if (result.type() == mtpc_messages_feedMessagesNotModified) { +// LOG(("API Error: " +// "Unexpected messages.feedMessagesNotModified.")); +// callback(Data::UnreadMessagePosition); +// return; +// } +// Assert(result.type() == mtpc_messages_feedMessages); +// const auto &data = result.c_messages_feedMessages(); +// const auto &messages = data.vmessages.v; +// const auto type = NewMessageExisting; +// _session->data().processUsers(data.vusers); +// _session->data().processChats(data.vchats); +// for (const auto &msg : messages) { +// if (const auto item = _session->data().addNewMessage(msg, type)) { +// if (item->date() >= offsetDate || true) { +// callback(item->position()); +// return; +// } +// } +// } +// callback(Data::UnreadMessagePosition); +// }).send(); +//} +// +//void ApiWrap::jumpToFeedDate(not_null feed, const QDate &date) { +// requestMessageAfterDate(feed, date, [=](Data::MessagePosition result) { +// Ui::hideLayer(); +// App::wnd()->controller()->showSection( +// HistoryFeed::Memento(feed, result)); +// }); +//} void ApiWrap::preloadEnoughUnreadMentions(not_null history) { auto fullCount = history->getUnreadMentionsCount(); @@ -5849,59 +5841,59 @@ void ApiWrap::readServerHistoryForce(not_null history) { sendReadRequest(peer, upTo); } } - -void ApiWrap::readFeed( - not_null feed, - Data::MessagePosition position) { - const auto already = feed->unreadPosition(); - if (already && already >= position) { - return; - } - feed->setUnreadPosition(position); - if (!_feedReadsDelayed.contains(feed)) { - if (_feedReadsDelayed.empty()) { - _feedReadTimer.callOnce(kFeedReadTimeout); - } - _feedReadsDelayed.emplace(feed, crl::now() + kFeedReadTimeout); - } -} - -void ApiWrap::readFeeds() { - auto delay = kFeedReadTimeout; - const auto now = crl::now(); - //for (auto i = begin(_feedReadsDelayed); i != end(_feedReadsDelayed);) { // #feed - // const auto feed = i->first; - // const auto time = i->second; - // // Clang fails to capture structure-binded feed to lambda :( - // //const auto [feed, time] = *i; - // if (time > now) { - // accumulate_min(delay, time - now); - // ++i; - // } else if (_feedReadRequests.contains(feed)) { - // ++i; - // } else { - // const auto position = feed->unreadPosition(); - // const auto requestId = request(MTPchannels_ReadFeed( - // MTP_int(feed->id()), - // MTP_feedPosition( - // MTP_int(position.date), - // MTP_peerChannel(MTP_int(position.fullId.channel)), - // MTP_int(position.fullId.msg)) - // )).done([=](const MTPUpdates &result) { - // applyUpdates(result); - // _feedReadRequests.remove(feed); - // }).fail([=](const RPCError &error) { - // _feedReadRequests.remove(feed); - // }).send(); - // _feedReadRequests.emplace(feed, requestId); - - // i = _feedReadsDelayed.erase(i); - // } - //} - //if (!_feedReadsDelayed.empty()) { - // _feedReadTimer.callOnce(delay); - //} -} +// // #feed +//void ApiWrap::readFeed( +// not_null feed, +// Data::MessagePosition position) { +// const auto already = feed->unreadPosition(); +// if (already && already >= position) { +// return; +// } +// feed->setUnreadPosition(position); +// if (!_feedReadsDelayed.contains(feed)) { +// if (_feedReadsDelayed.empty()) { +// _feedReadTimer.callOnce(kFeedReadTimeout); +// } +// _feedReadsDelayed.emplace(feed, crl::now() + kFeedReadTimeout); +// } +//} +// +//void ApiWrap::readFeeds() { +// auto delay = kFeedReadTimeout; +// const auto now = crl::now(); +// for (auto i = begin(_feedReadsDelayed); i != end(_feedReadsDelayed);) { +// const auto feed = i->first; +// const auto time = i->second; +// // Clang fails to capture structure-binded feed to lambda :( +// //const auto [feed, time] = *i; +// if (time > now) { +// accumulate_min(delay, time - now); +// ++i; +// } else if (_feedReadRequests.contains(feed)) { +// ++i; +// } else { +// const auto position = feed->unreadPosition(); +// const auto requestId = request(MTPchannels_ReadFeed( +// MTP_int(feed->id()), +// MTP_feedPosition( +// MTP_int(position.date), +// MTP_peerChannel(MTP_int(position.fullId.channel)), +// MTP_int(position.fullId.msg)) +// )).done([=](const MTPUpdates &result) { +// applyUpdates(result); +// _feedReadRequests.remove(feed); +// }).fail([=](const RPCError &error) { +// _feedReadRequests.remove(feed); +// }).send(); +// _feedReadRequests.emplace(feed, requestId); +// +// i = _feedReadsDelayed.erase(i); +// } +// } +// if (!_feedReadsDelayed.empty()) { +// _feedReadTimer.callOnce(delay); +// } +//} void ApiWrap::sendReadRequest(not_null peer, MsgId upTo) { const auto requestId = [&] { diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index b1d4f32ef..78e7c63ad 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -79,8 +79,8 @@ public: QString exportDirectMessageLink(not_null item); void requestContacts(); - void requestDialogEntry(not_null feed); - //void requestFeedDialogsEntries(not_null feed); + void requestDialogEntry(not_null folder); + //void requestFeedDialogsEntries(not_null feed); // #feed void requestDialogEntry( not_null history, Fn callback = nullptr); @@ -309,9 +309,9 @@ public: void shareContact(not_null user, const SendOptions &options); void readServerHistory(not_null history); void readServerHistoryForce(not_null history); - void readFeed( - not_null feed, - Data::MessagePosition position); + //void readFeed( // #feed + // not_null feed, + // Data::MessagePosition position); void sendVoiceMessage( QByteArray result, @@ -462,9 +462,9 @@ private: QVector collectMessageIds(const MessageDataRequests &requests); MessageDataRequests *messageDataRequests(ChannelData *channel, bool onlyExisting = false); void applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs); - void applyFeedDialogs( - not_null feed, - const MTPmessages_Dialogs &dialogs); + //void applyFeedDialogs( // #feed + // not_null feed, + // const MTPmessages_Dialogs &dialogs); void gotChatFull( not_null peer, @@ -522,17 +522,17 @@ private: const QVector &participants); void jumpToHistoryDate(not_null peer, const QDate &date); - void jumpToFeedDate(not_null feed, const QDate &date); + //void jumpToFeedDate(not_null feed, const QDate &date); // #feed template void requestMessageAfterDate( not_null peer, const QDate &date, Callback &&callback); - template - void requestMessageAfterDate( - not_null feed, - const QDate &date, - Callback &&callback); + //template // #feed + //void requestMessageAfterDate( + // not_null feed, + // const QDate &date, + // Callback &&callback); void sharedMediaDone( not_null peer, @@ -601,7 +601,7 @@ private: uint64 randomId); FileLoadTo fileLoadTaskOptions(const SendOptions &options) const; - void readFeeds(); + //void readFeeds(); // #feed void getProxyPromotionDelayed(TimeId now, TimeId next); void proxyPromotionDone(const MTPhelp_ProxyData &proxy); @@ -701,7 +701,7 @@ private: mtpRequestId _contactsRequestId = 0; mtpRequestId _contactsStatusesRequestId = 0; - base::flat_set> _dialogFeedRequests; + base::flat_set> _dialogFolderRequests; base::flat_map< not_null, std::vector>> _dialogRequests; @@ -720,19 +720,19 @@ private: base::flat_map, mtpRequestId> _userPhotosRequests; - base::flat_set> _feedChannelsGetRequests; - base::flat_map< - not_null, - mtpRequestId> _feedChannelsSetRequests; - base::flat_set, - Data::MessagePosition, - SliceType>> _feedMessagesRequests; - base::flat_set, - Data::MessagePosition, - SliceType>> _feedMessagesRequestsPending; - mtpRequestId _saveDefaultFeedIdRequest = 0; + //base::flat_set> _feedChannelsGetRequests; // #feed + //base::flat_map< + // not_null, + // mtpRequestId> _feedChannelsSetRequests; + //base::flat_set, + // Data::MessagePosition, + // SliceType>> _feedMessagesRequests; + //base::flat_set, + // Data::MessagePosition, + // SliceType>> _feedMessagesRequestsPending; + //mtpRequestId _saveDefaultFeedIdRequest = 0; rpl::event_stream _sendActions; @@ -755,9 +755,10 @@ private: rpl::event_stream _stickerSetInstalled; - base::flat_map, crl::time> _feedReadsDelayed; - base::flat_map, mtpRequestId> _feedReadRequests; - base::Timer _feedReadTimer; + // #feed + //base::flat_map, crl::time> _feedReadsDelayed; + //base::flat_map, mtpRequestId> _feedReadRequests; + //base::Timer _feedReadTimer; mtpRequestId _proxyPromotionRequestId = 0; std::pair _proxyPromotionKey; diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 23192a786..e53dc3a36 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "data/data_chat.h" #include "data/data_session.h" -#include "data/data_feed.h" +#include "data/data_folder.h" #include "observer_peer.h" #include "auth_session.h" #include "apiwrap.h" @@ -306,27 +306,27 @@ void ChannelData::setAvailableMinId(MsgId availableMinId) { } } } - -void ChannelData::setFeed(not_null feed) { - setFeedPointer(feed); -} - -void ChannelData::clearFeed() { - setFeedPointer(nullptr); -} - -void ChannelData::setFeedPointer(Data::Feed *feed) { - if (_feed != feed) { - const auto was = _feed; - _feed = feed; - if (was) { - was->unregisterOne(this); - } - if (_feed) { - _feed->registerOne(this); - } - } -} +// #TODO archive +//void ChannelData::setFeed(not_null feed) { +// setFeedPointer(feed); +//} +// +//void ChannelData::clearFeed() { +// setFeedPointer(nullptr); +//} +// +//void ChannelData::setFeedPointer(Data::Feed *feed) { +// if (_feed != feed) { +// const auto was = _feed; +// _feed = feed; +// if (was) { +// was->unregisterOne(this); +// } +// if (_feed) { +// _feed->registerOne(this); +// } +// } +//} bool ChannelData::canBanMembers() const { return amCreator() diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index 452b96a11..748f5cbce 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -327,13 +327,6 @@ public: } void setAvailableMinId(MsgId availableMinId); - void setFeed(not_null feed); - void clearFeed(); - - Data::Feed *feed() const { - return _feed; - } - enum class UpdateStatus { Good, TooOld, @@ -365,7 +358,6 @@ public: private: bool canEditLastAdmin(not_null user) const; - void setFeedPointer(Data::Feed *feed); Flags _flags = Flags(MTPDchannel_ClientFlag::f_forbidden | 0); FullFlags _fullFlags; @@ -387,7 +379,6 @@ private: QString _unavailableReason; QString _inviteLink; - Data::Feed *_feed = nullptr; rpl::lifetime _lifetime; diff --git a/Telegram/SourceFiles/data/data_feed.cpp b/Telegram/SourceFiles/data/data_folder.cpp similarity index 64% rename from Telegram/SourceFiles/data/data_feed.cpp rename to Telegram/SourceFiles/data/data_folder.cpp index a7995d7fa..f724eceff 100644 --- a/Telegram/SourceFiles/data/data_feed.cpp +++ b/Telegram/SourceFiles/data/data_folder.cpp @@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ -#include "data/data_feed.h" +#include "data/data_folder.h" #include "data/data_session.h" #include "data/data_channel.h" @@ -14,7 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "lang/lang_keys.h" #include "storage/storage_facade.h" -#include "storage/storage_feed_messages.h" +//#include "storage/storage_feed_messages.h" // #feed #include "auth_session.h" #include "apiwrap.h" #include "mainwidget.h" @@ -31,7 +31,7 @@ namespace Data { // data.vid.v)); //} -Feed::Feed(not_null owner, FeedId id) +Folder::Folder(not_null owner, FolderId id) : Entry(this) , _id(id) , _owner(owner) @@ -39,19 +39,19 @@ Feed::Feed(not_null owner, FeedId id) indexNameParts(); } -Data::Session &Feed::owner() const { +Data::Session &Folder::owner() const { return *_owner; } -AuthSession &Feed::session() const { +AuthSession &Folder::session() const { return _owner->session(); } -FeedId Feed::id() const { +FolderId Folder::id() const { return _id; } -void Feed::indexNameParts() { +void Folder::indexNameParts() { _nameWords.clear(); _nameFirstLetters.clear(); auto toIndexList = QStringList(); @@ -77,13 +77,13 @@ void Feed::indexNameParts() { } } -void Feed::registerOne(not_null channel) { - const auto history = owner().history(channel); - if (!base::contains(_channels, history)) { - const auto invisible = (_channels.size() < 2); - _channels.push_back(history); - session().storage().invalidate( - Storage::FeedMessagesInvalidate(_id)); +void Folder::registerOne(not_null peer) { + const auto history = owner().history(peer); + if (!base::contains(_chats, history)) { + const auto invisible = empty(_chats); + _chats.push_back(history); + //session().storage().invalidate( // #feed + // Storage::FeedMessagesInvalidate(_id)); if (history->chatListMessageKnown()) { if (const auto last = history->chatListMessage()) { @@ -103,30 +103,30 @@ void Feed::registerOne(not_null channel) { if (const auto count = history->unreadCount()) { unreadCountChanged(count, history->mute() ? count : 0); } - } else if (!_settingChannels) { + } else if (!_settingChats) { session().api().requestDialogEntry(this); } } - if (invisible && _channels.size() > 1) { + if (invisible && !empty(_chats)) { updateChatListExistence(); - for (const auto history : _channels) { + for (const auto history : _chats) { history->updateChatListExistence(); } } else { history->updateChatListExistence(); } - _owner->notifyFeedUpdated(this, FeedUpdateFlag::Channels); + _owner->notifyFolderUpdated(this, FolderUpdateFlag::List); } } -void Feed::unregisterOne(not_null channel) { - const auto history = owner().history(channel); - const auto i = ranges::remove(_channels, history); - if (i != end(_channels)) { - const auto visible = (_channels.size() > 1); - _channels.erase(i, end(_channels)); - session().storage().remove( - Storage::FeedMessagesRemoveAll(_id, channel->bareId())); +void Folder::unregisterOne(not_null peer) { + const auto history = owner().history(peer); + const auto i = ranges::remove(_chats, history); + if (i != end(_chats)) { + const auto visible = !empty(_chats); + _chats.erase(i, end(_chats)); + //session().storage().remove( // #feed + // Storage::FeedMessagesRemoveAll(_id, channel->bareId())); if (chatListMessageKnown()) { if (const auto last = chatListMessage()) { @@ -144,19 +144,19 @@ void Feed::unregisterOne(not_null channel) { session().api().requestDialogEntry(this); } } - if (visible && _channels.size() < 2) { + if (visible && empty(_chats)) { updateChatListExistence(); - for (const auto history : _channels) { + for (const auto history : _chats) { history->updateChatListExistence(); } } else { history->updateChatListExistence(); } - _owner->notifyFeedUpdated(this, FeedUpdateFlag::Channels); + _owner->notifyFolderUpdated(this, FolderUpdateFlag::List); } } -void Feed::updateChatListMessage(not_null item) { +void Folder::updateChatListMessage(not_null item) { if (justUpdateChatListMessage(item)) { if (_chatListMessage && *_chatListMessage) { setChatListTimeId((*_chatListMessage)->date()); @@ -164,108 +164,108 @@ void Feed::updateChatListMessage(not_null item) { } } -void Feed::loadUserpic() { - constexpr auto kPaintUserpicsCount = 4; - auto load = kPaintUserpicsCount; - for (const auto channel : _channels) { - channel->peer->loadUserpic(); - if (!--load) { - break; - } - } +void Folder::loadUserpic() { + //constexpr auto kPaintUserpicsCount = 4; // #feed + //auto load = kPaintUserpicsCount; + //for (const auto history : _chats) { + // history->peer->loadUserpic(); + // if (!--load) { + // break; + // } + //} } -void Feed::paintUserpic( +void Folder::paintUserpic( Painter &p, int x, int y, int size) const { - const auto small = (size - st::lineWidth) / 2; - const auto delta = size - small; - auto index = 0; - for (const auto channel : _channels) { - channel->peer->paintUserpic(p, x, y, small); - switch (++index) { - case 1: - case 3: x += delta; break; - case 2: x -= delta; y += delta; break; - case 4: return; - } - } + //const auto small = (size - st::lineWidth) / 2; // #feed + //const auto delta = size - small; + //auto index = 0; + //for (const auto history : _chats) { + // history->peer->paintUserpic(p, x, y, small); + // switch (++index) { + // case 1: + // case 3: x += delta; break; + // case 2: x -= delta; y += delta; break; + // case 4: return; + // } + //} } -const std::vector> &Feed::channels() const { - return _channels; +const std::vector> &Folder::chats() const { + return _chats; } -int32 Feed::channelsHash() const { +int32 Folder::chatsHash() const { const auto ordered = ranges::view::all( - _channels + _chats ) | ranges::view::transform([](not_null history) { return history->peer->bareId(); }) | ranges::to_vector | ranges::action::sort; return Api::CountHash(ordered); } -bool Feed::channelsLoaded() const { - return _channelsLoaded; +bool Folder::chatsLoaded() const { + return _chatsLoaded; } -void Feed::setChannelsLoaded(bool loaded) { - if (_channelsLoaded != loaded) { - _channelsLoaded = loaded; - _owner->notifyFeedUpdated(this, FeedUpdateFlag::Channels); +void Folder::setChatsLoaded(bool loaded) { + if (_chatsLoaded != loaded) { + _chatsLoaded = loaded; + _owner->notifyFolderUpdated(this, FolderUpdateFlag::List); } } -void Feed::setChannels(std::vector> channels) { +void Folder::setChats(std::vector> chats) { const auto remove = ranges::view::all( - _channels + _chats ) | ranges::view::transform([](not_null history) { - return not_null(history->peer->asChannel()); - }) | ranges::view::filter([&](not_null channel) { - return !base::contains(channels, channel); + return history->peer; + }) | ranges::view::filter([&](not_null peer) { + return !base::contains(chats, peer); }) | ranges::to_vector; const auto add = ranges::view::all( - channels - ) | ranges::view::filter([&](not_null channel) { + chats + ) | ranges::view::filter([&](not_null peer) { return ranges::find( - _channels, - channel.get(), - [](auto history) { return history->peer->asChannel(); } - ) == end(_channels); - }) | ranges::view::transform([](ChannelData *channel) { - return not_null(channel); + _chats, + peer, + [](auto history) { return history->peer; } + ) == end(_chats); + }) | ranges::view::transform([](PeerData *peer) { + return not_null(peer); }) | ranges::to_vector; - changeChannelsList(add, remove); + changeChatsList(add, remove); - setChannelsLoaded(true); + setChatsLoaded(true); } -void Feed::changeChannelsList( - const std::vector> &add, - const std::vector> &remove) { - _settingChannels = true; - const auto restore = gsl::finally([&] { _settingChannels = false; }); +void Folder::changeChatsList( + const std::vector> &add, + const std::vector> &remove) { + _settingChats = true; + const auto restore = gsl::finally([&] { _settingChats = false; }); - for (const auto channel : remove) { - channel->clearFeed(); - } + //for (const auto channel : remove) { // #TODO archive + // channel->clearFeed(); + //} - // 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. - // After that we restore it. + //// 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. + //// After that we restore it. const auto oldChatListMessage = base::take(_chatListMessage); - for (const auto channel : add) { - _chatListMessage = std::nullopt; - channel->setFeed(this); - } + //for (const auto channel : add) { + // _chatListMessage = std::nullopt; + // channel->setFeed(this); + //} _chatListMessage = oldChatListMessage; } -bool Feed::justUpdateChatListMessage(not_null item) { +bool Folder::justUpdateChatListMessage(not_null item) { if (!_chatListMessage) { return false; } else if (*_chatListMessage @@ -276,13 +276,13 @@ bool Feed::justUpdateChatListMessage(not_null item) { return true; } -void Feed::messageRemoved(not_null item) { +void Folder::messageRemoved(not_null item) { if (chatListMessage() == item) { recountChatListMessage(); } } -void Feed::historyCleared(not_null history) { +void Folder::historyCleared(not_null history) { if (const auto last = chatListMessage()) { if (last->history() == history) { messageRemoved(last); @@ -290,15 +290,15 @@ void Feed::historyCleared(not_null history) { } } -void Feed::requestChatListMessage() { +void Folder::requestChatListMessage() { if (!chatListMessageKnown()) { session().api().requestDialogEntry(this); } } -void Feed::recountChatListMessage() { +void Folder::recountChatListMessage() { _chatListMessage = std::nullopt; - for (const auto history : _channels) { + for (const auto history : _chats) { if (!history->chatListMessageKnown()) { requestChatListMessage(); return; @@ -307,9 +307,9 @@ void Feed::recountChatListMessage() { setChatListMessageFromChannels(); } -void Feed::setChatListMessageFromChannels() { +void Folder::setChatListMessageFromChannels() { _chatListMessage = nullptr; - for (const auto history : _channels) { + for (const auto history : _chats) { if (const auto last = history->chatListMessage()) { justUpdateChatListMessage(last); } @@ -317,27 +317,27 @@ void Feed::setChatListMessageFromChannels() { updateChatListDate(); } -void Feed::updateChatListDate() { +void Folder::updateChatListDate() { if (_chatListMessage && *_chatListMessage) { setChatListTimeId((*_chatListMessage)->date()); } } -int Feed::unreadCount() const { +int Folder::unreadCount() const { return _unreadCount ? *_unreadCount : 0; } -rpl::producer Feed::unreadCountValue() const { +rpl::producer Folder::unreadCountValue() const { return rpl::single( unreadCount() ) | rpl::then(_unreadCountChanges.events()); } -bool Feed::unreadCountKnown() const { +bool Folder::unreadCountKnown() const { return !!_unreadCount; } // #feed -//void Feed::applyDialog(const MTPDdialogFeed &data) { +//void Folder::applyDialog(const MTPDdialogFeed &data) { // const auto addChannel = [&](ChannelId channelId) { // if (const auto channel = owner().channelLoaded(channelId)) { // 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) { return; } @@ -391,7 +391,7 @@ void Feed::changedInChatListHook(Dialogs::Mode list, bool added) { } template -void Feed::updateUnreadCounts(PerformUpdate &&performUpdate) { +void Folder::updateUnreadCounts(PerformUpdate &&performUpdate) { const auto wasUnreadCount = _unreadCount ? *_unreadCount : 0; const auto wasUnreadMutedCount = _unreadMutedCount; 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() && (*_unreadCount == unreadNonMutedCount + 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) { _unreadPosition = position; } } -void Feed::unreadCountChanged(int unreadCountDelta, int mutedCountDelta) { +void Folder::unreadCountChanged(int unreadCountDelta, int mutedCountDelta) { if (!unreadCountKnown()) { return; } @@ -467,55 +467,55 @@ void Feed::unreadCountChanged(int unreadCountDelta, int mutedCountDelta) { }); } -MessagePosition Feed::unreadPosition() const { +MessagePosition Folder::unreadPosition() const { return _unreadPosition.current(); } -rpl::producer Feed::unreadPositionChanges() const { +rpl::producer Folder::unreadPositionChanges() const { return _unreadPosition.changes(); } -bool Feed::toImportant() const { +bool Folder::toImportant() const { return false; // TODO feeds workmode } -bool Feed::useProxyPromotion() const { +bool Folder::useProxyPromotion() const { return false; } -bool Feed::shouldBeInChatList() const { - return _channels.size() > 1; +bool Folder::shouldBeInChatList() const { + return !empty(_chats); } -int Feed::chatListUnreadCount() const { +int Folder::chatListUnreadCount() const { return unreadCount(); } -bool Feed::chatListUnreadMark() const { +bool Folder::chatListUnreadMark() const { return false; // #feed unread mark } -bool Feed::chatListMutedBadge() const { +bool Folder::chatListMutedBadge() const { return _unreadCount ? (*_unreadCount <= _unreadMutedCount) : false; } -HistoryItem *Feed::chatListMessage() const { +HistoryItem *Folder::chatListMessage() const { return _chatListMessage ? *_chatListMessage : nullptr; } -bool Feed::chatListMessageKnown() const { +bool Folder::chatListMessageKnown() const { return _chatListMessage.has_value(); } -const QString &Feed::chatListName() const { +const QString &Folder::chatListName() const { return _name; } -const base::flat_set &Feed::chatListNameWords() const { +const base::flat_set &Folder::chatListNameWords() const { return _nameWords; } -const base::flat_set &Feed::chatListFirstLetters() const { +const base::flat_set &Folder::chatListFirstLetters() const { return _nameFirstLetters; } diff --git a/Telegram/SourceFiles/data/data_feed.h b/Telegram/SourceFiles/data/data_folder.h similarity index 73% rename from Telegram/SourceFiles/data/data_feed.h rename to Telegram/SourceFiles/data/data_folder.h index 5ead5e228..d0df909df 100644 --- a/Telegram/SourceFiles/data/data_feed.h +++ b/Telegram/SourceFiles/data/data_folder.h @@ -16,35 +16,33 @@ class AuthSession; namespace Data { class Session; -class Feed; +class Folder; -enum class FeedUpdateFlag { - Channels, - ChannelPhoto, +enum class FolderUpdateFlag { + List, }; -struct FeedUpdate { - not_null feed; - FeedUpdateFlag flag; +struct FolderUpdate { + not_null folder; + FolderUpdateFlag flag; }; //MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed -class Feed : public Dialogs::Entry { +class Folder : public Dialogs::Entry { public: static constexpr auto kId = 1; - static constexpr auto kChannelsLimit = 1000; - Feed(not_null owner, FeedId id); - Feed(const Feed &) = delete; - Feed &operator=(const Feed &) = delete; + Folder(not_null owner, FolderId id); + Folder(const Folder &) = delete; + Folder &operator=(const Folder &) = delete; Data::Session &owner() const; AuthSession &session() const; - FeedId id() const; - void registerOne(not_null channel); - void unregisterOne(not_null channel); + FolderId id() const; + void registerOne(not_null peer); + void unregisterOne(not_null peer); void updateChatListMessage(not_null item); void messageRemoved(not_null item); @@ -84,11 +82,11 @@ public: int y, int size) const override; - const std::vector> &channels() const; - int32 channelsHash() const; - bool channelsLoaded() const; - void setChannelsLoaded(bool loaded); - void setChannels(std::vector> channels); + const std::vector> &chats() const; + int32 chatsHash() const; + bool chatsLoaded() const; + void setChatsLoaded(bool loaded); + void setChats(std::vector> chats); private: void indexNameParts(); @@ -96,18 +94,18 @@ private: void setChatListMessageFromChannels(); bool justUpdateChatListMessage(not_null item); void updateChatListDate(); - void changeChannelsList( - const std::vector> &add, - const std::vector> &remove); + void changeChatsList( + const std::vector> &add, + const std::vector> &remove); template void updateUnreadCounts(PerformUpdate &&performUpdate); - FeedId _id = 0; + FolderId _id = 0; not_null _owner; - std::vector> _channels; - bool _settingChannels = false; - bool _channelsLoaded = false; + std::vector> _chats; + bool _settingChats = false; + bool _chatsLoaded = false; QString _name; base::flat_set _nameWords; diff --git a/Telegram/SourceFiles/data/data_messages.cpp b/Telegram/SourceFiles/data/data_messages.cpp index 4ace5265c..382143af5 100644 --- a/Telegram/SourceFiles/data/data_messages.cpp +++ b/Telegram/SourceFiles/data/data_messages.cpp @@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ -#include "data/data_feed_messages.h" +#include "data/data_messages.h" namespace Data { diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 84deac793..f0e685930 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -11,7 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat.h" #include "data/data_channel.h" #include "data/data_photo.h" -#include "data/data_feed.h" +#include "data/data_folder.h" #include "data/data_session.h" #include "lang/lang_keys.h" #include "observer_peer.h" @@ -356,13 +356,13 @@ void PeerData::setUserpicChecked( || _userpicLocation != location) { setUserpic(photoId, location, userpic); Notify::peerUpdatedDelayed(this, UpdateFlag::PhotoChanged); - if (const auto channel = asChannel()) { - if (const auto feed = channel->feed()) { - owner().notifyFeedUpdated( - feed, - Data::FeedUpdateFlag::ChannelPhoto); - } - } + //if (const auto channel = asChannel()) { // #feed + // if (const auto feed = channel->feed()) { + // owner().notifyFeedUpdated( + // feed, + // Data::FeedUpdateFlag::ChannelPhoto); + // } + //} } } @@ -576,13 +576,6 @@ not_null PeerData::migrateToOrMe() const { return this; } -Data::Feed *PeerData::feed() const { - if (const auto channel = asChannel()) { - return channel->feed(); - } - return nullptr; -} - const Text &PeerData::dialogName() const { return migrateTo() ? migrateTo()->dialogName() diff --git a/Telegram/SourceFiles/data/data_peer.h b/Telegram/SourceFiles/data/data_peer.h index 1600807ba..c0d01f06a 100644 --- a/Telegram/SourceFiles/data/data_peer.h +++ b/Telegram/SourceFiles/data/data_peer.h @@ -25,7 +25,6 @@ class ChannelData; namespace Data { -class Feed; class Session; int PeerColorIndex(PeerId peerId); @@ -179,7 +178,6 @@ public: [[nodiscard]] ChannelData *migrateTo() const; [[nodiscard]] not_null migrateToOrMe(); [[nodiscard]] not_null migrateToOrMe() const; - [[nodiscard]] Data::Feed *feed() const; void updateFull(); void updateFullForced(); diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index aedb0f35b..c0174beb4 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/themes/window_theme.h" #include "lang/lang_keys.h" // for lang(lng_deleted) in user name. #include "data/data_media_types.h" -#include "data/data_feed.h" +#include "data/data_folder.h" #include "data/data_channel.h" #include "data/data_chat.h" #include "data/data_user.h" @@ -910,7 +910,7 @@ void Session::setupChannelLeavingViewer() { return (channel != nullptr) && !(channel->amIn()); }) | rpl::start_with_next([=](not_null channel) { - channel->clearFeed(); +// channel->clearFeed(); // #feed if (const auto history = historyLoaded(channel->id)) { history->removeJoinedMessage(); history->updateChatListExistence(); @@ -1206,14 +1206,14 @@ rpl::producer> Session::megagroupParticipantAdded( }); } -void Session::notifyFeedUpdated( - not_null feed, - FeedUpdateFlag update) { - _feedUpdates.fire({ feed, update }); +void Session::notifyFolderUpdated( + not_null folder, + FolderUpdateFlag update) { + _folderUpdates.fire({ folder, update }); } -rpl::producer Session::feedUpdated() const { - return _feedUpdates.events(); +rpl::producer Session::folderUpdated() const { + return _folderUpdates.events(); } void Session::notifyStickersUpdated() { @@ -1277,43 +1277,27 @@ void Session::setPinnedDialog(const Dialogs::Key &key, bool pinned) { void Session::applyPinnedDialogs(const QVector &list) { clearPinnedDialogs(); for (auto i = list.size(); i != 0;) { - const auto &dialog = list[--i]; - switch (dialog.type()) { - case mtpc_dialog: { - const auto &dialogData = dialog.c_dialog(); - if (const auto peer = peerFromMTP(dialogData.vpeer)) { + list[--i].match([&](const MTPDdialog &data) { + if (const auto peer = peerFromMTP(data.vpeer)) { setPinnedDialog(history(peer), true); } - } break; - - //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."); - } + }, [&](const MTPDdialogFolder &data) { // #TODO archive + //setPinnedDialog(processFolder(data.vfolder), true); + }); } } void Session::applyPinnedDialogs(const QVector &list) { clearPinnedDialogs(); for (auto i = list.size(); i != 0;) { - const auto &dialogPeer = list[--i]; - switch (dialogPeer.type()) { - case mtpc_dialogPeer: { - const auto &peerData = dialogPeer.c_dialogPeer(); - if (const auto peerId = peerFromMTP(peerData.vpeer)) { + list[--i].match([&](const MTPDdialogPeer &data) { + if (const auto peerId = peerFromMTP(data.vpeer)) { setPinnedDialog(history(peerId), true); } - } break; - //case mtpc_dialogPeerFeed: { // #feed - // const auto &feedData = dialogPeer.c_dialogPeerFeed(); - // const auto feedId = feedData.vfeed_id.v; - // setPinnedDialog(feed(feedId), true); - //} break; - } + }, [&](const MTPDdialogPeerFolder &data) { // #TODO archive + //const auto folderId = data.vfolder_id.v; + //setPinnedDialog(folder(folderId), true); + }); } } @@ -2803,32 +2787,32 @@ void Session::unregisterItemView(not_null view) { } } -not_null Session::feed(FeedId id) { - if (const auto result = feedLoaded(id)) { +not_null Session::folder(FolderId id) { + if (const auto result = folderLoaded(id)) { return result; } - const auto [it, ok] = _feeds.emplace( + const auto [it, ok] = _folders.emplace( id, - std::make_unique(this, id)); + std::make_unique(this, id)); return it->second.get(); } -Feed *Session::feedLoaded(FeedId id) { - const auto it = _feeds.find(id); - return (it == end(_feeds)) ? nullptr : it->second.get(); -} - -void Session::setDefaultFeedId(FeedId id) { - _defaultFeedId = id; -} - -FeedId Session::defaultFeedId() const { - return _defaultFeedId.current(); -} - -rpl::producer Session::defaultFeedIdValue() const { - return _defaultFeedId.value(); +Folder *Session::folderLoaded(FolderId id) { + const auto it = _folders.find(id); + return (it == end(_folders)) ? nullptr : it->second.get(); } +// // #feed +//void Session::setDefaultFeedId(FeedId id) { +// _defaultFeedId = id; +//} +// +//FeedId Session::defaultFeedId() const { +// return _defaultFeedId.current(); +//} +// +//rpl::producer Session::defaultFeedIdValue() const { +// return _defaultFeedId.value(); +//} void Session::requestNotifySettings(not_null peer) { if (peer->notifySettingsUnknown()) { diff --git a/Telegram/SourceFiles/data/data_session.h b/Telegram/SourceFiles/data/data_session.h index 7efc58d11..c3d159b4a 100644 --- a/Telegram/SourceFiles/data/data_session.h +++ b/Telegram/SourceFiles/data/data_session.h @@ -48,9 +48,9 @@ struct SavedCredentials; namespace Data { -class Feed; -enum class FeedUpdateFlag; -struct FeedUpdate; +class Folder; +enum class FolderUpdateFlag; +struct FolderUpdate; class WallPaper; @@ -203,8 +203,8 @@ public: [[nodiscard]] rpl::producer> megagroupParticipantAdded( not_null channel) const; - void notifyFeedUpdated(not_null feed, FeedUpdateFlag update); - [[nodiscard]] rpl::producer feedUpdated() const; + void notifyFolderUpdated(not_null folder, FolderUpdateFlag update); + [[nodiscard]] rpl::producer folderUpdated() const; void notifyStickersUpdated(); [[nodiscard]] rpl::producer<> stickersUpdated() const; @@ -500,11 +500,13 @@ public: void registerItemView(not_null view); void unregisterItemView(not_null view); - not_null feed(FeedId id); - Feed *feedLoaded(FeedId id); - void setDefaultFeedId(FeedId id); - FeedId defaultFeedId() const; - rpl::producer defaultFeedIdValue() const; + [[nodiscard]] not_null folder(FolderId id); + [[nodiscard]] Folder *folderLoaded(FolderId id); + not_null processFolder(const MTPFolder &data); + not_null processFolder(const MTPDfolder &data); + //void setDefaultFeedId(FeedId id); // #feed + //FeedId defaultFeedId() const; + //rpl::producer defaultFeedIdValue() const; void requestNotifySettings(not_null peer); void applyNotifySetting( @@ -644,6 +646,10 @@ private: PhotoData *photo, DocumentData *document); + void folderApplyFields( + not_null folder, + const MTPDfolder &data); + bool stickersUpdateNeeded(crl::time lastUpdate, crl::time now) const { constexpr auto kStickersUpdateTimeout = crl::time(3600'000); return (lastUpdate == 0) @@ -708,7 +714,7 @@ private: rpl::event_stream> _historyChanged; rpl::event_stream _megagroupParticipantRemoved; rpl::event_stream _megagroupParticipantAdded; - rpl::event_stream _feedUpdates; + rpl::event_stream _folderUpdates; rpl::event_stream<> _stickersUpdated; rpl::event_stream<> _savedGifsUpdated; @@ -787,8 +793,8 @@ private: base::flat_set> _pollsUpdated; std::deque _pinnedDialogs; - base::flat_map> _feeds; - rpl::variable _defaultFeedId = FeedId(); + base::flat_map> _folders; + //rpl::variable _defaultFeedId = FeedId(); // #feed Groups _groups; std::unordered_map< not_null, diff --git a/Telegram/SourceFiles/data/data_types.h b/Telegram/SourceFiles/data/data_types.h index bb044b91d..9bccded6d 100644 --- a/Telegram/SourceFiles/data/data_types.h +++ b/Telegram/SourceFiles/data/data_types.h @@ -122,13 +122,13 @@ class BotCommand; struct BotInfo; namespace Data { -class Feed; +class Folder; } // namespace Data using UserId = int32; using ChatId = int32; using ChannelId = int32; -using FeedId = int32; +using FolderId = int32; constexpr auto NoChannel = ChannelId(0); diff --git a/Telegram/SourceFiles/dialogs/dialogs.style b/Telegram/SourceFiles/dialogs/dialogs.style index 17cdf03f5..a56cc610e 100644 --- a/Telegram/SourceFiles/dialogs/dialogs.style +++ b/Telegram/SourceFiles/dialogs/dialogs.style @@ -151,9 +151,9 @@ dialogsChannelIconActive: icon {{ "dialogs_channel", dialogsChatIconFgActive, po dialogsBotIcon: icon {{ "dialogs_bot", dialogsChatIconFg, point(1px, 3px) }}; dialogsBotIconOver: icon {{ "dialogs_bot", dialogsChatIconFgOver, point(1px, 3px) }}; dialogsBotIconActive: icon {{ "dialogs_bot", dialogsChatIconFgActive, point(1px, 3px) }}; -dialogsFeedIcon: icon {{ "dialogs_feed", dialogsChatIconFg, point(4px, 4px) }}; -dialogsFeedIconOver: icon {{ "dialogs_feed", dialogsChatIconFgOver, point(4px, 4px) }}; -dialogsFeedIconActive: icon {{ "dialogs_feed", dialogsChatIconFgActive, point(4px, 4px) }}; +//dialogsFeedIcon: icon {{ "dialogs_feed", dialogsChatIconFg, point(4px, 4px) }}; // #feed +//dialogsFeedIconOver: icon {{ "dialogs_feed", dialogsChatIconFgOver, point(4px, 4px) }}; +//dialogsFeedIconActive: icon {{ "dialogs_feed", dialogsChatIconFgActive, point(4px, 4px) }}; dialogsSendStateSkip: 20px; dialogsSendingIcon: icon {{ "dialogs_sending", dialogsSendingIconFg, point(8px, 4px) }}; diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 9a92cd5d5..55129fa15 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/dialogs_indexed_list.h" #include "dialogs/dialogs_layout.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_item.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/text_options.h" #include "data/data_drafts.h" -#include "data/data_feed.h" +#include "data/data_folder.h" #include "data/data_session.h" #include "data/data_channel.h" #include "data/data_chat.h" @@ -108,11 +108,11 @@ DialogsInner::DialogsInner(QWidget *parent, not_null contro if (history->textCachedFor == item) { history->updateChatListEntry(); } - if (const auto feed = history->peer->feed()) { - if (feed->textCachedFor == item) { - feed->updateChatListEntry(); - } - } + //if (const auto folder = history->peer->folder()) { // #TODO archive + // if (folder->textCachedFor == item) { + // folder->updateChatListEntry(); + // } + //} }, lifetime()); Auth().data().sendActionAnimationUpdated( @@ -165,9 +165,9 @@ DialogsInner::DialogsInner(QWidget *parent, not_null contro } } })); - Auth().data().feedUpdated( - ) | rpl::start_with_next([=](const Data::FeedUpdate &update) { - updateDialogRow({ update.feed, FullMsgId() }); + Auth().data().folderUpdated( + ) | rpl::start_with_next([=](const Data::FolderUpdate &update) { + updateDialogRow({ update.folder, FullMsgId() }); }, lifetime()); _controller->activeChatEntryValue( @@ -629,8 +629,8 @@ void DialogsInner::paintSearchInChat( } else { paintSearchInPeer(p, peer, top, fullWidth, _searchInChatText); } - } else if (const auto feed = _searchInChat.feed()) { - paintSearchInFeed(p, feed, top, fullWidth, _searchInChatText); + //} else if (const auto feed = _searchInChat.feed()) { // #feed + // paintSearchInFeed(p, feed, top, fullWidth, _searchInChatText); } else { Unexpected("Empty Dialogs::Key in paintSearchInChat."); } @@ -705,19 +705,19 @@ void DialogsInner::paintSearchInSaved( paintSearchInFilter(p, paintUserpic, top, fullWidth, nullptr, text); } -void DialogsInner::paintSearchInFeed( - Painter &p, - not_null feed, - int top, - int fullWidth, - const Text &text) const { - const auto paintUserpic = [&](Painter &p, int x, int y, int size) { - feed->paintUserpicLeft(p, x, y, fullWidth, size); - }; - const auto icon = Dialogs::Layout::FeedTypeIcon(feed, false, false); - paintSearchInFilter(p, paintUserpic, top, fullWidth, icon, text); -} - +//void DialogsInner::paintSearchInFeed( // #feed +// Painter &p, +// not_null feed, +// int top, +// int fullWidth, +// const Text &text) const { +// const auto paintUserpic = [&](Painter &p, int x, int y, int size) { +// feed->paintUserpicLeft(p, x, y, fullWidth, size); +// }; +// const auto icon = Dialogs::Layout::FeedTypeIcon(feed, false, false); +// paintSearchInFilter(p, paintUserpic, top, fullWidth, icon, text); +//} +// void DialogsInner::activate() { } @@ -1600,14 +1600,14 @@ void DialogsInner::contextMenuEvent(QContextMenuEvent *e) { return _menu->addAction(text, std::move(callback)); }, Window::PeerMenuSource::ChatsList); - } else if (const auto feed = row.key.feed()) { - Window::FillFeedMenu( - _controller, - feed, - [&](const QString &text, Fn callback) { - return _menu->addAction(text, std::move(callback)); - }, - Window::PeerMenuSource::ChatsList); + } else if (const auto folder = row.key.folder()) { + //Window::FillFolderMenu( // #TODO archive + // _controller, + // folder, + // [&](const QString &text, Fn callback) { + // return _menu->addAction(text, std::move(callback)); + // }, + // Window::PeerMenuSource::ChatsList); } connect(_menu.get(), &QObject::destroyed, [=] { if (_menuRow.key) { @@ -1850,11 +1850,11 @@ void DialogsInner::itemRemoved(not_null item) { void DialogsInner::dialogsReceived(const QVector &added) { for (const auto &dialog : added) { - switch (dialog.type()) { - case mtpc_dialog: applyDialog(dialog.c_dialog()); break; - //case mtpc_dialogFeed: applyFeedDialog(dialog.c_dialogFeed()); break; // #feed - default: Unexpected("Type in DialogsInner::dialogsReceived"); - } + dialog.match([&](const MTPDdialog &data) { + applyDialog(data); + }, [&](const MTPDdialogFolder &data) { + //applyFolderDialog(data); // #TODO archive + }); } refresh(); } @@ -2241,8 +2241,8 @@ void DialogsInner::refreshSearchInChatLabel() { return lang(lng_saved_messages); } return peer->name; - } else if (const auto feed = _searchInChat.feed()) { - return feed->chatListName(); + //} else if (const auto feed = _searchInChat.feed()) { // #feed + // return feed->chatListName(); } return QString(); }(); @@ -2563,17 +2563,17 @@ DialogsInner::ChosenRow DialogsInner::computeChosenRow() const { }; } else if (base::in_range(_searchedSelected, 0, _searchResults.size())) { const auto result = _searchResults[_searchedSelected].get(); - if (const auto feed = result->searchInChat().feed()) { - return { - feed, - result->item()->position() - }; - } else { + //if (const auto feed = result->searchInChat().feed()) { // #feed + // return { + // feed, + // result->item()->position() + // }; + //} else { return { result->item()->history(), result->item()->position() }; - } + //} } } return ChosenRow(); @@ -2599,10 +2599,11 @@ bool DialogsInner::chooseRow() { (uniqueSearchResults() ? ShowAtUnreadMsgId : chosen.message.fullId.msg)); - } else if (const auto feed = chosen.key.feed()) { - _controller->showSection( - HistoryFeed::Memento(feed, chosen.message), - Window::SectionShow::Way::ClearStack); + } else if (const auto folder = chosen.key.folder()) { + // #TODO archive + //_controller->showSection( + // HistoryFeed::Memento(feed, chosen.message), + // Window::SectionShow::Way::ClearStack); } if (openSearchResult && !Auth().supportMode()) { emit clearSearchQuery(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index c2998853a..e524dbd13 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -252,12 +252,12 @@ private: int top, int fullWidth, const Text &text) const; - void paintSearchInFeed( - Painter &p, - not_null feed, - int top, - int fullWidth, - const Text &text) const; + //void paintSearchInFeed( // #feed + // Painter &p, + // not_null feed, + // int top, + // int fullWidth, + // const Text &text) const; template void paintSearchInFilter( Painter &p, diff --git a/Telegram/SourceFiles/dialogs/dialogs_key.cpp b/Telegram/SourceFiles/dialogs/dialogs_key.cpp index 3e64063af..a402f3d79 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_key.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_key.cpp @@ -7,15 +7,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "dialogs/dialogs_key.h" -#include "data/data_feed.h" +#include "data/data_folder.h" #include "history/history.h" namespace Dialogs { +namespace { + +using Folder = Data::Folder; + +} // namespace not_null Key::entry() const { if (const auto p = base::get_if>(&_value)) { return *p; - } else if (const auto p = base::get_if>(&_value)) { + } else if (const auto p = base::get_if>(&_value)) { return *p; } Unexpected("Empty Dialogs::Key in Key::entry()."); @@ -28,8 +33,8 @@ History *Key::history() const { return nullptr; } -Data::Feed *Key::feed() const { - if (const auto p = base::get_if>(&_value)) { +Folder *Key::folder() const { + if (const auto p = base::get_if>(&_value)) { return *p; } return nullptr; diff --git a/Telegram/SourceFiles/dialogs/dialogs_key.h b/Telegram/SourceFiles/dialogs/dialogs_key.h index 295f205b7..a17cddd07 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_key.h +++ b/Telegram/SourceFiles/dialogs/dialogs_key.h @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL class History; namespace Data { -class Feed; +class Folder; } // namespace Data namespace Dialogs { @@ -26,9 +26,9 @@ public: } Key(not_null history) : _value(history) { } - Key(Data::Feed *feed) : _value(feed) { + Key(Data::Folder *folder) : _value(folder) { } - Key(not_null feed) : _value(feed) { + Key(not_null folder) : _value(folder) { } explicit operator bool() const { @@ -36,7 +36,7 @@ public: } not_null entry() const; History *history() const; - Data::Feed *feed() const; + Data::Folder *folder() const; PeerData *peer() const; inline bool operator<(const Key &other) const { @@ -60,7 +60,7 @@ public: base::optional_variant< not_null, - not_null> raw() const { + not_null> raw() const { return _value; } @@ -70,7 +70,9 @@ public: //} private: - base::optional_variant, not_null> _value; + base::optional_variant< + not_null, + not_null> _value; }; diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp index a2483688e..7b940116d 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.cpp @@ -165,7 +165,7 @@ enum class Flag { OnlyBackground = 0x04, SearchResult = 0x08, SavedMessages = 0x10, - FeedSearchResult = 0x20, + //FeedSearchResult = 0x20, // #feed }; inline constexpr bool is_flag_type(Flag) { return true; } @@ -257,20 +257,20 @@ void paintRow( st::msgNameFont->height); const auto promoted = chat.entry()->useProxyPromotion() - && !(flags & (Flag::SearchResult | Flag::FeedSearchResult)); + && !(flags & (Flag::SearchResult/* | Flag::FeedSearchResult*/)); // #feed if (promoted) { const auto text = lang(lng_proxy_sponsor); 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)) { chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth); rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); } - } else if (const auto feed = chat.feed()) { - if (const auto feedTypeIcon = FeedTypeIcon(feed, active, selected)) { - feedTypeIcon->paint(p, rectForName.topLeft(), fullWidth); - rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); - } + //} else if (const auto feed = chat.feed()) { // #feed + // if (const auto feedTypeIcon = FeedTypeIcon(feed, active, selected)) { + // feedTypeIcon->paint(p, rectForName.topLeft(), fullWidth); + // rectForName.setLeft(rectForName.left() + st::dialogsChatTypeSkip); + // } } auto texttop = st::dialogsPadding.y() + st::msgNameFont->height @@ -462,14 +462,14 @@ const style::icon *ChatTypeIcon( return nullptr; } -const style::icon *FeedTypeIcon( - not_null feed, - bool active, - bool selected) { - return &(active ? st::dialogsFeedIconActive - : (selected ? st::dialogsFeedIconOver : st::dialogsFeedIcon)); -} - +//const style::icon *FeedTypeIcon( // #feed +// not_null feed, +// bool active, +// bool selected) { +// return &(active ? st::dialogsFeedIconActive +// : (selected ? st::dialogsFeedIconOver : st::dialogsFeedIcon)); +//} +// void paintUnreadBadge(Painter &p, const QRect &rect, const UnreadBadgeStyle &st) { Assert(rect.height() == st.size); @@ -789,8 +789,8 @@ void RowPainter::paint( | (selected ? Flag::Selected : Flag(0)) | (onlyBackground ? Flag::OnlyBackground : Flag(0)) | Flag::SearchResult - | (showSavedMessages ? Flag::SavedMessages : Flag(0)) - | (row->searchInChat().feed() ? Flag::FeedSearchResult : Flag(0)); + | (showSavedMessages ? Flag::SavedMessages : Flag(0))/* // #feed + | (row->searchInChat().feed() ? Flag::FeedSearchResult : Flag(0))*/; paintRow( p, row, diff --git a/Telegram/SourceFiles/dialogs/dialogs_layout.h b/Telegram/SourceFiles/dialogs/dialogs_layout.h index 9f536b275..5f5613a56 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_layout.h +++ b/Telegram/SourceFiles/dialogs/dialogs_layout.h @@ -7,10 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -namespace Data { -class Feed; -} // namespace Data - namespace Dialogs { class Row; @@ -22,10 +18,10 @@ const style::icon *ChatTypeIcon( not_null peer, bool active, bool selected); -const style::icon *FeedTypeIcon( - not_null feed, - bool active, - bool selected); +//const style::icon *FeedTypeIcon( // #feed +// not_null feed, +// bool active, +// bool selected); class RowPainter { public: diff --git a/Telegram/SourceFiles/dialogs/dialogs_row.h b/Telegram/SourceFiles/dialogs/dialogs_row.h index 9876e7cde..6581b1db2 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_row.h +++ b/Telegram/SourceFiles/dialogs/dialogs_row.h @@ -55,8 +55,8 @@ public: History *history() const { return _id.history(); } - Data::Feed *feed() const { - return _id.feed(); + Data::Folder *folder() const { + return _id.folder(); } not_null entry() const { return _id.entry(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 62ccce107..b897fa645 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -12,7 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/dialogs_key.h" #include "dialogs/dialogs_entry.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/input_fields.h" #include "ui/wrap/fade_wrap.h" @@ -752,17 +752,17 @@ bool DialogsWidget::onSearchMessages(bool searchCache) { MTP_int(0)), rpcDone(&DialogsWidget::searchReceived, DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, DialogsSearchPeerFromStart)); - } else if (const auto feed = _searchInChat.feed()) { - //_searchRequest = MTP::send( // #feed - // MTPchannels_SearchFeed( - // MTP_int(feed->id()), - // MTP_string(_searchQuery), - // MTP_int(0), - // MTP_inputPeerEmpty(), - // MTP_int(0), - // MTP_int(SearchPerPage)), - // rpcDone(&DialogsWidget::searchReceived, DialogsSearchFromStart), - // rpcFail(&DialogsWidget::searchFailed, DialogsSearchFromStart)); + //} else if (const auto feed = _searchInChat.feed()) { // #feed + // _searchRequest = MTP::send( + // MTPchannels_SearchFeed( + // MTP_int(feed->id()), + // MTP_string(_searchQuery), + // MTP_int(0), + // MTP_inputPeerEmpty(), + // MTP_int(0), + // MTP_int(SearchPerPage)), + // rpcDone(&DialogsWidget::searchReceived, DialogsSearchFromStart), + // rpcFail(&DialogsWidget::searchFailed, DialogsSearchFromStart)); } else { _searchRequest = MTP::send( MTPmessages_SearchGlobal( @@ -888,19 +888,19 @@ void DialogsWidget::onSearchMore() { MTP_int(0)), rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart)); - } else if (const auto feed = _searchInChat.feed()) { - //_searchRequest = MTP::send( // #feed - // MTPchannels_SearchFeed( - // MTP_int(feed->id()), - // MTP_string(_searchQuery), - // MTP_int(offsetDate), - // offsetPeer - // ? offsetPeer->input - // : MTP_inputPeerEmpty(), - // MTP_int(offsetId), - // MTP_int(SearchPerPage)), - // rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart), - // rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart)); + //} else if (const auto feed = _searchInChat.feed()) { // #feed + // _searchRequest = MTP::send( + // MTPchannels_SearchFeed( + // MTP_int(feed->id()), + // MTP_string(_searchQuery), + // MTP_int(offsetDate), + // offsetPeer + // ? offsetPeer->input + // : MTP_inputPeerEmpty(), + // MTP_int(offsetId), + // MTP_int(SearchPerPage)), + // rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart), + // rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchFromOffset : DialogsSearchFromStart)); } else { _searchRequest = MTP::send( MTPmessages_SearchGlobal( @@ -1599,8 +1599,8 @@ bool DialogsWidget::onCancelSearch() { if (Adaptive::OneColumn()) { if (const auto peer = _searchInChat.peer()) { Ui::showPeerHistory(peer, ShowAtUnreadMsgId); - } else if (const auto feed = _searchInChat.feed()) { - controller()->showSection(HistoryFeed::Memento(feed)); + //} else if (const auto feed = _searchInChat.feed()) { // #feed + // controller()->showSection(HistoryFeed::Memento(feed)); } else { Unexpected("Empty key in onCancelSearch()."); } @@ -1624,8 +1624,8 @@ void DialogsWidget::onCancelSearchInChat() { if (Adaptive::OneColumn() && !App::main()->selectingPeer()) { if (const auto peer = _searchInChat.peer()) { Ui::showPeerHistory(peer, ShowAtUnreadMsgId); - } else if (const auto feed = _searchInChat.feed()) { - controller()->showSection(HistoryFeed::Memento(feed)); + //} else if (const auto feed = _searchInChat.feed()) { // #feed + // controller()->showSection(HistoryFeed::Memento(feed)); } else { Unexpected("Empty key in onCancelSearchInPeer()."); } diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index c2f0b704f..65caf6aa4 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -1457,6 +1457,7 @@ DialogsInfo ParseDialogsInfo(const MTPmessages_Dialogs &data) { result.chats.reserve(result.chats.size() + data.vdialogs.v.size()); for (const auto &dialog : data.vdialogs.v) { if (dialog.type() != mtpc_dialog) { + LOG(("API Error: Unexpected dialog type in chats export.")); continue; } const auto &fields = dialog.c_dialog(); diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 89935fc5d..ed285bbaa 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -28,10 +28,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/localstorage.h" #include "storage/storage_facade.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 "data/data_channel_admins.h" -#include "data/data_feed.h" +#include "data/data_folder.h" #include "data/data_photo.h" #include "data/data_channel.h" #include "data/data_chat.h" @@ -158,13 +158,13 @@ void History::checkChatListMessageRemoved(not_null item) { } _chatListMessage = std::nullopt; refreshChatListMessage(); - if (const auto channel = peer->asChannel()) { - if (const auto feed = channel->feed()) { - // Must be after history->chatListMessage() is updated. - // Otherwise feed last message will be this value again. - feed->messageRemoved(item); - } - } + //if (const auto channel = peer->asChannel()) { // #feed + // if (const auto feed = channel->feed()) { + // // Must be after history->chatListMessage() is updated. + // // Otherwise feed last message will be this value again. + // feed->messageRemoved(item); + // } + //} } void History::itemVanished(not_null item) { @@ -1711,12 +1711,12 @@ void History::changeUnreadCount(int delta) { if (_unreadCount) { setUnreadCount(std::max(*_unreadCount + delta, 0)); } - if (const auto channel = peer->asChannel()) { - if (const auto feed = channel->feed()) { - const auto mutedCountDelta = mute() ? delta : 0; - feed->unreadCountChanged(delta, mutedCountDelta); - } - } + //if (const auto channel = peer->asChannel()) { // #feed + // if (const auto feed = channel->feed()) { + // const auto mutedCountDelta = mute() ? delta : 0; + // feed->unreadCountChanged(delta, mutedCountDelta); + // } + //} } bool History::mute() const { @@ -1729,21 +1729,21 @@ bool History::changeMute(bool newMute) { } _mute = newMute; - const auto feed = peer->isChannel() - ? peer->asChannel()->feed() - : nullptr; - if (feed) { - if (_unreadCount) { - if (*_unreadCount) { - const auto unreadCountDelta = 0; - const auto mutedCountDelta = _mute ? *_unreadCount : -*_unreadCount; - feed->unreadCountChanged(unreadCountDelta, mutedCountDelta); - } - } else { - session().api().requestDialogEntry(this); - session().api().requestDialogEntry(feed); - } - } + //const auto feed = peer->isChannel() // #feed + // ? peer->asChannel()->feed() + // : nullptr; + //if (feed) { + // if (_unreadCount) { + // if (*_unreadCount) { + // const auto unreadCountDelta = 0; + // const auto mutedCountDelta = _mute ? *_unreadCount : -*_unreadCount; + // feed->unreadCountChanged(unreadCountDelta, mutedCountDelta); + // } + // } else { + // session().api().requestDialogEntry(this); + // session().api().requestDialogEntry(feed); + // } + //} if (inChatList(Dialogs::Mode::All)) { if (const auto count = historiesUnreadCount()) { _owner->unreadMuteChanged(count, _mute); @@ -2135,26 +2135,26 @@ void History::setNotLoadedAtBottom() { session().storage().invalidate( Storage::SharedMediaInvalidateBottom(peer->id)); - if (const auto channel = peer->asChannel()) { - if (const auto feed = channel->feed()) { - session().storage().invalidate( - Storage::FeedMessagesInvalidateBottom( - feed->id())); - } - } + //if (const auto channel = peer->asChannel()) { // #feed + // if (const auto feed = channel->feed()) { + // session().storage().invalidate( + // Storage::FeedMessagesInvalidateBottom( + // feed->id())); + // } + //} } void History::clearSharedMedia() { session().storage().remove( Storage::SharedMediaRemoveAll(peer->id)); - if (const auto channel = peer->asChannel()) { - if (const auto feed = channel->feed()) { - session().storage().remove( - Storage::FeedMessagesRemoveAll( - feed->id(), - channel->bareId())); - } - } + //if (const auto channel = peer->asChannel()) { // #feed + // if (const auto feed = channel->feed()) { + // session().storage().remove( + // Storage::FeedMessagesRemoveAll( + // feed->id(), + // channel->bareId())); + // } + //} } void History::setLastMessage(HistoryItem *item) { @@ -2348,15 +2348,15 @@ bool History::lastMessageKnown() const { void History::updateChatListExistence() { Entry::updateChatListExistence(); - if (const auto channel = peer->asChannel()) { - if (!channel->feed()) { - // After ungrouping from a feed we need to load dialog. - requestChatListMessage(); - if (!unreadCountKnown()) { - session().api().requestDialogEntry(this); - } - } - } + //if (const auto channel = peer->asChannel()) { // #feed + // if (!channel->feed()) { + // // After ungrouping from a feed we need to load dialog. + // requestChatListMessage(); + // if (!unreadCountKnown()) { + // session().api().requestDialogEntry(this); + // } + // } + //} } bool History::useProxyPromotion() const { @@ -2376,8 +2376,8 @@ bool History::shouldBeInChatList() const { } else if (const auto channel = peer->asChannel()) { if (!channel->amIn()) { return isProxyPromoted(); - } else if (const auto feed = channel->feed()) { - return !feed->needUpdateInChatList(); + //} else if (const auto feed = channel->feed()) { // #feed + // return !feed->needUpdateInChatList(); } } else if (const auto chat = peer->asChat()) { return chat->amIn() @@ -2966,10 +2966,10 @@ void History::clear(ClearType type) { clearLastKeyboard(); if (const auto channel = peer->asChannel()) { channel->clearPinnedMessage(); - if (const auto feed = channel->feed()) { - // Should be after resetting the _lastMessage. - feed->historyCleared(this); - } + //if (const auto feed = channel->feed()) { // #feed + // // Should be after resetting the _lastMessage. + // feed->historyCleared(this); + //} } } _owner->notifyHistoryChangeDelayed(this); diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 39f4e4a23..16c73b16d 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -23,7 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/file_upload.h" #include "storage/storage_facade.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 "apiwrap.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_messages.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_chat.h" #include "data/data_user.h" @@ -229,12 +229,12 @@ void HistoryItem::invalidateChatListEntry() { if (history()->textCachedFor == this) { history()->textCachedFor = nullptr; } - if (const auto feed = history()->peer->feed()) { - if (feed->textCachedFor == this) { - feed->textCachedFor = nullptr; - feed->updateChatListEntry(); - } - } + //if (const auto feed = history()->peer->feed()) { // #TODO archive + // if (feed->textCachedFor == this) { + // feed->textCachedFor = nullptr; + // feed->updateChatListEntry(); + // } + //} } void HistoryItem::finishEditionToEmpty() { @@ -402,13 +402,13 @@ void HistoryItem::indexAsNewItem() { types, id)); } - if (const auto channel = history()->peer->asChannel()) { - if (const auto feed = channel->feed()) { - _history->session().storage().add(Storage::FeedMessagesAddNew( - feed->id(), - position())); - } - } + //if (const auto channel = history()->peer->asChannel()) { // #feed + // if (const auto feed = channel->feed()) { + // _history->session().storage().add(Storage::FeedMessagesAddNew( + // feed->id(), + // position())); + // } + //} } } diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index ca6880e5e..a7b7b2bf7 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -17,7 +17,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_message.h" #include "history/history_item_components.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_media_types.h" #include "data/data_game.h" @@ -722,12 +722,12 @@ void HistoryService::updateDependentText() { if (history()->textCachedFor == this) { history()->textCachedFor = nullptr; } - if (const auto feed = history()->peer->feed()) { - if (feed->textCachedFor == this) { - feed->textCachedFor = nullptr; - feed->updateChatListEntry(); - } - } + //if (const auto feed = history()->peer->feed()) { // #TODO archive + // if (feed->textCachedFor == this) { + // feed->textCachedFor = nullptr; + // feed->updateChatListEntry(); + // } + //} if (const auto main = App::main()) { // #TODO feeds search results main->repaintDialogRow({ history(), fullId() }); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 14dec140e..491d08f7b 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -40,7 +40,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_drag_area.h" #include "history/history_inner_widget.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_element.h" #include "profile/profile_block_group_members.h" diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index 6b0733c05..31200d5ad 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -41,16 +41,16 @@ namespace { // If we can't cloud-export link for such time we export it locally. constexpr auto kExportLocalTimeout = crl::time(1000); -void AddToggleGroupingAction( - not_null menu, - not_null peer) { - if (const auto channel = peer->asChannel()) { - const auto grouped = (channel->feed() != nullptr); - //menu->addAction( // #feed - // lang(grouped ? lng_feed_ungroup : lng_feed_group), - // [=] { Window::ToggleChannelGrouping(channel, !grouped); }); - } -} +//void AddToggleGroupingAction( // #feed +// not_null menu, +// not_null peer) { +// if (const auto channel = peer->asChannel()) { +// const auto grouped = (channel->feed() != nullptr); +// menu->addAction( // #feed +// lang(grouped ? lng_feed_ungroup : lng_feed_group), +// [=] { Window::ToggleChannelGrouping(channel, !grouped); }); +// } +//} void SavePhotoToFile(not_null photo) { if (photo->isNull() || !photo->loaded()) { @@ -469,18 +469,18 @@ base::unique_qptr FillContextMenu( AddPhotoActions(result, photo); } else if (linkDocument) { AddDocumentActions(result, document, itemId); - } else if (linkPeer) { - const auto peer = linkPeer->peer(); - if (peer->isChannel() - && peer->asChannel()->feed() != nullptr - && (list->delegate()->listContext() == Context::Feed)) { - Window::PeerMenuAddMuteAction(peer, [&]( - const QString &text, - Fn handler) { - return result->addAction(text, handler); - }); - AddToggleGroupingAction(result, linkPeer->peer()); - } + //} else if (linkPeer) { // #feed + // const auto peer = linkPeer->peer(); + // if (peer->isChannel() + // && peer->asChannel()->feed() != nullptr + // && (list->delegate()->listContext() == Context::Feed)) { + // Window::PeerMenuAddMuteAction(peer, [&]( + // const QString &text, + // Fn handler) { + // return result->addAction(text, handler); + // }); + // AddToggleGroupingAction(result, linkPeer->peer()); + // } } else if (!request.overSelection && view && !hasSelection) { const auto media = view->media(); const auto mediaHasTextForCopy = media && media->hasTextForCopy(); diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index be5ed9994..7fe74e0da 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -326,9 +326,10 @@ bool Element::computeIsAttachToPrevious(not_null previous) { const auto prev = previous->data(); const auto possible = !item->serviceMsg() && !prev->serviceMsg() && !item->isEmpty() && !prev->isEmpty() - && (std::abs(prev->date() - item->date()) < kAttachMessageToPreviousSecondsDelta) - && (_context == Context::Feed - || (!item->isPost() && !prev->isPost())); + && (std::abs(prev->date() - item->date()) + < kAttachMessageToPreviousSecondsDelta) + && (/*_context == Context::Feed // #feed + || */(!item->isPost() && !prev->isPost())); if (possible) { if (item->history()->peer->isSelf()) { return IsAttachedToPreviousInSavedMessages(prev, item); diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 69b24cf63..6815b35d3 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -27,7 +27,7 @@ struct TextState; enum class Context : char { History, - Feed, + //Feed, // #feed AdminLog, ContactPreview }; diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index f880e3b74..2ea577fcb 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -31,7 +31,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "boxes/peers/edit_participant_box.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_document.h" #include "data/data_peer.h" diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 84f47be1c..a7680b416 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -704,7 +704,7 @@ bool Message::hasFromPhoto() const { } switch (context()) { case Context::AdminLog: - case Context::Feed: + //case Context::Feed: // #feed return true; case Context::History: { const auto item = message(); @@ -1311,7 +1311,7 @@ HistoryWebPage *Message::logEntryOriginal() const { bool Message::hasFromName() const { switch (context()) { case Context::AdminLog: - case Context::Feed: + //case Context::Feed: // #feed return true; case Context::History: { const auto item = message(); diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index 1ab046241..d9c0e4773 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -376,9 +376,9 @@ QSize Service::performCountOptimalSize() { } bool Service::isHidden() const { - if (context() == Context::Feed) { - return true; - } + //if (context() == Context::Feed) { // #feed + // return true; + //} return Element::isHidden(); } diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index e393713ad..8f762e028 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -29,7 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_peer_menu.h" #include "calls/calls_instance.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_channel.h" #include "data/data_chat.h" @@ -219,10 +219,10 @@ void TopBarWidget::showMenu() { peer, addAction, Window::PeerMenuSource::History); - } else if (const auto feed = _activeChat.feed()) { - Window::FillFeedMenu( + } else if (const auto folder = _activeChat.folder()) { + Window::FillFolderMenu( _controller, - feed, + folder, addAction, Window::PeerMenuSource::History); } else { @@ -237,13 +237,13 @@ void TopBarWidget::toggleInfoSection() { && (Auth().settings().thirdSectionInfoEnabled() || Auth().settings().tabbedReplacedWithInfo())) { _controller->closeThirdSection(); - } else if (_activeChat) { + } else if (_activeChat.peer()) { if (_controller->canShowThirdSection()) { Auth().settings().setThirdSectionInfoEnabled(true); Auth().saveSettingsDelayed(); if (Adaptive::ThreeColumn()) { _controller->showSection( - Info::Memento::Default(_activeChat), + Info::Memento::Default(_activeChat.peer()), Window::SectionShow().withThirdColumn()); } else { _controller->resizeForThirdSection(); @@ -297,7 +297,7 @@ void TopBarWidget::paintEvent(QPaintEvent *e) { } void TopBarWidget::paintTopBar(Painter &p) { - if (!_activeChat) { + if (!_activeChat.peer()) { // #feed return; } auto nameleft = _leftTaken; @@ -308,7 +308,7 @@ void TopBarWidget::paintTopBar(Painter &p) { auto history = _activeChat.history(); 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 textWidth = st::historySavedFont->width(text); if (namewidth < textWidth) { @@ -320,7 +320,7 @@ void TopBarWidget::paintTopBar(Painter &p) { (height() - st::historySavedFont->height) / 2, width(), text); - } else if (_activeChat.peer()->isSelf()) { + } else */if (_activeChat.peer()->isSelf()) { auto text = lang(lng_saved_messages); auto textWidth = st::historySavedFont->width(text); if (namewidth < textWidth) { @@ -411,12 +411,12 @@ void TopBarWidget::mousePressEvent(QMouseEvent *e) { } void TopBarWidget::infoClicked() { - if (!_activeChat) { + if (!_activeChat.peer()) { return; - } else if (const auto feed = _activeChat.feed()) { - _controller->showSection(Info::Memento( - feed, - Info::Section(Info::Section::Type::Profile))); + //} else if (const auto feed = _activeChat.feed()) { // #feed + // _controller->showSection(Info::Memento( + // feed, + // Info::Section(Info::Section::Type::Profile))); } else if (_activeChat.peer()->isSelf()) { _controller->showSection(Info::Memento( _activeChat.peer()->id, @@ -458,13 +458,13 @@ void TopBarWidget::refreshInfoButton() { info->showSavedMessagesOnSelf(true); _info.destroy(); _info = std::move(info); - } else if (const auto feed = _activeChat.feed()) { - _info.destroy(); - _info = object_ptr( - this, - _controller, - feed, - st::topBarFeedInfoButton); + //} else if (const auto feed = _activeChat.feed()) { // #feed + // _info.destroy(); + // _info = object_ptr( + // this, + // _controller, + // feed, + // st::topBarFeedInfoButton); } if (_info) { _info->setAttribute(Qt::WA_TransparentForMouseEvents); diff --git a/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp b/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp index c4904c484..f5f519a90 100644 --- a/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp +++ b/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp @@ -297,25 +297,21 @@ void NotificationsController::applyFeedDialogs( auto channels = std::vector>(); channels.reserve(dialogsList->size()); for (const auto &dialog : *dialogsList) { - switch (dialog.type()) { - case mtpc_dialog: { - if (const auto peerId = peerFromMTP(dialog.c_dialog().vpeer)) { - if (peerIsChannel(peerId)) { + dialog.match([&](const MTPDdialog &data) { + if (const auto peerId = peerFromMTP(data.vpeer)) { + if (peerIsChannel(peerId)) { // #TODO archive const auto history = Auth().data().history(peerId); const auto channel = history->peer->asChannel(); - history->applyDialog(dialog.c_dialog()); + history->applyDialog(data); channels.emplace_back(channel); } else { LOG(("API Error: " - "Unexpected non-channel in feed dialogs list.")); + "Unexpected non-channel in folder dialogs list.")); } } - } break; - //case mtpc_dialogFeed: { // #feed - // LOG(("API Error: Unexpected dialogFeed in feed dialogs list.")); - //} break; - default: Unexpected("Type in DialogsInner::dialogsReceived"); - } + }, [&](const MTPDdialogFolder &data) { + LOG(("API Error: Unexpected dialogFolder in folder dialogs list.")); + }); } if (!channels.empty()) { auto notMutedChannels = ranges::view::all( diff --git a/Telegram/SourceFiles/info/info_content_widget.cpp b/Telegram/SourceFiles/info/info_content_widget.cpp index 9db9a9756..c55385076 100644 --- a/Telegram/SourceFiles/info/info_content_widget.cpp +++ b/Telegram/SourceFiles/info/info_content_widget.cpp @@ -262,8 +262,8 @@ void ContentWidget::refreshSearchField(bool shown) { Key ContentMemento::key() const { if (const auto peerId = this->peerId()) { return Key(Auth().data().peer(peerId)); - } else if (const auto feed = this->feed()) { - return Key(feed); + //} else if (const auto feed = this->feed()) { // #feed + // return Key(feed); } else { return Settings::Tag{ settingsSelf() }; } diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index 7c989c8fd..1b2c50987 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -23,10 +23,6 @@ template class PaddingWrap; } // namespace Ui -namespace Data { -class Feed; -} // namespace Data - namespace Info { namespace Settings { struct Tag; @@ -124,8 +120,8 @@ public: : _peerId(peerId) , _migratedPeerId(migratedPeerId) { } - explicit ContentMemento(not_null feed) : _feed(feed) { - } + //explicit ContentMemento(not_null feed) : _feed(feed) { // #feed + //} explicit ContentMemento(Settings::Tag settings); virtual object_ptr createWidget( @@ -139,9 +135,9 @@ public: PeerId migratedPeerId() const { return _migratedPeerId; } - Data::Feed *feed() const { - return _feed; - } + //Data::Feed *feed() const { // #feed + // return _feed; + //} UserData *settingsSelf() const { return _settingsSelf; } @@ -179,7 +175,7 @@ public: private: const PeerId _peerId = 0; const PeerId _migratedPeerId = 0; - Data::Feed * const _feed = nullptr; + //Data::Feed * const _feed = nullptr; // #feed UserData * const _settingsSelf = nullptr; int _scrollTop = 0; QString _searchFieldQuery; diff --git a/Telegram/SourceFiles/info/info_controller.cpp b/Telegram/SourceFiles/info/info_controller.cpp index 3bdb61134..c06bd1c40 100644 --- a/Telegram/SourceFiles/info/info_controller.cpp +++ b/Telegram/SourceFiles/info/info_controller.cpp @@ -40,8 +40,8 @@ not_null CorrectPeer(PeerId peerId) { Key::Key(not_null peer) : _value(peer) { } -Key::Key(not_null feed) : _value(feed) { -} +//Key::Key(not_null feed) : _value(feed) { // #feed +//} Key::Key(Settings::Tag settings) : _value(settings) { } @@ -53,12 +53,12 @@ PeerData *Key::peer() const { return nullptr; } -Data::Feed *Key::feed() const { - if (const auto feed = base::get_if>(&_value)) { - return *feed; - } - return nullptr; -} +//Data::Feed *Key::feed() const { // #feed +// if (const auto feed = base::get_if>(&_value)) { +// return *feed; +// } +// return nullptr; +//} UserData *Key::settingsSelf() const { if (const auto tag = base::get_if(&_value)) { @@ -167,7 +167,7 @@ bool Controller::validateMementoPeer( not_null memento) const { return memento->peerId() == peerId() && memento->migratedPeerId() == migratedPeerId() - && memento->feed() == feed() + //&& memento->feed() == feed() // #feed && memento->settingsSelf() == settingsSelf(); } @@ -190,8 +190,8 @@ void Controller::updateSearchControllers( = (type == Type::CommonGroups); auto hasMembersSearch = (type == Type::Members - || type == Type::Profile - || type == Type::Channels); + || type == Type::Profile/* // #feed + || type == Type::Channels*/); auto searchQuery = memento->searchFieldQuery(); if (isMedia) { _searchController diff --git a/Telegram/SourceFiles/info/info_controller.h b/Telegram/SourceFiles/info/info_controller.h index a8ce32f4d..47f362ce9 100644 --- a/Telegram/SourceFiles/info/info_controller.h +++ b/Telegram/SourceFiles/info/info_controller.h @@ -31,17 +31,17 @@ struct Tag { class Key { public: Key(not_null peer); - Key(not_null feed); + //Key(not_null feed); // #feed Key(Settings::Tag settings); PeerData *peer() const; - Data::Feed *feed() const; + //Data::Feed *feed() const; // #feed UserData *settingsSelf() const; private: base::variant< not_null, - not_null, + //not_null, // #feed Settings::Tag> _value; }; @@ -58,7 +58,7 @@ public: Media, CommonGroups, Members, - Channels, + //Channels, // #feed Settings, }; using SettingsType = ::Settings::Type; @@ -107,9 +107,9 @@ public: PeerId peerId() const; PeerId migratedPeerId() const; - Data::Feed *feed() const { - return key().feed(); - } + //Data::Feed *feed() const { // #feed + // return key().feed(); + //} UserData *settingsSelf() const { return key().settingsSelf(); } diff --git a/Telegram/SourceFiles/info/info_memento.cpp b/Telegram/SourceFiles/info/info_memento.cpp index d48e7b2ee..68133be06 100644 --- a/Telegram/SourceFiles/info/info_memento.cpp +++ b/Telegram/SourceFiles/info/info_memento.cpp @@ -10,9 +10,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "info/profile/info_profile_widget.h" #include "info/media/info_media_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/feed/info_feed_profile_widget.h" +//#include "info/feed/info_feed_profile_widget.h" // #feed #include "info/settings/info_settings_widget.h" #include "info/info_section_widget.h" #include "info/info_layer_widget.h" @@ -33,10 +33,10 @@ Memento::Memento(PeerId peerId, Section section) : Memento(DefaultStack(peerId, section)) { } -Memento::Memento(not_null feed, Section section) -: Memento(DefaultStack(feed, section)) { -} - +//Memento::Memento(not_null feed, Section section) // #feed +//: Memento(DefaultStack(feed, section)) { +//} +// Memento::Memento(Settings::Tag settings, Section section) : Memento(DefaultStack(settings, section)) { } @@ -53,14 +53,14 @@ std::vector> Memento::DefaultStack( return result; } -std::vector> Memento::DefaultStack( - not_null feed, - Section section) { - auto result = std::vector>(); - result.push_back(DefaultContent(feed, section)); - return result; -} - +//std::vector> Memento::DefaultStack( // #feed +// not_null feed, +// Section section) { +// auto result = std::vector>(); +// result.push_back(DefaultContent(feed, section)); +// return result; +//} +// std::vector> Memento::DefaultStack( Settings::Tag settings, Section section) { @@ -71,21 +71,32 @@ std::vector> Memento::DefaultStack( return result; } -Section Memento::DefaultSection(Dialogs::Key key) { - if (const auto peer = key.peer()) { - if (peer->isSelf()) { - return Section(Section::MediaType::Photo); - } +Section Memento::DefaultSection(not_null peer) { + if (peer->isSelf()) { + return Section(Section::MediaType::Photo); } 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) { - if (const auto peer = key.peer()) { - return Memento(peer->id, DefaultSection(key)); - } - return Memento(key.feed(), DefaultSection(key)); +Memento Memento::Default(not_null peer) { + return Memento(peer->id, DefaultSection(peer)); } +// // #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 Memento::DefaultContent( PeerId peerId, @@ -121,18 +132,18 @@ std::unique_ptr Memento::DefaultContent( } Unexpected("Wrong section type in Info::Memento::DefaultContent()"); } - -std::unique_ptr Memento::DefaultContent( - not_null feed, - Section section) { - switch (section.type()) { - case Section::Type::Profile: - return std::make_unique(feed); - case Section::Type::Channels: - return std::make_unique(feed); - } - Unexpected("Wrong feed section in Info::Memento::DefaultContent()"); -} +// +//std::unique_ptr Memento::DefaultContent( // #feed +// not_null feed, +// Section section) { +// switch (section.type()) { +// case Section::Type::Profile: +// return std::make_unique(feed); +// case Section::Type::Channels: +// return std::make_unique(feed); +// } +// Unexpected("Wrong feed section in Info::Memento::DefaultContent()"); +//} object_ptr Memento::createWidget( QWidget *parent, diff --git a/Telegram/SourceFiles/info/info_memento.h b/Telegram/SourceFiles/info/info_memento.h index 5dd484991..976b5661c 100644 --- a/Telegram/SourceFiles/info/info_memento.h +++ b/Telegram/SourceFiles/info/info_memento.h @@ -16,10 +16,6 @@ namespace Storage { enum class SharedMediaType : signed char; } // namespace Storage -namespace Data { -class Feed; -} // namespace Data - namespace Ui { class ScrollArea; struct ScrollToRequest; @@ -37,7 +33,7 @@ class Memento final : public Window::SectionMemento { public: explicit Memento(PeerId peerId); Memento(PeerId peerId, Section section); - Memento(not_null feed, Section section); + //Memento(not_null feed, Section section); // #feed Memento(Settings::Tag settings, Section section); explicit Memento(std::vector> stack); @@ -62,8 +58,10 @@ public: return _stack.back().get(); } - static Section DefaultSection(Dialogs::Key key); - static Memento Default(Dialogs::Key key); + static Section DefaultSection(not_null peer); + //static Section DefaultSection(Dialogs::Key key); // #feed + static Memento Default(not_null peer); + //static Memento Default(Dialogs::Key key); // #feed ~Memento(); @@ -71,15 +69,15 @@ private: static std::vector> DefaultStack( PeerId peerId, Section section); - static std::vector> DefaultStack( - not_null feed, - Section section); + //static std::vector> DefaultStack( // #feed + // not_null feed, + // Section section); static std::vector> DefaultStack( Settings::Tag settings, Section section); - static std::unique_ptr DefaultContent( - not_null feed, - Section section); + //static std::unique_ptr DefaultContent( // #feed + // not_null feed, + // Section section); static std::unique_ptr DefaultContent( PeerId peerId, diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index 57b73ee19..b83a9b8d8 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -554,9 +554,9 @@ rpl::producer TitleValue( switch (section.type()) { case Section::Type::Profile: - if (const auto feed = key.feed()) { + /*if (const auto feed = key.feed()) { return lng_info_feed_title; - } else if (const auto user = peer->asUser()) { + } else */if (const auto user = peer->asUser()) { return (user->isBot() && !user->isSupport()) ? lng_info_bot_title : lng_info_user_title; @@ -597,8 +597,8 @@ rpl::producer TitleValue( case Section::Type::Members: return lng_profile_participants_section; - case Section::Type::Channels: - return lng_info_feed_channels; + //case Section::Type::Channels: // #feed + // return lng_info_feed_channels; case Section::Type::Settings: switch (section.settingsType()) { diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 980068c07..7acccde9e 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -131,8 +131,8 @@ void WrapWidget::startInjectingActivePeerProfiles() { void WrapWidget::injectActiveProfile(Dialogs::Key key) { if (const auto peer = key.peer()) { injectActivePeerProfile(peer); - } else if (const auto feed = key.feed()) { - injectActiveFeedProfile(feed); + //} else if (const auto feed = key.feed()) { // #feed + // injectActiveFeedProfile(feed); } } @@ -167,22 +167,22 @@ void WrapWidget::injectActivePeerProfile(not_null peer) { Memento(peer->id, section).takeStack().front())); } } - -void WrapWidget::injectActiveFeedProfile(not_null feed) { - const auto firstFeed = hasStackHistory() - ? _historyStack.front().section->feed() - : _controller->feed(); - const auto firstSectionType = hasStackHistory() - ? _historyStack.front().section->section().type() - : _controller->section().type(); - const auto expectedType = Section::Type::Profile; - if (firstSectionType != expectedType - || firstFeed != feed) { - auto section = Section(Section::Type::Profile); - injectActiveProfileMemento(std::move( - Memento(feed, section).takeStack().front())); - } -} +// // #feed +//void WrapWidget::injectActiveFeedProfile(not_null feed) { +// const auto firstFeed = hasStackHistory() +// ? _historyStack.front().section->feed() +// : _controller->feed(); +// const auto firstSectionType = hasStackHistory() +// ? _historyStack.front().section->section().type() +// : _controller->section().type(); +// const auto expectedType = Section::Type::Profile; +// if (firstSectionType != expectedType +// || firstFeed != feed) { +// auto section = Section(Section::Type::Profile); +// injectActiveProfileMemento(std::move( +// Memento(feed, section).takeStack().front())); +// } +//} void WrapWidget::injectActiveProfileMemento( std::unique_ptr memento) { @@ -214,8 +214,8 @@ Key WrapWidget::key() const { Dialogs::RowDescriptor WrapWidget::activeChat() const { if (const auto peer = key().peer()) { return Dialogs::RowDescriptor(peer->owner().history(peer), FullMsgId()); - } else if (const auto feed = key().feed()) { - return Dialogs::RowDescriptor(feed, FullMsgId()); + //} else if (const auto feed = key().feed()) { // #feed + // return Dialogs::RowDescriptor(feed, FullMsgId()); } else if (key().settingsSelf()) { return Dialogs::RowDescriptor(); } @@ -570,12 +570,12 @@ void WrapWidget::showTopBarMenu() { peer, addAction, Window::PeerMenuSource::Profile); - } else if (const auto feed = key().feed()) { - Window::FillFeedMenu( - _controller->parentController(), - feed, - addAction, - Window::PeerMenuSource::Profile); + //} else if (const auto feed = key().feed()) { // #feed + // Window::FillFeedMenu( + // _controller->parentController(), + // feed, + // addAction, + // Window::PeerMenuSource::Profile); } else if (const auto self = key().settingsSelf()) { const auto showOther = [=](::Settings::Type type) { const auto controller = _controller.get(); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.h b/Telegram/SourceFiles/info/info_wrap_widget.h index c49d996dc..f92a9e859 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.h +++ b/Telegram/SourceFiles/info/info_wrap_widget.h @@ -14,10 +14,6 @@ namespace Storage { enum class SharedMediaType : signed char; } // namespace Storage -namespace Data { -class Feed; -} // namespace Data - namespace Ui { class SettingsSlider; class FadeShadow; @@ -148,7 +144,7 @@ private: void startInjectingActivePeerProfiles(); void injectActiveProfile(Dialogs::Key key); void injectActivePeerProfile(not_null peer); - void injectActiveFeedProfile(not_null feed); + //void injectActiveFeedProfile(not_null feed); // #feed void injectActiveProfileMemento( std::unique_ptr memento); void checkBeforeClose(Fn close); diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index dfcd37668..6b6171623 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -7,11 +7,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "info/profile/info_profile_actions.h" -#include -#include #include "data/data_peer_values.h" #include "data/data_session.h" -#include "data/data_feed.h" +#include "data/data_folder.h" #include "data/data_channel.h" #include "data/data_user.h" #include "ui/wrap/vertical_layout.h" @@ -167,37 +165,37 @@ private: object_ptr _wrap = { nullptr }; }; - -class FeedDetailsFiller { -public: - FeedDetailsFiller( - not_null controller, - not_null parent, - not_null feed); - - object_ptr fill(); - -private: - object_ptr setupDefaultToggle(); - - template < - typename Widget, - typename = std::enable_if_t< - std::is_base_of_v>> - Widget *add( - object_ptr &&child, - const style::margins &margin = style::margins()) { - return _wrap->add( - std::move(child), - margin); - } - - not_null _controller; - not_null _parent; - not_null _feed; - object_ptr _wrap; - -}; +// // #feed +//class FeedDetailsFiller { +//public: +// FeedDetailsFiller( +// not_null controller, +// not_null parent, +// not_null feed); +// +// object_ptr fill(); +// +//private: +// object_ptr setupDefaultToggle(); +// +// template < +// typename Widget, +// typename = std::enable_if_t< +// std::is_base_of_v>> +// Widget *add( +// object_ptr &&child, +// const style::margins &margin = style::margins()) { +// return _wrap->add( +// std::move(child), +// margin); +// } +// +// not_null _controller; +// not_null _parent; +// not_null _feed; +// object_ptr _wrap; +// +//}; DetailsFiller::DetailsFiller( not_null controller, @@ -703,47 +701,47 @@ object_ptr ActionsFiller::fill() { } return { nullptr }; } - -FeedDetailsFiller::FeedDetailsFiller( - not_null controller, - not_null parent, - not_null feed) -: _controller(controller) -, _parent(parent) -, _feed(feed) -, _wrap(_parent) { -} - -object_ptr FeedDetailsFiller::fill() { - add(object_ptr(_wrap)); - add(CreateSkipWidget(_wrap)); - add(setupDefaultToggle()); - add(CreateSkipWidget(_wrap)); - return std::move(_wrap); -} - -object_ptr FeedDetailsFiller::setupDefaultToggle() { - using namespace rpl::mappers; - const auto feedId = _feed->id(); - auto result = object_ptr