From ee182ea6841040f1945163c31d22c1cee455e058 Mon Sep 17 00:00:00 2001 From: John Preston <johnprestonmail@gmail.com> Date: Tue, 6 Mar 2018 20:07:42 +0300 Subject: [PATCH] API scheme downgraded to layer 76. --- Telegram/Resources/scheme.tl | 27 +- Telegram/SourceFiles/apiwrap.cpp | 796 +++++++++--------- Telegram/SourceFiles/apiwrap.h | 44 +- Telegram/SourceFiles/app.cpp | 10 +- Telegram/SourceFiles/data/data_feed.cpp | 77 +- Telegram/SourceFiles/data/data_feed.h | 4 +- .../SourceFiles/data/data_feed_messages.cpp | 8 +- Telegram/SourceFiles/data/data_session.cpp | 20 +- .../dialogs/dialogs_inner_widget.cpp | 28 +- .../dialogs/dialogs_inner_widget.h | 2 +- .../SourceFiles/dialogs/dialogs_widget.cpp | 48 +- .../view/history_view_context_menu.cpp | 6 +- .../history/view/history_view_list_widget.cpp | 2 +- .../feed/info_feed_channels_controllers.cpp | 156 ++-- .../feed/info_feed_channels_controllers.h | 10 +- .../info/profile/info_profile_actions.cpp | 2 +- Telegram/SourceFiles/mainwidget.cpp | 76 +- .../SourceFiles/window/window_peer_menu.cpp | 79 +- .../SourceFiles/window/window_peer_menu.h | 4 +- 19 files changed, 692 insertions(+), 707 deletions(-) diff --git a/Telegram/Resources/scheme.tl b/Telegram/Resources/scheme.tl index 87d1f80b3..18b69036d 100644 --- a/Telegram/Resources/scheme.tl +++ b/Telegram/Resources/scheme.tl @@ -219,7 +219,7 @@ userStatusLastMonth#77ebc742 = UserStatus; chatEmpty#9ba2d800 id:int = Chat; chat#d91cdd54 flags:# creator:flags.0?true kicked:flags.1?true left:flags.2?true admins_enabled:flags.3?true admin:flags.4?true deactivated:flags.5?true id:int title:string photo:ChatPhoto participants_count:int date:int version:int migrated_to:flags.6?InputChannel = Chat; chatForbidden#7328bdb id:int title:string = Chat; -channel#c88974ac flags:# creator:flags.0?true left:flags.2?true editor:flags.3?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true democracy:flags.10?true signatures:flags.11?true min:flags.12?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChannelAdminRights banned_rights:flags.15?ChannelBannedRights participants_count:flags.17?int feed_id:flags.18?int = Chat; +channel#450b7115 flags:# creator:flags.0?true left:flags.2?true editor:flags.3?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true democracy:flags.10?true signatures:flags.11?true min:flags.12?true id:int access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int version:int restriction_reason:flags.9?string admin_rights:flags.14?ChannelAdminRights banned_rights:flags.15?ChannelBannedRights participants_count:flags.17?int = Chat; channelForbidden#289da732 flags:# broadcast:flags.5?true megagroup:flags.8?true id:int access_hash:long title:string until_date:flags.16?int = Chat; chatFull#2e02a614 id:int participants:ChatParticipants chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:ExportedChatInvite bot_info:Vector<BotInfo> = ChatFull; @@ -273,7 +273,6 @@ messageActionCustomAction#fae69f56 message:string = MessageAction; messageActionBotAllowed#abe9affe domain:string = MessageAction; dialog#e4def5db flags:# pinned:flags.2?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage = Dialog; -dialogFeed#36086d42 flags:# pinned:flags.2?true peer:Peer top_message:int feed_id:int feed_other_channels:Vector<int> read_max_position:flags.3?FeedPosition unread_count:int unread_muted_count:int = Dialog; photoEmpty#2331b22d id:long = Photo; photo#9288dd29 flags:# has_stickers:flags.0?true id:long access_hash:long date:int sizes:Vector<PhotoSize> = Photo; @@ -437,7 +436,6 @@ updateFavedStickers#e511996d = Update; updateChannelReadMessagesContents#89893b45 channel_id:int messages:Vector<int> = Update; updateContactsReset#7084a7be = Update; updateChannelAvailableMessages#70db6837 channel_id:int available_min_id:int = Update; -updateReadFeed#6fa68e41 flags:# feed_id:int max_position:FeedPosition unread_count:flags.0?int unread_muted_count:flags.0?int = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -948,27 +946,14 @@ inputMessageReplyTo#bad88395 id:int = InputMessage; inputMessagePinned#86872538 = InputMessage; inputDialogPeer#fcaafeb7 peer:InputPeer = InputDialogPeer; -inputDialogPeerFeed#2c38b8cf feed_id:int = InputDialogPeer; dialogPeer#e56dbf05 peer:Peer = DialogPeer; -dialogPeerFeed#da429411 feed_id:int = DialogPeer; messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets; messages.foundStickerSets#5108d648 hash:int sets:Vector<StickerSetCovered> = messages.FoundStickerSets; fileHash#6242c773 offset:int limit:int hash:bytes = FileHash; -feedPosition#5059dc73 date:int peer:Peer id:int = FeedPosition; - -messages.feedMessagesNotModified#4678d0cf = messages.FeedMessages; -messages.feedMessages#55c3a1b1 flags:# max_position:flags.0?FeedPosition min_position:flags.1?FeedPosition read_max_position:flags.2?FeedPosition messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.FeedMessages; - -feedBroadcasts#4f4feaf1 feed_id:int channels:Vector<int> = FeedBroadcasts; -feedBroadcastsUngrouped#9a687cba channels:Vector<int> = FeedBroadcasts; - -channels.feedSourcesNotModified#88b12a17 = channels.FeedSources; -channels.feedSources#8e8bca3d flags:# newly_joined_feed:flags.0?int feeds:Vector<FeedBroadcasts> chats:Vector<Chat> users:Vector<User> = channels.FeedSources; - ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1046,7 +1031,7 @@ contacts.resetTopPeerRating#1ae373ac category:TopPeerCategory peer:InputPeer = B contacts.resetSaved#879537f1 = Bool; messages.getMessages#63c66506 id:Vector<InputMessage> = messages.Messages; -messages.getDialogs#5c0fae2 flags:# exclude_pinned:flags.0?true feed_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int = messages.Dialogs; +messages.getDialogs#191ba9c5 flags:# exclude_pinned:flags.0?true offset_date:int offset_id:int offset_peer:InputPeer limit:int = messages.Dialogs; messages.getHistory#dcbb8260 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; messages.search#8614ef68 flags:# peer:InputPeer q:string from_id:flags.0?InputUser filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:int = messages.Messages; messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; @@ -1204,12 +1189,6 @@ channels.setStickers#ea8ca4f9 channel:InputChannel stickerset:InputStickerSet = channels.readMessageContents#eab5dc38 channel:InputChannel id:Vector<int> = Bool; channels.deleteHistory#af369d42 channel:InputChannel max_id:int = Bool; channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Updates; -channels.getFeed#b90f450 flags:# offset_to_max_read:flags.3?true feed_id:int offset_position:flags.0?FeedPosition add_offset:int limit:int max_position:flags.1?FeedPosition min_position:flags.2?FeedPosition hash:int = messages.FeedMessages; -channels.searchFeed#88325369 feed_id:int q:string offset_date:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; -channels.getFeedSources#d8ce236e flags:# feed_id:flags.0?int hash:int = channels.FeedSources; -channels.changeFeedBroadcast#ffb37511 flags:# channel:InputChannel feed_id:flags.0?int = Updates; -channels.setFeedBroadcasts#ea80bfae flags:# feed_id:int channels:flags.0?Vector<InputChannel> also_newly_joined:flags.1?Bool = Updates; -channels.readFeed#9c3011d feed_id:int max_position:FeedPosition = Updates; bots.sendCustomRequest#aa2769ed custom_method:string params:DataJSON = DataJSON; bots.answerWebhookJSONQuery#e6213f4d query_id:long data:DataJSON = Bool; @@ -1240,4 +1219,4 @@ langpack.getStrings#2e1ee318 lang_code:string keys:Vector<string> = Vector<LangP langpack.getDifference#b2e4d7d from_version:int = LangPackDifference; langpack.getLanguages#800fd57d = Vector<LangPackLanguage>; -// LAYER 77 +// LAYER 76 diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index 9ff67b82e..a5717a8cc 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -165,7 +165,7 @@ void ApiWrap::savePinnedOrder() { 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()))); +// peers.push_back(MTP_inputDialogPeerFeed(MTP_int(feed->id()))); // #feed } } auto flags = MTPmessages_ReorderPinnedDialogs::Flag::f_force; @@ -174,50 +174,50 @@ void ApiWrap::savePinnedOrder() { MTP_vector(peers) )).send(); } - -void ApiWrap::toggleChannelGrouping( - not_null<ChannelData*> channel, - bool group, - base::lambda<void()> callback) { - if (const auto already = _channelGroupingRequests.take(channel)) { - request(already->first).cancel(); - } - const auto feedId = Data::Feed::kId; - const auto flags = group - ? MTPchannels_ChangeFeedBroadcast::Flag::f_feed_id - : MTPchannels_ChangeFeedBroadcast::Flag(0); - const auto requestId = request(MTPchannels_ChangeFeedBroadcast( - MTP_flags(flags), - channel->inputChannel, - MTP_int(feedId) - )).done([=](const MTPUpdates &result) { - applyUpdates(result); - if (group) { - channel->setFeed(Auth().data().feed(feedId)); - } else { - channel->clearFeed(); - } - if (const auto data = _channelGroupingRequests.take(channel)) { - data->second(); - } - }).fail([=](const RPCError &error) { - _channelGroupingRequests.remove(channel); - }).send(); - _channelGroupingRequests.emplace(channel, requestId, callback); -} - -void ApiWrap::ungroupAllFromFeed(not_null<Data::Feed*> feed) { - const auto flags = MTPchannels_SetFeedBroadcasts::Flag::f_channels - | MTPchannels_SetFeedBroadcasts::Flag::f_also_newly_joined; - request(MTPchannels_SetFeedBroadcasts( - MTP_flags(flags), - MTP_int(feed->id()), - MTP_vector<MTPInputChannel>(0), - MTP_bool(false) - )).done([=](const MTPUpdates &result) { - applyUpdates(result); - }).send(); -} +// #feed +//void ApiWrap::toggleChannelGrouping( +// not_null<ChannelData*> channel, +// bool group, +// base::lambda<void()> callback) { +// if (const auto already = _channelGroupingRequests.take(channel)) { +// request(already->first).cancel(); +// } +// const auto feedId = Data::Feed::kId; +// const auto flags = group +// ? MTPchannels_ChangeFeedBroadcast::Flag::f_feed_id +// : MTPchannels_ChangeFeedBroadcast::Flag(0); +// const auto requestId = request(MTPchannels_ChangeFeedBroadcast( +// MTP_flags(flags), +// channel->inputChannel, +// MTP_int(feedId) +// )).done([=](const MTPUpdates &result) { +// applyUpdates(result); +// if (group) { +// channel->setFeed(Auth().data().feed(feedId)); +// } else { +// channel->clearFeed(); +// } +// if (const auto data = _channelGroupingRequests.take(channel)) { +// data->second(); +// } +// }).fail([=](const RPCError &error) { +// _channelGroupingRequests.remove(channel); +// }).send(); +// _channelGroupingRequests.emplace(channel, requestId, callback); +//} +// +//void ApiWrap::ungroupAllFromFeed(not_null<Data::Feed*> feed) { +// const auto flags = MTPchannels_SetFeedBroadcasts::Flag::f_channels +// | MTPchannels_SetFeedBroadcasts::Flag::f_also_newly_joined; +// request(MTPchannels_SetFeedBroadcasts( +// MTP_flags(flags), +// MTP_int(feed->id()), +// MTP_vector<MTPInputChannel>(0), +// MTP_bool(false) +// )).done([=](const MTPUpdates &result) { +// applyUpdates(result); +// }).send(); +//} void ApiWrap::sendMessageFail(const RPCError &error) { if (error.type() == qstr("PEER_FLOOD")) { @@ -391,17 +391,17 @@ void ApiWrap::requestDialogEntry(not_null<Data::Feed*> feed) { } _dialogFeedRequests.emplace(feed); - auto peers = QVector<MTPInputDialogPeer>( - 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<MTPInputDialogPeer>( // #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(); } //void ApiWrap::requestFeedDialogsEntries(not_null<Data::Feed*> feed) { @@ -460,11 +460,11 @@ void ApiWrap::applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs) { } } break; - case mtpc_dialogFeed: { - const auto &fields = dialog.c_dialogFeed(); - const auto feed = Auth().data().feed(fields.vfeed_id.v); - feed->applyDialog(fields); - } break; + //case mtpc_dialogFeed: { // #feed + // const auto &fields = dialog.c_dialogFeed(); + // const auto feed = Auth().data().feed(fields.vfeed_id.v); + // feed->applyDialog(fields); + //} break; } } _session->data().sendHistoryChangeNotifications(); @@ -548,9 +548,9 @@ void ApiWrap::applyFeedDialogs( } } } break; - case mtpc_dialogFeed: { - LOG(("API Error: Unexpected dialogFeed in feed dialogs list.")); - } break; + //case mtpc_dialogFeed: { // #feed + // LOG(("API Error: Unexpected dialogFeed in feed dialogs list.")); + //} break; default: Unexpected("Type in DialogsInner::dialogsReceived"); } } @@ -2714,44 +2714,44 @@ void ApiWrap::requestMessageAfterDate( 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>(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; - App::feedUsers(data.vusers); - App::feedChats(data.vchats); - for (const auto &msg : messages) { - if (const auto item = App::histories().addNewMessage(msg, type)) { - if (item->date() >= offsetDate || true) { - callback(item->position()); - return; - } - } - } - callback(Data::UnreadMessagePosition); - }).send(); + //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>(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; + // App::feedUsers(data.vusers); + // App::feedChats(data.vchats); + // for (const auto &msg : messages) { + // if (const auto item = App::histories().addNewMessage(msg, type)) { + // if (item->date() >= offsetDate || true) { + // callback(item->position()); + // return; + // } + // } + // } + // callback(Data::UnreadMessagePosition); + //}).send(); } void ApiWrap::jumpToFeedDate(not_null<Data::Feed*> feed, const QDate &date) { @@ -3032,271 +3032,271 @@ void ApiWrap::userPhotosDone( fullCount )); } - -void ApiWrap::requestFeedChannels(not_null<Data::Feed*> feed) { - if (_feedChannelsGetRequests.contains(feed)) { - return; - } - const auto hash = feed->channelsHash(); - request(MTPchannels_GetFeedSources( - MTP_flags(MTPchannels_GetFeedSources::Flag::f_feed_id), - MTP_int(feed->id()), - MTP_int(hash) - )).done([=](const MTPchannels_FeedSources &result) { - _feedChannelsGetRequests.remove(feed); - - switch (result.type()) { - case mtpc_channels_feedSourcesNotModified: - if (feed->channelsHash() == hash) { - feedChannelsDone(feed); - } else { - requestFeedChannels(feed); - } - break; - - case mtpc_channels_feedSources: { - const auto &data = result.c_channels_feedSources(); - applyFeedSources(data); - if (feed->channelsLoaded()) { - feedChannelsDone(feed); - } else { - LOG(("API Error: feed channels not received for " - ).arg(feed->id())); - } - } break; - - default: Unexpected("Type in channels.getFeedSources response."); - } - }).fail([=](const RPCError &error) { - _feedChannelsGetRequests.remove(feed); - }).send(); - _feedChannelsGetRequests.emplace(feed); -} - -void ApiWrap::applyFeedSources(const MTPDchannels_feedSources &data) { - // First we set channels without reading them from data. - // This allows us to apply them all at once without registering - // them one by one. - for (const auto &broadcasts : data.vfeeds.v) { - if (broadcasts.type() == mtpc_feedBroadcasts) { - const auto &list = broadcasts.c_feedBroadcasts(); - const auto feedId = list.vfeed_id.v; - const auto feed = _session->data().feed(feedId); - auto channels = std::vector<not_null<ChannelData*>>(); - for (const auto &channelId : list.vchannels.v) { - channels.push_back(App::channel(channelId.v)); - } - feed->setChannels(std::move(channels)); - } - } - - App::feedUsers(data.vusers); - App::feedChats(data.vchats); - - if (data.has_newly_joined_feed()) { - _session->data().setDefaultFeedId( - data.vnewly_joined_feed.v); - } -} - -void ApiWrap::setFeedChannels( - not_null<Data::Feed*> feed, - const std::vector<not_null<ChannelData*>> &channels) { - if (const auto already = _feedChannelsSetRequests.take(feed)) { - request(*already).cancel(); - } - auto inputs = QVector<MTPInputChannel>(); - inputs.reserve(channels.size()); - for (const auto channel : channels) { - inputs.push_back(channel->inputChannel); - } - const auto requestId = request(MTPchannels_SetFeedBroadcasts( - MTP_flags(MTPchannels_SetFeedBroadcasts::Flag::f_channels), - MTP_int(feed->id()), - MTP_vector<MTPInputChannel>(inputs), - MTPbool() - )).done([=](const MTPUpdates &result) { - applyUpdates(result); - - _feedChannelsSetRequests.remove(feed); - }).fail([=](const RPCError &error) { - _feedChannelsSetRequests.remove(feed); - }).send(); - -} - -void ApiWrap::feedChannelsDone(not_null<Data::Feed*> feed) { - feed->setChannelsLoaded(true); - for (const auto key : base::take(_feedMessagesRequestsPending)) { - std::apply( - [=](auto&&...args) { requestFeedMessages(args...); }, - key); - } -} - -void ApiWrap::requestFeedMessages( - not_null<Data::Feed*> feed, - Data::MessagePosition messageId, - SliceType slice) { - const auto key = std::make_tuple(feed, messageId, slice); - if (_feedMessagesRequests.contains(key) - || _feedMessagesRequestsPending.contains(key)) { - return; - } - - if (!feed->channelsLoaded()) { - _feedMessagesRequestsPending.emplace(key); - requestFeedChannels(feed); - return; - } - - // We request messages with overlapping and skip overlapped in response. - const auto limit = kFeedMessagesLimit; - const auto addOffset = [&] { - switch (slice) { - case SliceType::Before: return -2; - case SliceType::Around: return -limit / 2; - case SliceType::After: return 1 - limit; - } - Unexpected("Direction in PrepareSearchRequest"); - }(); - const auto hash = int32(0); - const auto flags = (messageId && messageId.fullId.channel) - ? MTPchannels_GetFeed::Flag::f_offset_position - : MTPchannels_GetFeed::Flag::f_offset_to_max_read; - const auto requestId = request(MTPchannels_GetFeed( - MTP_flags(flags), - MTP_int(feed->id()), - MTP_feedPosition( - MTP_int(messageId.date), - MTP_peerChannel(MTP_int(messageId.fullId.channel)), - MTP_int(messageId.fullId.msg)), - MTP_int(addOffset), - MTP_int(limit), - MTPFeedPosition(), - MTPFeedPosition(), - MTP_int(hash) - )).done([=](const MTPmessages_FeedMessages &result) { - const auto key = std::make_tuple(feed, messageId, slice); - _feedMessagesRequests.remove(key); - feedMessagesDone(feed, messageId, slice, result); - }).fail([=](const RPCError &error) { - _feedMessagesRequests.remove(key); - if (error.type() == qstr("SOURCES_HASH_INVALID")) { - _feedMessagesRequestsPending.emplace(key); - requestFeedChannels(feed); - } - }).send(); - _feedMessagesRequests.emplace(key); -} - -void ApiWrap::feedMessagesDone( - not_null<Data::Feed*> feed, - Data::MessagePosition messageId, - SliceType slice, - const MTPmessages_FeedMessages &result) { - if (result.type() == mtpc_messages_feedMessagesNotModified) { - LOG(("API Error: Unexpected messages.feedMessagesNotModified.")); - _session->storage().add(Storage::FeedMessagesAddSlice( - feed->id(), - std::vector<Data::MessagePosition>(), - Data::FullMessagesRange)); - return; - } - Assert(result.type() == mtpc_messages_feedMessages); - const auto &data = result.c_messages_feedMessages(); - const auto &messages = data.vmessages.v; - const auto type = NewMessageExisting; - - auto ids = std::vector<Data::MessagePosition>(); - auto noSkipRange = Data::MessagesRange(messageId, messageId); - const auto accumulateFrom = [](auto &from, const auto &candidate) { - if (!from || from > candidate) { - from = candidate; - } - }; - const auto accumulateTill = [](auto &till, const auto &candidate) { - if (!till || till < candidate) { - till = candidate; - } - }; - const auto tooLargePosition = [&](const auto &position) { - return (slice == SliceType::Before) && !(position < messageId); - }; - const auto tooSmallPosition = [&](const auto &position) { - return (slice == SliceType::After) && !(messageId < position); - }; - App::feedUsers(data.vusers); - App::feedChats(data.vchats); - if (!messages.empty()) { - ids.reserve(messages.size()); - for (const auto &msg : messages) { - if (const auto item = App::histories().addNewMessage(msg, type)) { - const auto position = item->position(); - if (tooLargePosition(position)) { - accumulateTill(noSkipRange.till, position); - continue; - } else if (tooSmallPosition(position)) { - accumulateFrom(noSkipRange.from, position); - continue; - } - ids.push_back(position); - accumulateFrom(noSkipRange.from, position); - accumulateTill(noSkipRange.till, position); - } - } - ranges::reverse(ids); - } - if (data.has_min_position() && !ids.empty()) { - accumulateFrom( - noSkipRange.from, - Data::FeedPositionFromMTP(data.vmin_position)); - } else if (slice == SliceType::Before) { - noSkipRange.from = Data::MinMessagePosition; - } - if (data.has_max_position() && !ids.empty()) { - accumulateTill( - noSkipRange.till, - Data::FeedPositionFromMTP(data.vmax_position)); - } else if (slice == SliceType::After) { - noSkipRange.till = Data::MaxMessagePosition; - } - - const auto unreadPosition = [&] { - if (data.has_read_max_position()) { - return Data::FeedPositionFromMTP(data.vread_max_position); - } else if (!messageId) { - const auto result = ids.empty() - ? noSkipRange.till - : ids.back(); - return Data::MessagePosition( - result.date, - FullMsgId(result.fullId.channel, result.fullId.msg - 1)); - } - return Data::MessagePosition(); - }(); - - _session->storage().add(Storage::FeedMessagesAddSlice( - feed->id(), - std::move(ids), - noSkipRange)); - - if (unreadPosition) { - feed->setUnreadPosition(unreadPosition); - } -} - -void ApiWrap::saveDefaultFeedId(FeedId id, bool isDefaultFeedId) { - if (const auto already = base::take(_saveDefaultFeedIdRequest)) { - request(already).cancel(); - } - _saveDefaultFeedIdRequest = request(MTPchannels_SetFeedBroadcasts( - MTP_flags(MTPchannels_SetFeedBroadcasts::Flag::f_also_newly_joined), - MTP_int(id), - MTPVector<MTPInputChannel>(), - MTP_bool(isDefaultFeedId) - )).send(); -} +// #feed +//void ApiWrap::requestFeedChannels(not_null<Data::Feed*> feed) { +// if (_feedChannelsGetRequests.contains(feed)) { +// return; +// } +// const auto hash = feed->channelsHash(); +// request(MTPchannels_GetFeedSources( +// MTP_flags(MTPchannels_GetFeedSources::Flag::f_feed_id), +// MTP_int(feed->id()), +// MTP_int(hash) +// )).done([=](const MTPchannels_FeedSources &result) { +// _feedChannelsGetRequests.remove(feed); +// +// switch (result.type()) { +// case mtpc_channels_feedSourcesNotModified: +// if (feed->channelsHash() == hash) { +// feedChannelsDone(feed); +// } else { +// requestFeedChannels(feed); +// } +// break; +// +// case mtpc_channels_feedSources: { +// const auto &data = result.c_channels_feedSources(); +// applyFeedSources(data); +// if (feed->channelsLoaded()) { +// feedChannelsDone(feed); +// } else { +// LOG(("API Error: feed channels not received for " +// ).arg(feed->id())); +// } +// } break; +// +// default: Unexpected("Type in channels.getFeedSources response."); +// } +// }).fail([=](const RPCError &error) { +// _feedChannelsGetRequests.remove(feed); +// }).send(); +// _feedChannelsGetRequests.emplace(feed); +//} +// +//void ApiWrap::applyFeedSources(const MTPDchannels_feedSources &data) { +// // First we set channels without reading them from data. +// // This allows us to apply them all at once without registering +// // them one by one. +// for (const auto &broadcasts : data.vfeeds.v) { +// if (broadcasts.type() == mtpc_feedBroadcasts) { +// const auto &list = broadcasts.c_feedBroadcasts(); +// const auto feedId = list.vfeed_id.v; +// const auto feed = _session->data().feed(feedId); +// auto channels = std::vector<not_null<ChannelData*>>(); +// for (const auto &channelId : list.vchannels.v) { +// channels.push_back(App::channel(channelId.v)); +// } +// feed->setChannels(std::move(channels)); +// } +// } +// +// App::feedUsers(data.vusers); +// App::feedChats(data.vchats); +// +// if (data.has_newly_joined_feed()) { +// _session->data().setDefaultFeedId( +// data.vnewly_joined_feed.v); +// } +//} +// +//void ApiWrap::setFeedChannels( +// not_null<Data::Feed*> feed, +// const std::vector<not_null<ChannelData*>> &channels) { +// if (const auto already = _feedChannelsSetRequests.take(feed)) { +// request(*already).cancel(); +// } +// auto inputs = QVector<MTPInputChannel>(); +// inputs.reserve(channels.size()); +// for (const auto channel : channels) { +// inputs.push_back(channel->inputChannel); +// } +// const auto requestId = request(MTPchannels_SetFeedBroadcasts( +// MTP_flags(MTPchannels_SetFeedBroadcasts::Flag::f_channels), +// MTP_int(feed->id()), +// MTP_vector<MTPInputChannel>(inputs), +// MTPbool() +// )).done([=](const MTPUpdates &result) { +// applyUpdates(result); +// +// _feedChannelsSetRequests.remove(feed); +// }).fail([=](const RPCError &error) { +// _feedChannelsSetRequests.remove(feed); +// }).send(); +// +//} +// +//void ApiWrap::feedChannelsDone(not_null<Data::Feed*> feed) { +// feed->setChannelsLoaded(true); +// for (const auto key : base::take(_feedMessagesRequestsPending)) { +// std::apply( +// [=](auto&&...args) { requestFeedMessages(args...); }, +// key); +// } +//} +// +//void ApiWrap::requestFeedMessages( +// not_null<Data::Feed*> feed, +// Data::MessagePosition messageId, +// SliceType slice) { +// const auto key = std::make_tuple(feed, messageId, slice); +// if (_feedMessagesRequests.contains(key) +// || _feedMessagesRequestsPending.contains(key)) { +// return; +// } +// +// if (!feed->channelsLoaded()) { +// _feedMessagesRequestsPending.emplace(key); +// requestFeedChannels(feed); +// return; +// } +// +// // We request messages with overlapping and skip overlapped in response. +// const auto limit = kFeedMessagesLimit; +// const auto addOffset = [&] { +// switch (slice) { +// case SliceType::Before: return -2; +// case SliceType::Around: return -limit / 2; +// case SliceType::After: return 1 - limit; +// } +// Unexpected("Direction in PrepareSearchRequest"); +// }(); +// const auto hash = int32(0); +// const auto flags = (messageId && messageId.fullId.channel) +// ? MTPchannels_GetFeed::Flag::f_offset_position +// : MTPchannels_GetFeed::Flag::f_offset_to_max_read; +// const auto requestId = request(MTPchannels_GetFeed( +// MTP_flags(flags), +// MTP_int(feed->id()), +// MTP_feedPosition( +// MTP_int(messageId.date), +// MTP_peerChannel(MTP_int(messageId.fullId.channel)), +// MTP_int(messageId.fullId.msg)), +// MTP_int(addOffset), +// MTP_int(limit), +// MTPFeedPosition(), +// MTPFeedPosition(), +// MTP_int(hash) +// )).done([=](const MTPmessages_FeedMessages &result) { +// const auto key = std::make_tuple(feed, messageId, slice); +// _feedMessagesRequests.remove(key); +// feedMessagesDone(feed, messageId, slice, result); +// }).fail([=](const RPCError &error) { +// _feedMessagesRequests.remove(key); +// if (error.type() == qstr("SOURCES_HASH_INVALID")) { +// _feedMessagesRequestsPending.emplace(key); +// requestFeedChannels(feed); +// } +// }).send(); +// _feedMessagesRequests.emplace(key); +//} +// +//void ApiWrap::feedMessagesDone( +// not_null<Data::Feed*> feed, +// Data::MessagePosition messageId, +// SliceType slice, +// const MTPmessages_FeedMessages &result) { +// if (result.type() == mtpc_messages_feedMessagesNotModified) { +// LOG(("API Error: Unexpected messages.feedMessagesNotModified.")); +// _session->storage().add(Storage::FeedMessagesAddSlice( +// feed->id(), +// std::vector<Data::MessagePosition>(), +// Data::FullMessagesRange)); +// return; +// } +// Assert(result.type() == mtpc_messages_feedMessages); +// const auto &data = result.c_messages_feedMessages(); +// const auto &messages = data.vmessages.v; +// const auto type = NewMessageExisting; +// +// auto ids = std::vector<Data::MessagePosition>(); +// auto noSkipRange = Data::MessagesRange(messageId, messageId); +// const auto accumulateFrom = [](auto &from, const auto &candidate) { +// if (!from || from > candidate) { +// from = candidate; +// } +// }; +// const auto accumulateTill = [](auto &till, const auto &candidate) { +// if (!till || till < candidate) { +// till = candidate; +// } +// }; +// const auto tooLargePosition = [&](const auto &position) { +// return (slice == SliceType::Before) && !(position < messageId); +// }; +// const auto tooSmallPosition = [&](const auto &position) { +// return (slice == SliceType::After) && !(messageId < position); +// }; +// App::feedUsers(data.vusers); +// App::feedChats(data.vchats); +// if (!messages.empty()) { +// ids.reserve(messages.size()); +// for (const auto &msg : messages) { +// if (const auto item = App::histories().addNewMessage(msg, type)) { +// const auto position = item->position(); +// if (tooLargePosition(position)) { +// accumulateTill(noSkipRange.till, position); +// continue; +// } else if (tooSmallPosition(position)) { +// accumulateFrom(noSkipRange.from, position); +// continue; +// } +// ids.push_back(position); +// accumulateFrom(noSkipRange.from, position); +// accumulateTill(noSkipRange.till, position); +// } +// } +// ranges::reverse(ids); +// } +// if (data.has_min_position() && !ids.empty()) { +// accumulateFrom( +// noSkipRange.from, +// Data::FeedPositionFromMTP(data.vmin_position)); +// } else if (slice == SliceType::Before) { +// noSkipRange.from = Data::MinMessagePosition; +// } +// if (data.has_max_position() && !ids.empty()) { +// accumulateTill( +// noSkipRange.till, +// Data::FeedPositionFromMTP(data.vmax_position)); +// } else if (slice == SliceType::After) { +// noSkipRange.till = Data::MaxMessagePosition; +// } +// +// const auto unreadPosition = [&] { +// if (data.has_read_max_position()) { +// return Data::FeedPositionFromMTP(data.vread_max_position); +// } else if (!messageId) { +// const auto result = ids.empty() +// ? noSkipRange.till +// : ids.back(); +// return Data::MessagePosition( +// result.date, +// FullMsgId(result.fullId.channel, result.fullId.msg - 1)); +// } +// return Data::MessagePosition(); +// }(); +// +// _session->storage().add(Storage::FeedMessagesAddSlice( +// feed->id(), +// std::move(ids), +// noSkipRange)); +// +// if (unreadPosition) { +// feed->setUnreadPosition(unreadPosition); +// } +//} +// +//void ApiWrap::saveDefaultFeedId(FeedId id, bool isDefaultFeedId) { +// if (const auto already = base::take(_saveDefaultFeedIdRequest)) { +// request(already).cancel(); +// } +// _saveDefaultFeedIdRequest = request(MTPchannels_SetFeedBroadcasts( +// MTP_flags(MTPchannels_SetFeedBroadcasts::Flag::f_also_newly_joined), +// MTP_int(id), +// MTPVector<MTPInputChannel>(), +// MTP_bool(isDefaultFeedId) +// )).send(); +//} void ApiWrap::sendAction(const SendOptions &options) { readServerHistory(options.history); @@ -3936,38 +3936,38 @@ void ApiWrap::readFeed( void ApiWrap::readFeeds() { auto delay = kFeedReadTimeout; const auto now = getms(true); - 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); + //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); - } + // i = _feedReadsDelayed.erase(i); + // } + //} + //if (!_feedReadsDelayed.empty()) { + // _feedReadTimer.callOnce(delay); + //} } void ApiWrap::sendReadRequest(not_null<PeerData*> peer, MsgId upTo) { diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index 77bd1f991..78edf5946 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -60,11 +60,11 @@ public: void applyUpdates(const MTPUpdates &updates, uint64 sentMessageRandomId = 0); void savePinnedOrder(); - void toggleChannelGrouping( - not_null<ChannelData*> channel, - bool group, - base::lambda<void()> callback); - void ungroupAllFromFeed(not_null<Data::Feed*> feed); + //void toggleChannelGrouping( // #feed + // not_null<ChannelData*> channel, + // bool group, + // base::lambda<void()> callback); + //void ungroupAllFromFeed(not_null<Data::Feed*> feed); using RequestMessageDataCallback = base::lambda<void(ChannelData*, MsgId)>; void requestMessageData( @@ -76,10 +76,10 @@ public: void requestDialogEntry(not_null<Data::Feed*> feed); //void requestFeedDialogsEntries(not_null<Data::Feed*> feed); void requestDialogEntry(not_null<History*> history); - void applyFeedSources(const MTPDchannels_feedSources &data); - void setFeedChannels( - not_null<Data::Feed*> feed, - const std::vector<not_null<ChannelData*>> &channels); + //void applyFeedSources(const MTPDchannels_feedSources &data); // #feed + //void setFeedChannels( + // not_null<Data::Feed*> feed, + // const std::vector<not_null<ChannelData*>> &channels); void requestFullPeer(PeerData *peer); void requestPeer(PeerData *peer); @@ -180,13 +180,13 @@ public: not_null<UserData*> user, PhotoId afterId); - void requestFeedChannels( - not_null<Data::Feed*> feed); - void requestFeedMessages( - not_null<Data::Feed*> feed, - Data::MessagePosition messageId, - SliceType slice); - void saveDefaultFeedId(FeedId id, bool isDefaultFeedId); + //void requestFeedChannels( // #feed + // not_null<Data::Feed*> feed); + //void requestFeedMessages( + // not_null<Data::Feed*> feed, + // Data::MessagePosition messageId, + // SliceType slice); + //void saveDefaultFeedId(FeedId id, bool isDefaultFeedId); void stickerSetInstalled(uint64 setId) { _stickerSetInstalled.fire_copy(setId); @@ -375,12 +375,12 @@ private: PhotoId photoId, const MTPphotos_Photos &result); - void feedChannelsDone(not_null<Data::Feed*> feed); - void feedMessagesDone( - not_null<Data::Feed*> feed, - Data::MessagePosition messageId, - SliceType slice, - const MTPmessages_FeedMessages &result); + //void feedChannelsDone(not_null<Data::Feed*> feed); // #feed + //void feedMessagesDone( + // not_null<Data::Feed*> feed, + // Data::MessagePosition messageId, + // SliceType slice, + // const MTPmessages_FeedMessages &result); void sendSharedContact( const QString &phone, diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index 52787fe33..f508c5c15 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -563,11 +563,11 @@ namespace { cdata->setRestrictionReason(QString()); } cdata->setFlags(d.vflags.v); - if (d.has_feed_id()) { - cdata->setFeed(Auth().data().feed(d.vfeed_id.v)); - } else { - cdata->clearFeed(); - } + //if (d.has_feed_id()) { // #feed + // cdata->setFeed(Auth().data().feed(d.vfeed_id.v)); + //} else { + // cdata->clearFeed(); + //} } QString uname = d.has_username() ? TextUtilities::SingleLine(qs(d.vusername)) : QString(); diff --git a/Telegram/SourceFiles/data/data_feed.cpp b/Telegram/SourceFiles/data/data_feed.cpp index 0aeb59b1c..ac850955a 100644 --- a/Telegram/SourceFiles/data/data_feed.cpp +++ b/Telegram/SourceFiles/data/data_feed.cpp @@ -20,14 +20,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Data { -MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position) { - Expects(position.type() == mtpc_feedPosition); - - const auto &data = position.c_feedPosition(); - return MessagePosition(data.vdate.v, FullMsgId( - peerToChannel(peerFromMTP(data.vpeer)), - data.vid.v)); -} +// #feed +//MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position) { +// Expects(position.type() == mtpc_feedPosition); +// +// const auto &data = position.c_feedPosition(); +// return MessagePosition(data.vdate.v, FullMsgId( +// peerToChannel(peerFromMTP(data.vpeer)), +// data.vid.v)); +//} Feed::Feed(FeedId id, not_null<Data::Session*> parent) : Entry(this) @@ -328,36 +329,36 @@ rpl::producer<int> Feed::unreadCountValue() const { bool Feed::unreadCountKnown() const { return !!_unreadCount; } - -void Feed::applyDialog(const MTPDdialogFeed &data) { - const auto addChannel = [&](ChannelId channelId) { - if (const auto channel = App::channelLoaded(channelId)) { - channel->setFeed(this); - } - }; - for (const auto &channelId : data.vfeed_other_channels.v) { - addChannel(channelId.v); - } - - _lastMessage = nullptr; - if (const auto peerId = peerFromMTP(data.vpeer)) { - if (const auto channelId = peerToChannel(peerId)) { - addChannel(channelId); - const auto fullId = FullMsgId(channelId, data.vtop_message.v); - if (const auto item = App::histItemById(fullId)) { - justUpdateLastMessage(item); - } - } - } - updateChatsListDate(); - - setUnreadCounts( - data.vunread_count.v, - data.vunread_muted_count.v); - if (data.has_read_max_position()) { - setUnreadPosition(FeedPositionFromMTP(data.vread_max_position)); - } -} +// #feed +//void Feed::applyDialog(const MTPDdialogFeed &data) { +// const auto addChannel = [&](ChannelId channelId) { +// if (const auto channel = App::channelLoaded(channelId)) { +// channel->setFeed(this); +// } +// }; +// for (const auto &channelId : data.vfeed_other_channels.v) { +// addChannel(channelId.v); +// } +// +// _lastMessage = nullptr; +// if (const auto peerId = peerFromMTP(data.vpeer)) { +// if (const auto channelId = peerToChannel(peerId)) { +// addChannel(channelId); +// const auto fullId = FullMsgId(channelId, data.vtop_message.v); +// if (const auto item = App::histItemById(fullId)) { +// justUpdateLastMessage(item); +// } +// } +// } +// updateChatsListDate(); +// +// setUnreadCounts( +// data.vunread_count.v, +// data.vunread_muted_count.v); +// if (data.has_read_max_position()) { +// setUnreadPosition(FeedPositionFromMTP(data.vread_max_position)); +// } +//} void Feed::changedInChatListHook(Dialogs::Mode list, bool added) { if (list == Dialogs::Mode::All && unreadCount()) { diff --git a/Telegram/SourceFiles/data/data_feed.h b/Telegram/SourceFiles/data/data_feed.h index 12bf51208..806724326 100644 --- a/Telegram/SourceFiles/data/data_feed.h +++ b/Telegram/SourceFiles/data/data_feed.h @@ -27,7 +27,7 @@ struct FeedUpdate { FeedUpdateFlag flag; }; -MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); +//MessagePosition FeedPositionFromMTP(const MTPFeedPosition &position); // #feed class Feed : public Dialogs::Entry { public: @@ -44,7 +44,7 @@ public: void messageRemoved(not_null<HistoryItem*> item); void historyCleared(not_null<History*> history); - void applyDialog(const MTPDdialogFeed &data); + //void applyDialog(const MTPDdialogFeed &data); // #feed void setUnreadCounts(int unreadNonMutedCount, int unreadMutedCount); void setUnreadPosition(const MessagePosition &position); void unreadCountChanged( diff --git a/Telegram/SourceFiles/data/data_feed_messages.cpp b/Telegram/SourceFiles/data/data_feed_messages.cpp index 11332e5fa..4f4d9da52 100644 --- a/Telegram/SourceFiles/data/data_feed_messages.cpp +++ b/Telegram/SourceFiles/data/data_feed_messages.cpp @@ -31,10 +31,10 @@ rpl::producer<MessagesSlice> FeedMessagesViewer( using AroundData = MessagesSliceBuilder::AroundData; const auto requestMediaAround = [=](const AroundData &data) { if (data.aroundId || !key.position) { - Auth().api().requestFeedMessages( - feed, - data.aroundId, - data.direction); + //Auth().api().requestFeedMessages( // #feed + // feed, + // data.aroundId, + // data.direction); } }; builder->insufficientAround( diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index c3d2f8b7d..5f670542a 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -426,11 +426,11 @@ void Session::applyPinnedDialogs(const QVector<MTPDialog> &list) { } } break; - case mtpc_dialogFeed: { - const auto &feedData = dialog.c_dialogFeed(); - const auto feedId = feedData.vfeed_id.v; - setPinnedDialog(feed(feedId), 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."); } @@ -448,11 +448,11 @@ void Session::applyPinnedDialogs(const QVector<MTPDialogPeer> &list) { setPinnedDialog(App::history(peerId), true); } } break; - case mtpc_dialogPeerFeed: { - const auto &feedData = dialogPeer.c_dialogPeerFeed(); - const auto feedId = feedData.vfeed_id.v; - setPinnedDialog(feed(feedId), true); - } break; + //case mtpc_dialogPeerFeed: { // #feed + // const auto &feedData = dialogPeer.c_dialogPeerFeed(); + // const auto feedId = feedData.vfeed_id.v; + // setPinnedDialog(feed(feedId), true); + //} break; } } } diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 5578d2bc5..2a8c3c154 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -1754,7 +1754,7 @@ void DialogsInner::dialogsReceived(const QVector<MTPDialog> &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; + //case mtpc_dialogFeed: applyFeedDialog(dialog.c_dialogFeed()); break; // #feed default: Unexpected("Type in DialogsInner::dialogsReceived"); } } @@ -1787,19 +1787,19 @@ void DialogsInner::applyDialog(const MTPDdialog &dialog) { } } } - -void DialogsInner::applyFeedDialog(const MTPDdialogFeed &dialog) { - const auto feedId = dialog.vfeed_id.v; - const auto feed = Auth().data().feed(feedId); - feed->applyDialog(dialog); - - if (!feed->isPinnedDialog()) { - const auto date = feed->chatsListDate(); - if (!date.isNull()) { - addSavedPeersAfter(date); - } - } -} +// #feed +//void DialogsInner::applyFeedDialog(const MTPDdialogFeed &dialog) { +// const auto feedId = dialog.vfeed_id.v; +// const auto feed = Auth().data().feed(feedId); +// feed->applyDialog(dialog); +// +// if (!feed->isPinnedDialog()) { +// const auto date = feed->chatsListDate(); +// if (!date.isNull()) { +// addSavedPeersAfter(date); +// } +// } +//} void DialogsInner::addSavedPeersAfter(const QDateTime &date) { auto &saved = cRefSavedPeersByTime(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index 67e8b8532..46de6c91f 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -193,7 +193,7 @@ private: const base::flat_set<QChar> &oldLetters); void applyDialog(const MTPDdialog &dialog); - void applyFeedDialog(const MTPDdialogFeed &dialog); +// void applyFeedDialog(const MTPDdialogFeed &dialog); // #feed void itemRemoved(not_null<const HistoryItem*> item); enum class UpdateRowSection { diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 77b355607..f8aee8a80 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -389,7 +389,7 @@ void DialogsWidget::updateDialogsOffset( const auto &dialog = dialogs[--i]; switch (dialog.type()) { case mtpc_dialog: fillFromDialog(dialog.c_dialog()); break; - case mtpc_dialogFeed: fillFromDialog(dialog.c_dialogFeed()); break; +// case mtpc_dialogFeed: fillFromDialog(dialog.c_dialogFeed()); break; // #feed default: Unexpected("Type in DialogsWidget::updateDialogsOffset"); } if (lastDate) { @@ -518,16 +518,16 @@ bool DialogsWidget::onSearchMessages(bool searchCache) { rpcDone(&DialogsWidget::searchReceived, DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, DialogsSearchPeerFromStart)); } else if (const auto feed = _searchInChat.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)); + //_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 { _searchRequest = MTP::send( MTPmessages_SearchGlobal( @@ -637,18 +637,18 @@ void DialogsWidget::onSearchMore() { rpcDone(&DialogsWidget::searchReceived, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart), rpcFail(&DialogsWidget::searchFailed, offsetId ? DialogsSearchPeerFromOffset : DialogsSearchPeerFromStart)); } else if (const auto feed = _searchInChat.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)); + //_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 { _searchRequest = MTP::send( MTPmessages_SearchGlobal( @@ -707,7 +707,7 @@ void DialogsWidget::loadDialogs() { _dialogsRequestId = MTP::send( MTPmessages_GetDialogs( MTP_flags(flags), - MTP_int(feedId), + //MTP_int(feedId), // #feed MTP_int(_dialogsOffsetDate), MTP_int(_dialogsOffsetId), _dialogsOffsetPeer diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index b503d2bb8..f755dd41d 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -37,9 +37,9 @@ void AddToggleGroupingAction( not_null<PeerData*> peer) { if (const auto channel = peer->asChannel()) { const auto grouped = (channel->feed() != nullptr); - menu->addAction( - lang(grouped ? lng_feed_ungroup : lng_feed_group), - [=] { Window::ToggleChannelGrouping(channel, !grouped); }); + //menu->addAction( // #feed + // lang(grouped ? lng_feed_ungroup : lng_feed_group), + // [=] { Window::ToggleChannelGrouping(channel, !grouped); }); } } diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 418ee1a4c..382c6f872 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -2406,7 +2406,7 @@ void ListWidget::refreshItem(not_null<const Element*> view) { if (const auto i = _views.find(item); i != end(_views)) { auto result = std::move(i->second); _views.erase(i); - return std::move(result); + return result; } return nullptr; }(); diff --git a/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp b/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp index 1631b8192..c75e85719 100644 --- a/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp +++ b/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.cpp @@ -96,7 +96,7 @@ ChannelsController::ChannelsController(not_null<Controller*> controller) , _controller(controller) , _feed(_controller->key().feed()) { if (!_feed->channelsLoaded()) { - Auth().api().requestFeedChannels(_feed); +// Auth().api().requestFeedChannels(_feed); // #feed } _controller->setSearchEnabledByContent(false); } @@ -198,9 +198,9 @@ base::unique_qptr<Ui::PopupMenu> ChannelsController::rowContextMenu( base::lambda<void()> handler) { return result->addAction(text, handler); }); - result->addAction( - lang(lng_feed_ungroup), - [=] { Window::ToggleChannelGrouping(channel, false); }); + //result->addAction( // #feed + // lang(lng_feed_ungroup), + // [=] { Window::ToggleChannelGrouping(channel, false); }); result->addAction( lang(lng_profile_leave_channel), @@ -252,19 +252,19 @@ void NotificationsController::loadMoreRows() { if (_preloadRequestId || _allLoaded) { return; } - _preloadRequestId = request(MTPmessages_GetDialogs( - MTP_flags(MTPmessages_GetDialogs::Flag::f_feed_id), - MTP_int(_feed->id()), - MTP_int(_preloadOffsetDate), - MTP_int(_preloadOffsetId), - _preloadPeer ? _preloadPeer->input : MTP_inputPeerEmpty(), - MTP_int(Data::Feed::kChannelsLimit) - )).done([=](const MTPmessages_Dialogs &result) { - applyFeedDialogs(result); - _preloadRequestId = 0; - }).fail([=](const RPCError &error) { - _preloadRequestId = 0; - }).send(); + //_preloadRequestId = request(MTPmessages_GetDialogs( // #feed + // MTP_flags(MTPmessages_GetDialogs::Flag::f_feed_id), + // MTP_int(_feed->id()), + // MTP_int(_preloadOffsetDate), + // MTP_int(_preloadOffsetId), + // _preloadPeer ? _preloadPeer->input : MTP_inputPeerEmpty(), + // MTP_int(Data::Feed::kChannelsLimit) + //)).done([=](const MTPmessages_Dialogs &result) { + // applyFeedDialogs(result); + // _preloadRequestId = 0; + //}).fail([=](const RPCError &error) { + // _preloadRequestId = 0; + //}).send(); } void NotificationsController::applyFeedDialogs( @@ -310,9 +310,9 @@ void NotificationsController::applyFeedDialogs( } } } break; - case mtpc_dialogFeed: { - LOG(("API Error: Unexpected dialogFeed in feed dialogs list.")); - } break; + //case mtpc_dialogFeed: { // #feed + // LOG(("API Error: Unexpected dialogFeed in feed dialogs list.")); + //} break; default: Unexpected("Type in DialogsInner::dialogsReceived"); } } @@ -360,7 +360,7 @@ void EditController::Start( return; } box->closeBox(); - Auth().api().setFeedChannels(feed, channels); + //Auth().api().setFeedChannels(feed, channels); // #feed }); box->addButton(langFactory(lng_cancel), [box] { box->closeBox(); }); }; @@ -372,8 +372,8 @@ void EditController::Start( EditController::EditController( not_null<Data::Feed*> feed, ChannelData *channel) -: _feed(feed) -, _startWithChannel(channel) { +: _feed(feed) { +//, _startWithChannel(channel) { // #feed } void EditController::prepare() { @@ -391,62 +391,62 @@ void EditController::loadMoreRows() { if (_preloadRequestId || _allLoaded) { return; } - const auto hash = 0; - _preloadRequestId = request(MTPchannels_GetFeedSources( - MTP_flags(0), - MTP_int(0), - MTP_int(hash) - )).done([=](const MTPchannels_FeedSources &result) { - applyFeedSources(result); - _preloadRequestId = 0; - }).fail([=](const RPCError &error) { - _preloadRequestId = 0; - }).send(); -} - -void EditController::applyFeedSources( - const MTPchannels_FeedSources &result) { - auto channels = std::vector<not_null<ChannelData*>>(); - - switch (result.type()) { - case mtpc_channels_feedSourcesNotModified: - LOG(("API Error: Unexpected channels.feedSourcesNotModified.")); - break; - - case mtpc_channels_feedSources: { - const auto &data = result.c_channels_feedSources(); - Auth().api().applyFeedSources(data); - - for (const auto &chat : data.vchats.v) { - if (chat.type() == mtpc_channel) { - channels.push_back(App::channel(chat.c_channel().vid.v)); - } - } - } break; - - default: Unexpected("Type in channels.getFeedSources response."); - } - - _allLoaded = true; - if (channels.size() < kChannelsInFeedMin) { - setDescriptionText(lng_feed_too_few_channels( - lt_count, - kChannelsInFeedMin)); - delegate()->peerListSetSearchMode(PeerListSearchMode::Disabled); - } else { - auto alreadyInFeed = ranges::view::all( - channels - ) | ranges::view::filter([&](not_null<ChannelData*> channel) { - return (channel->feed() == _feed) - || (channel == _startWithChannel); - }); - delegate()->peerListAddSelectedRows(alreadyInFeed); - for (const auto channel : channels) { - delegate()->peerListAppendRow(createRow(channel)); - } - } - delegate()->peerListRefreshRows(); + //const auto hash = 0; // #feed + //_preloadRequestId = request(MTPchannels_GetFeedSources( + // MTP_flags(0), + // MTP_int(0), + // MTP_int(hash) + //)).done([=](const MTPchannels_FeedSources &result) { + // applyFeedSources(result); + // _preloadRequestId = 0; + //}).fail([=](const RPCError &error) { + // _preloadRequestId = 0; + //}).send(); } +// #feed +//void EditController::applyFeedSources( +// const MTPchannels_FeedSources &result) { +// auto channels = std::vector<not_null<ChannelData*>>(); +// +// switch (result.type()) { +// case mtpc_channels_feedSourcesNotModified: +// LOG(("API Error: Unexpected channels.feedSourcesNotModified.")); +// break; +// +// case mtpc_channels_feedSources: { +// const auto &data = result.c_channels_feedSources(); +// Auth().api().applyFeedSources(data); +// +// for (const auto &chat : data.vchats.v) { +// if (chat.type() == mtpc_channel) { +// channels.push_back(App::channel(chat.c_channel().vid.v)); +// } +// } +// } break; +// +// default: Unexpected("Type in channels.getFeedSources response."); +// } +// +// _allLoaded = true; +// if (channels.size() < kChannelsInFeedMin) { +// setDescriptionText(lng_feed_too_few_channels( +// lt_count, +// kChannelsInFeedMin)); +// delegate()->peerListSetSearchMode(PeerListSearchMode::Disabled); +// } else { +// auto alreadyInFeed = ranges::view::all( +// channels +// ) | ranges::view::filter([&](not_null<ChannelData*> channel) { +// return (channel->feed() == _feed) +// || (channel == _startWithChannel); +// }); +// delegate()->peerListAddSelectedRows(alreadyInFeed); +// for (const auto channel : channels) { +// delegate()->peerListAppendRow(createRow(channel)); +// } +// } +// delegate()->peerListRefreshRows(); +//} void EditController::rowClicked(not_null<PeerListRow*> row) { delegate()->peerListSetRowChecked(row, !row->checked()); diff --git a/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.h b/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.h index f8c934df6..4f5af6943 100644 --- a/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.h +++ b/Telegram/SourceFiles/info/feed/info_feed_channels_controllers.h @@ -71,9 +71,9 @@ private: not_null<Data::Feed*> _feed; mtpRequestId _preloadRequestId = 0; - TimeId _preloadOffsetDate = TimeId(0); - MsgId _preloadOffsetId = MsgId(0); - PeerData *_preloadPeer = nullptr; + //TimeId _preloadOffsetDate = TimeId(0); // #feed + //MsgId _preloadOffsetId = MsgId(0); + //PeerData *_preloadPeer = nullptr; bool _allLoaded = false; }; @@ -97,10 +97,10 @@ public: private: std::unique_ptr<PeerListRow> createRow(not_null<ChannelData*> channel); - void applyFeedSources(const MTPchannels_FeedSources &result); +// void applyFeedSources(const MTPchannels_FeedSources &result); // #feed not_null<Data::Feed*> _feed; - ChannelData *_startWithChannel = nullptr; +// ChannelData *_startWithChannel = nullptr; // #feed mtpRequestId _preloadRequestId = 0; bool _allLoaded = false; diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index f451bda3c..bdac933f3 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -715,7 +715,7 @@ object_ptr<Ui::RpWidget> FeedDetailsFiller::setupDefaultToggle() { const auto makeDefault = (Auth().data().defaultFeedId() != feedId); const auto defaultFeedId = makeDefault ? feedId : 0; Auth().data().setDefaultFeedId(defaultFeedId); - Auth().api().saveDefaultFeedId(feedId, makeDefault); +// Auth().api().saveDefaultFeedId(feedId, makeDefault); // #feed }); object_ptr<FloatingIcon>( result, diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 086ec7b37..dbe0d8f11 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -4686,21 +4686,21 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { } } break; - case mtpc_updateReadFeed: { - const auto &d = update.c_updateReadFeed(); - const auto feedId = d.vfeed_id.v; - if (const auto feed = Auth().data().feedLoaded(feedId)) { - feed->setUnreadPosition( - Data::FeedPositionFromMTP(d.vmax_position)); - if (d.has_unread_count() && d.has_unread_muted_count()) { - feed->setUnreadCounts( - d.vunread_count.v, - d.vunread_muted_count.v); - } else { - Auth().api().requestDialogEntry(feed); - } - } - } break; + //case mtpc_updateReadFeed: { // #feed + // const auto &d = update.c_updateReadFeed(); + // const auto feedId = d.vfeed_id.v; + // if (const auto feed = Auth().data().feedLoaded(feedId)) { + // feed->setUnreadPosition( + // Data::FeedPositionFromMTP(d.vmax_position)); + // if (d.has_unread_count() && d.has_unread_muted_count()) { + // feed->setUnreadCounts( + // d.vunread_count.v, + // d.vunread_muted_count.v); + // } else { + // Auth().api().requestDialogEntry(feed); + // } + // } + //} break; // Deleted messages. case mtpc_updateDeleteMessages: { @@ -4987,17 +4987,17 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { return false; } } break; - case mtpc_dialogPeerFeed: { - const auto &feed = dialogPeer.c_dialogPeerFeed(); - const auto feedId = feed.vfeed_id.v; - if (!Auth().data().feedLoaded(feedId)) { - DEBUG_LOG(("API Error: " - "pinned feed not loaded for feedId %1" - ).arg(feedId - )); - return false; - } - } break; + //case mtpc_dialogPeerFeed: { // #feed + // const auto &feed = dialogPeer.c_dialogPeerFeed(); + // const auto feedId = feed.vfeed_id.v; + // if (!Auth().data().feedLoaded(feedId)) { + // DEBUG_LOG(("API Error: " + // "pinned feed not loaded for feedId %1" + // ).arg(feedId + // )); + // return false; + // } + //} break; } } return true; @@ -5027,18 +5027,18 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { _dialogs->loadPinnedDialogs(); } } break; - case mtpc_dialogPeerFeed: { - const auto feedId = d.vpeer.c_dialogPeerFeed().vfeed_id.v; - if (const auto feed = Auth().data().feedLoaded(feedId)) { - Auth().data().setPinnedDialog(feed, d.is_pinned()); - } else { - DEBUG_LOG(("API Error: " - "pinned feed not loaded for feedId %1" - ).arg(feedId - )); - _dialogs->loadPinnedDialogs(); - } - } break; + //case mtpc_dialogPeerFeed: { // #feed + // const auto feedId = d.vpeer.c_dialogPeerFeed().vfeed_id.v; + // if (const auto feed = Auth().data().feedLoaded(feedId)) { + // Auth().data().setPinnedDialog(feed, d.is_pinned()); + // } else { + // DEBUG_LOG(("API Error: " + // "pinned feed not loaded for feedId %1" + // ).arg(feedId + // )); + // _dialogs->loadPinnedDialogs(); + // } + //} break; } } break; diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 9ca8e50f2..a844ec428 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -138,11 +138,16 @@ void TogglePinnedDialog(Dialogs::Key key) { if (isPinned) { flags |= MTPmessages_ToggleDialogPin::Flag::f_pinned; } - MTP::send(MTPmessages_ToggleDialogPin( - MTP_flags(flags), - key.history() - ? MTP_inputDialogPeer(key.history()->peer->input) - : MTP_inputDialogPeerFeed(MTP_int(key.feed()->id())))); + //MTP::send(MTPmessages_ToggleDialogPin( // #feed + // MTP_flags(flags), + // key.history() + // ? MTP_inputDialogPeer(key.history()->peer->input) + // : MTP_inputDialogPeerFeed(MTP_int(key.feed()->id())))); + if (key.history()) { + MTP::send(MTPmessages_ToggleDialogPin( + MTP_flags(flags), + MTP_inputDialogPeer(key.history()->peer->input))); + } if (isPinned) { if (const auto main = App::main()) { main->dialogsToUp(); @@ -330,9 +335,9 @@ void Filler::addChannelActions(not_null<ChannelData*> channel) { const auto feed = channel->feed(); const auto grouped = (feed != nullptr); if (!grouped || feed->channels().size() > 1) { - _addAction( - lang(grouped ? lng_feed_ungroup : lng_feed_group), - [=] { ToggleChannelGrouping(channel, !grouped); }); + //_addAction( // #feed + // lang(grouped ? lng_feed_ungroup : lng_feed_group), + // [=] { ToggleChannelGrouping(channel, !grouped); }); } } if (_source != PeerMenuSource::ChatsList) { @@ -481,9 +486,9 @@ void FeedFiller::addSearch() { void FeedFiller::addUngroup() { const auto feed = _feed; - _addAction(lang(lng_feed_ungroup_all), [=] { - PeerMenuUngroupFeed(feed); - }); + //_addAction(lang(lng_feed_ungroup_all), [=] { // #feed + // PeerMenuUngroupFeed(feed); + //}); } } // namespace @@ -655,32 +660,32 @@ void PeerMenuAddMuteAction( Ui::AttachAsChild(muteAction, std::move(lifetime)); } - -void PeerMenuUngroupFeed(not_null<Data::Feed*> feed) { - Ui::show(Box<ConfirmBox>( - lang(lng_feed_sure_ungroup_all), - lang(lng_feed_ungroup_sure), - [=] { Ui::hideLayer(); Auth().api().ungroupAllFromFeed(feed); })); -} - -void ToggleChannelGrouping(not_null<ChannelData*> channel, bool group) { - const auto callback = [=] { - Ui::Toast::Show(lang(group - ? lng_feed_channel_added - : lng_feed_channel_removed)); - }; - if (group) { - const auto feed = Auth().data().feed(Data::Feed::kId); - if (feed->channels().size() < 2) { - Info::FeedProfile::EditController::Start(feed, channel); - return; - } - } - Auth().api().toggleChannelGrouping( - channel, - group, - callback); -} +// #feed +//void PeerMenuUngroupFeed(not_null<Data::Feed*> feed) { +// Ui::show(Box<ConfirmBox>( +// lang(lng_feed_sure_ungroup_all), +// lang(lng_feed_ungroup_sure), +// [=] { Ui::hideLayer(); Auth().api().ungroupAllFromFeed(feed); })); +//} +// +//void ToggleChannelGrouping(not_null<ChannelData*> channel, bool group) { +// const auto callback = [=] { +// Ui::Toast::Show(lang(group +// ? lng_feed_channel_added +// : lng_feed_channel_removed)); +// }; +// if (group) { +// const auto feed = Auth().data().feed(Data::Feed::kId); +// if (feed->channels().size() < 2) { +// Info::FeedProfile::EditController::Start(feed, channel); +// return; +// } +// } +// Auth().api().toggleChannelGrouping( +// channel, +// group, +// callback); +//} base::lambda<void()> ClearHistoryHandler(not_null<PeerData*> peer) { return [peer] { diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index 4cc0b0bd3..2b11ab99e 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -48,9 +48,9 @@ void PeerMenuDeleteContact(not_null<UserData*> user); void PeerMenuShareContactBox(not_null<UserData*> user); void PeerMenuAddContact(not_null<UserData*> user); void PeerMenuAddChannelMembers(not_null<ChannelData*> channel); -void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); +//void PeerMenuUngroupFeed(not_null<Data::Feed*> feed); // #feed -void ToggleChannelGrouping(not_null<ChannelData*> channel, bool group); +//void ToggleChannelGrouping(not_null<ChannelData*> channel, bool group); // #feed base::lambda<void()> ClearHistoryHandler(not_null<PeerData*> peer); base::lambda<void()> DeleteAndLeaveHandler(not_null<PeerData*> peer);