diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index 45476bfd53..bc6788818b 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -169,7 +169,7 @@ void SendExistingDocument( if (document->sticker()) { if (const auto main = App::main()) { main->incrementSticker(document); - document->session().data().notifyRecentStickersUpdated(); + document->owner().notifyRecentStickersUpdated(); } } } diff --git a/Telegram/SourceFiles/apiwrap.cpp b/Telegram/SourceFiles/apiwrap.cpp index d6f49630e4..ff5c309a35 100644 --- a/Telegram/SourceFiles/apiwrap.cpp +++ b/Telegram/SourceFiles/apiwrap.cpp @@ -344,7 +344,7 @@ void ApiWrap::proxyPromotionDone(const MTPhelp_ProxyData &proxy) { const auto peer = _session->data().peer(peerId); _session->data().setProxyPromoted(peer); if (const auto history = _session->data().historyLoaded(peer)) { - requestDialogEntry(history); + history->owner().histories().requestDialogEntry(history); } }); } @@ -1012,134 +1012,6 @@ rpl::producer ApiWrap::dialogsLoadBlockedByDate() const { return _dialogsLoadBlockedByDate.value(); } -void ApiWrap::requestDialogEntry(not_null folder) { - if (_dialogFolderRequests.contains(folder)) { - return; - } - _dialogFolderRequests.emplace(folder); - - 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::requestDialogEntry( - not_null history, - Fn callback) { - const auto i = _dialogRequests.find(history); - if (i != end(_dialogRequests)) { - if (callback) { - i->second.push_back(std::move(callback)); - } - return; - } - - const auto [j, ok] = _dialogRequestsPending.try_emplace(history); - if (callback) { - j->second.push_back(std::move(callback)); - } - if (!ok) { - return; - } - if (_dialogRequestsPending.size() > 1) { - return; - } - Core::App().postponeCall(crl::guard(_session, [=] { - sendDialogRequests(); - })); -} - -void ApiWrap::sendDialogRequests() { - if (_dialogRequestsPending.empty()) { - return; - } - auto histories = std::vector>(); - ranges::transform( - _dialogRequestsPending, - ranges::back_inserter(histories), - [](const auto &pair) { return pair.first; }); - auto peers = QVector(); - const auto dialogPeer = [](not_null history) { - return MTP_inputDialogPeer(history->peer->input); - }; - ranges::transform( - histories, - ranges::back_inserter(peers), - dialogPeer); - for (auto &[history, callbacks] : base::take(_dialogRequestsPending)) { - _dialogRequests.emplace(history, std::move(callbacks)); - } - - const auto finalize = [=] { - for (const auto history : histories) { - dialogEntryApplied(history); - history->updateChatListExistence(); - } - }; - request(MTPmessages_GetPeerDialogs( - MTP_vector(std::move(peers)) - )).done([=](const MTPmessages_PeerDialogs &result) { - applyPeerDialogs(result); - finalize(); - }).fail([=](const RPCError &error) { - finalize(); - }).send(); -} - -void ApiWrap::dialogEntryApplied(not_null history) { - history->dialogEntryApplied(); - if (const auto callbacks = _dialogRequestsPending.take(history)) { - for (const auto &callback : *callbacks) { - callback(); - } - } - if (const auto callbacks = _dialogRequests.take(history)) { - for (const auto &callback : *callbacks) { - callback(); - } - } -} - -void ApiWrap::applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs) { - Expects(dialogs.type() == mtpc_messages_peerDialogs); - - const auto &data = dialogs.c_messages_peerDialogs(); - _session->data().processUsers(data.vusers()); - _session->data().processChats(data.vchats()); - _session->data().processMessages(data.vmessages(), NewMessageType::Last); - for (const auto &dialog : data.vdialogs().v) { - dialog.match([&](const MTPDdialog &data) { - if (const auto peerId = peerFromMTP(data.vpeer())) { - _session->data().history(peerId)->applyDialog(nullptr, data); - } - }, [&](const MTPDdialogFolder &data) { - const auto folder = _session->data().processFolder(data.vfolder()); - folder->applyDialog(data); - }); - } - _session->data().sendHistoryChangeNotifications(); -} - -void ApiWrap::changeDialogUnreadMark( - not_null history, - bool unread) { - history->setUnreadMark(unread); - - using Flag = MTPmessages_MarkDialogUnread::Flag; - request(MTPmessages_MarkDialogUnread( - MTP_flags(unread ? Flag::f_unread : Flag(0)), - MTP_inputDialogPeer(history->peer->input) - )).send(); -} - void ApiWrap::requestFakeChatListMessage( not_null history) { if (_fakeChatListRequests.contains(history)) { @@ -1787,7 +1659,7 @@ void ApiWrap::requestSelfParticipant(not_null channel) { history->checkLocalMessages(); history->owner().sendHistoryChangeNotifications(); } else { - requestDialogEntry(history); + history->owner().histories().requestDialogEntry(history); } } }; @@ -2463,7 +2335,7 @@ void ApiWrap::deleteHistory( } } if (!history->lastMessageKnown()) { - requestDialogEntry(history, [=] { + history->owner().histories().requestDialogEntry(history, [=] { Expects(history->lastMessageKnown()); deleteHistory(peer, justClear, revoke); diff --git a/Telegram/SourceFiles/apiwrap.h b/Telegram/SourceFiles/apiwrap.h index f7bddf0af5..a3691df2b8 100644 --- a/Telegram/SourceFiles/apiwrap.h +++ b/Telegram/SourceFiles/apiwrap.h @@ -170,17 +170,10 @@ public: rpl::producer dialogsLoadMayBlockByDate() const; rpl::producer dialogsLoadBlockedByDate() const; - void requestDialogEntry(not_null folder); - void requestDialogEntry( - not_null history, - Fn callback = nullptr); - void dialogEntryApplied(not_null history); //void applyFeedSources(const MTPDchannels_feedSources &data); // #feed //void setFeedChannels( // not_null feed, // const std::vector> &channels); - void changeDialogUnreadMark(not_null history, bool unread); - //void changeDialogUnreadMark(not_null feed, bool unread); // #feed void requestFakeChatListMessage(not_null history); void requestWallPaper( @@ -532,7 +525,6 @@ private: QVector collectMessageIds(const MessageDataRequests &requests); MessageDataRequests *messageDataRequests(ChannelData *channel, bool onlyExisting = false); - void applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs); void gotChatFull( not_null peer, @@ -682,8 +674,6 @@ private: not_null channel); void migrateFail(not_null peer, const RPCError &error); - void sendDialogRequests(); - not_null _session; base::flat_map _modifyRequests; @@ -753,13 +743,6 @@ private: mtpRequestId _contactsRequestId = 0; mtpRequestId _contactsStatusesRequestId = 0; - base::flat_set> _dialogFolderRequests; - base::flat_map< - not_null, - std::vector>> _dialogRequests; - base::flat_map< - not_null, - std::vector>> _dialogRequestsPending; base::flat_set> _fakeChatListRequests; base::flat_map, mtpRequestId> _unreadMentionsRequests; diff --git a/Telegram/SourceFiles/boxes/mute_settings_box.cpp b/Telegram/SourceFiles/boxes/mute_settings_box.cpp index fb8b67b090..7fd659c9bb 100644 --- a/Telegram/SourceFiles/boxes/mute_settings_box.cpp +++ b/Telegram/SourceFiles/boxes/mute_settings_box.cpp @@ -76,7 +76,7 @@ void MuteSettingsBox::prepare() { _save = [=] { const auto muteForSeconds = group->value() * 3600; - _peer->session().data().updateNotifySettings( + _peer->owner().updateNotifySettings( _peer, muteForSeconds); closeBox(); diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 38c5c5c06b..f81a767cc2 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_folder.h" #include "data/data_location.h" +#include "data/data_histories.h" #include "base/unixtime.h" #include "history/history.h" #include "observer_peer.h" @@ -688,13 +689,14 @@ void ApplyChannelUpdate( const auto folder = folderId ? channel->owner().folderLoaded(folderId) : nullptr; + auto &histories = channel->owner().histories(); if (folder && history->folder() != folder) { // If history folder is unknown or not synced, request both. - channel->session().api().requestDialogEntry(history); - channel->session().api().requestDialogEntry(folder); + histories.requestDialogEntry(history); + histories.requestDialogEntry(folder); } else if (!history->folderKnown() || channel->pts() != update.vpts().v) { - channel->session().api().requestDialogEntry(history); + histories.requestDialogEntry(history); } else { history->applyDialogFields( history->folder(), diff --git a/Telegram/SourceFiles/data/data_document.cpp b/Telegram/SourceFiles/data/data_document.cpp index 7aeb0d1241..56b6d5ff60 100644 --- a/Telegram/SourceFiles/data/data_document.cpp +++ b/Telegram/SourceFiles/data/data_document.cpp @@ -569,7 +569,7 @@ void DocumentData::validateLottieSticker() { void DocumentData::setDataAndCache(const QByteArray &data) { setData(data); if (saveToCache() && data.size() <= Storage::kMaxFileInMemory) { - session().data().cache().put( + owner().cache().put( cacheKey(), Storage::Cache::Database::TaggedValue( base::duplicate(data), diff --git a/Telegram/SourceFiles/data/data_folder.cpp b/Telegram/SourceFiles/data/data_folder.cpp index b42ac116cd..5229de94b6 100644 --- a/Telegram/SourceFiles/data/data_folder.cpp +++ b/Telegram/SourceFiles/data/data_folder.cpp @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_channel.h" +#include "data/data_histories.h" #include "dialogs/dialogs_key.h" #include "history/history.h" #include "history/history_item.h" @@ -108,7 +109,7 @@ void Folder::registerOne(not_null history) { if (_chatsList.indexed()->size() == 1) { updateChatListSortPosition(); if (!_cloudUnread.known) { - session().api().requestDialogEntry(this); + owner().histories().requestDialogEntry(this); } } else { updateChatListEntry(); @@ -323,7 +324,7 @@ uint32 Folder::chatListViewVersion() const { void Folder::requestChatListMessage() { if (!chatListMessageKnown()) { - session().api().requestDialogEntry(this); + owner().histories().requestDialogEntry(this); } } diff --git a/Telegram/SourceFiles/data/data_histories.cpp b/Telegram/SourceFiles/data/data_histories.cpp index efe4c3200a..283dc97d82 100644 --- a/Telegram/SourceFiles/data/data_histories.cpp +++ b/Telegram/SourceFiles/data/data_histories.cpp @@ -9,10 +9,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_channel.h" +#include "data/data_folder.h" #include "main/main_session.h" #include "history/history.h" #include "history/history_item.h" #include "history/view/history_view_element.h" +#include "core/application.h" #include "apiwrap.h" namespace Data { @@ -77,7 +79,7 @@ void Histories::readInbox(not_null history) { return; } } - session().api().requestDialogEntry(history, [=] { + requestDialogEntry(history, [=] { Expects(history->lastServerMessageKnown()); const auto last = history->lastServerMessage(); @@ -190,6 +192,134 @@ void Histories::readClientSideMessage(not_null item) { } } +void Histories::requestDialogEntry(not_null folder) { + if (_dialogFolderRequests.contains(folder)) { + return; + } + _dialogFolderRequests.emplace(folder); + + auto peers = QVector( + 1, + MTP_inputDialogPeerFolder(MTP_int(folder->id()))); + session().api().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 Histories::requestDialogEntry( + not_null history, + Fn callback) { + const auto i = _dialogRequests.find(history); + if (i != end(_dialogRequests)) { + if (callback) { + i->second.push_back(std::move(callback)); + } + return; + } + + const auto [j, ok] = _dialogRequestsPending.try_emplace(history); + if (callback) { + j->second.push_back(std::move(callback)); + } + if (!ok) { + return; + } + if (_dialogRequestsPending.size() > 1) { + return; + } + Core::App().postponeCall(crl::guard(&session(), [=] { + sendDialogRequests(); + })); +} + +void Histories::sendDialogRequests() { + if (_dialogRequestsPending.empty()) { + return; + } + auto histories = std::vector>(); + ranges::transform( + _dialogRequestsPending, + ranges::back_inserter(histories), + [](const auto &pair) { return pair.first; }); + auto peers = QVector(); + const auto dialogPeer = [](not_null history) { + return MTP_inputDialogPeer(history->peer->input); + }; + ranges::transform( + histories, + ranges::back_inserter(peers), + dialogPeer); + for (auto &[history, callbacks] : base::take(_dialogRequestsPending)) { + _dialogRequests.emplace(history, std::move(callbacks)); + } + + const auto finalize = [=] { + for (const auto history : histories) { + dialogEntryApplied(history); + history->updateChatListExistence(); + } + }; + session().api().request(MTPmessages_GetPeerDialogs( + MTP_vector(std::move(peers)) + )).done([=](const MTPmessages_PeerDialogs &result) { + applyPeerDialogs(result); + finalize(); + }).fail([=](const RPCError &error) { + finalize(); + }).send(); +} + +void Histories::dialogEntryApplied(not_null history) { + history->dialogEntryApplied(); + if (const auto callbacks = _dialogRequestsPending.take(history)) { + for (const auto &callback : *callbacks) { + callback(); + } + } + if (const auto callbacks = _dialogRequests.take(history)) { + for (const auto &callback : *callbacks) { + callback(); + } + } +} + +void Histories::applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs) { + Expects(dialogs.type() == mtpc_messages_peerDialogs); + + const auto &data = dialogs.c_messages_peerDialogs(); + _owner->processUsers(data.vusers()); + _owner->processChats(data.vchats()); + _owner->processMessages(data.vmessages(), NewMessageType::Last); + for (const auto &dialog : data.vdialogs().v) { + dialog.match([&](const MTPDdialog &data) { + if (const auto peerId = peerFromMTP(data.vpeer())) { + _owner->history(peerId)->applyDialog(nullptr, data); + } + }, [&](const MTPDdialogFolder &data) { + const auto folder = _owner->processFolder(data.vfolder()); + folder->applyDialog(data); + }); + } + _owner->sendHistoryChangeNotifications(); +} + +void Histories::changeDialogUnreadMark( + not_null history, + bool unread) { + history->setUnreadMark(unread); + + using Flag = MTPmessages_MarkDialogUnread::Flag; + session().api().request(MTPmessages_MarkDialogUnread( + MTP_flags(unread ? Flag::f_unread : Flag(0)), + MTP_inputDialogPeer(history->peer->input) + )).send(); +} + void Histories::sendPendingReadInbox(not_null history) { if (const auto state = lookup(history)) { if (state->readTill @@ -233,7 +363,7 @@ void Histories::sendReadRequest(not_null history, State &state) { Assert(state->readTill >= tillId); if (history->unreadCountRefreshNeeded(tillId)) { - session().api().requestDialogEntry(history); + requestDialogEntry(history); } if (state->readWhen == kReadRequestSent) { state->readWhen = 0; @@ -295,7 +425,7 @@ int Histories::sendRequest( type }); if (base::take(state.thenRequestEntry)) { - session().api().requestDialogEntry(history); + requestDialogEntry(history); } } else if (action == Action::Postpone) { state.postponed.emplace( @@ -322,7 +452,7 @@ void Histories::checkPostponed(not_null history, int requestId) { postponed.type }); if (base::take(state->thenRequestEntry)) { - session().api().requestDialogEntry(history); + requestDialogEntry(history); } } else { Assert(action == Action::Postpone); diff --git a/Telegram/SourceFiles/data/data_histories.h b/Telegram/SourceFiles/data/data_histories.h index 42a9641ce3..59f02542e6 100644 --- a/Telegram/SourceFiles/data/data_histories.h +++ b/Telegram/SourceFiles/data/data_histories.h @@ -19,6 +19,7 @@ class Session; namespace Data { class Session; +class Folder; class Histories final { public: @@ -40,6 +41,14 @@ public: void readClientSideMessage(not_null item); void sendPendingReadInbox(not_null history); + void requestDialogEntry(not_null folder); + void requestDialogEntry( + not_null history, + Fn callback = nullptr); + void dialogEntryApplied(not_null history); + void changeDialogUnreadMark(not_null history, bool unread); + //void changeDialogUnreadMark(not_null feed, bool unread); // #feed + private: enum class RequestType : uchar { None, @@ -85,12 +94,23 @@ private: RequestType type, bool fromPostponed = false) const; + void sendDialogRequests(); + void applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs); + const not_null _owner; std::unordered_map> _map; base::flat_map, State> _states; base::Timer _readRequestsTimer; + base::flat_set> _dialogFolderRequests; + base::flat_map< + not_null, + std::vector>> _dialogRequests; + base::flat_map< + not_null, + std::vector>> _dialogRequestsPending; + }; } // namespace Data diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index 8ccfa500bc..1044fcc3ce 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_folder.h" #include "data/data_session.h" #include "data/data_file_origin.h" +#include "data/data_histories.h" #include "base/unixtime.h" #include "base/crc32hash.h" #include "lang/lang_keys.h" @@ -457,7 +458,7 @@ void PeerData::checkFolder(FolderId folderId) { : nullptr; if (const auto history = owner().historyLoaded(this)) { if (folder && history->folder() != folder) { - session().api().requestDialogEntry(history); + owner().histories().requestDialogEntry(history); } } } diff --git a/Telegram/SourceFiles/data/data_session.cpp b/Telegram/SourceFiles/data/data_session.cpp index dc19add6e7..7fa9f0a063 100644 --- a/Telegram/SourceFiles/data/data_session.cpp +++ b/Telegram/SourceFiles/data/data_session.cpp @@ -1530,7 +1530,7 @@ void Session::applyDialog( return; } - const auto history = session().data().history(peerId); + const auto history = this->history(peerId); history->applyDialog(requestFolder, data); setPinnedFromDialog(history, data.is_pinned()); @@ -3597,7 +3597,7 @@ void Session::serviceNotification( } const auto history = this->history(PeerData::kServiceNotificationsId); if (!history->folderKnown()) { - _session->api().requestDialogEntry(history, [=] { + histories().requestDialogEntry(history, [=] { insertCheckedServiceNotification(message, media, date); }); } else { diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index d80fb87626..5af51519d7 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_chat.h" #include "data/data_user.h" #include "data/data_peer_values.h" +#include "data/data_histories.h" #include "base/unixtime.h" #include "lang/lang_keys.h" #include "mainwindow.h" @@ -2040,7 +2041,7 @@ bool InnerWidget::searchReceived( _searchInChat, item)); if (uniquePeers && !history->unreadCountKnown()) { - history->session().api().requestDialogEntry(history); + history->owner().histories().requestDialogEntry(history); } } lastDateFound = lastDate; diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 78fe529a47..80a17e2be1 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -685,7 +685,7 @@ not_null History::addNewItem( not_null item, bool unread) { if (item->isScheduled()) { - session().data().scheduledMessages().appendSending(item); + owner().scheduledMessages().appendSending(item); return item; } else if (!item->isHistoryEntry()) { return item; @@ -1285,7 +1285,7 @@ void History::newItemAdded(not_null item) { if (unreadCountKnown()) { setUnreadCount(unreadCount() + 1); } else { - session().api().requestDialogEntry(this); + owner().histories().requestDialogEntry(this); } } } @@ -1298,7 +1298,7 @@ void History::newItemAdded(not_null item) { outboxRead(item); } if (!folderKnown()) { - session().api().requestDialogEntry(this); + owner().histories().requestDialogEntry(this); } } @@ -1619,7 +1619,7 @@ bool History::readInboxTillNeedsRequest(MsgId tillId) { readClientSideMessages(); if (unreadMark()) { - session().api().changeDialogUnreadMark(this, false); + owner().histories().changeDialogUnreadMark(this, false); } return IsServerMsgId(tillId) && (_inboxReadBefore.value_or(1) <= tillId); } @@ -1691,8 +1691,8 @@ void History::applyInboxReadUpdate( const auto folder = folderId ? owner().folderLoaded(folderId) : nullptr; if (folder && this->folder() != folder) { // If history folder is unknown or not synced, request both. - session().api().requestDialogEntry(this); - session().api().requestDialogEntry(folder); + owner().histories().requestDialogEntry(this); + owner().histories().requestDialogEntry(folder); } if (_inboxReadBefore.value_or(1) <= upTo) { if (!peer->isChannel() || peer->asChannel()->pts() == channelPts) { @@ -1712,7 +1712,7 @@ void History::inboxRead(MsgId upTo, std::optional stillUnread) { } else if (const auto still = countStillUnreadLocal(upTo)) { setUnreadCount(*still); } else { - session().api().requestDialogEntry(this); + owner().histories().requestDialogEntry(this); } setInboxReadTill(upTo); updateChatListEntry(); @@ -2463,7 +2463,7 @@ void History::setChatListMessageUnknown() { void History::requestChatListMessage() { if (!lastMessageKnown()) { - session().api().requestDialogEntry(this, [=] { + owner().histories().requestDialogEntry(this, [=] { requestChatListMessage(); }); return; @@ -2556,7 +2556,7 @@ void History::updateChatListExistence() { // // After ungrouping from a feed we need to load dialog. // requestChatListMessage(); // if (!unreadCountKnown()) { - // session().api().requestDialogEntry(this); + // owner().histories().requestDialogEntry(this); // } // } //} @@ -2608,7 +2608,7 @@ bool History::toImportant() const { void History::unknownMessageDeleted(MsgId messageId) { if (_inboxReadBefore && messageId >= *_inboxReadBefore) { - session().api().requestDialogEntry(this); + owner().histories().requestDialogEntry(this); } } @@ -2660,7 +2660,7 @@ void History::applyDialog( if (draft && draft->type() == mtpc_draftMessage) { Data::applyPeerCloudDraft(peer->id, draft->c_draftMessage()); } - session().api().dialogEntryApplied(this); + owner().histories().dialogEntryApplied(this); } void History::dialogEntryApplied() { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index f70e5fa8de..15deb8f4fa 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -1878,9 +1878,13 @@ void HistoryWidget::showHistory( } } if (_history->chatListUnreadMark()) { - session().api().changeDialogUnreadMark(_history, false); + _history->owner().histories().changeDialogUnreadMark( + _history, + false); if (_migrated) { - session().api().changeDialogUnreadMark(_migrated, false); + _migrated->owner().histories().changeDialogUnreadMark( + _migrated, + false); } // Must be done before unreadCountUpdated(), or we auto-close. diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index ec105b29b9..b5a8dcfa93 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "data/data_scheduled_messages.h" #include "data/data_file_origin.h" +#include "data/data_histories.h" #include "api/api_text_entities.h" #include "ui/special_buttons.h" #include "ui/widgets/buttons.h" @@ -4027,7 +4028,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { // d.vunread_count()->v, // d.vunread_muted_count()->v); // } else { - // session().api().requestDialogEntry(feed); + // session().data().histories().requestDialogEntry(feed); // } // } //} break; @@ -4403,7 +4404,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { session().api().requestPinnedDialogs(folder); } if (!loaded) { - session().api().requestDialogEntry(folder); + session().data().histories().requestDialogEntry(folder); } } break; @@ -4461,12 +4462,12 @@ void MainWidget::feedUpdate(const MTPUpdate &update) { //if (const auto feed = channel->feed()) { // #feed // feed->requestChatListMessage(); // if (!feed->unreadCountKnown()) { - // feed->session().api().requestDialogEntry(feed); + // feed->owner().histories().requestDialogEntry(feed); // } //} else { history->requestChatListMessage(); if (!history->unreadCountKnown()) { - history->session().api().requestDialogEntry(history); + history->owner().histories().requestDialogEntry(history); } //} if (!channel->amCreator()) { diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 64220b5a2c..fa85d2984f 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -304,9 +304,9 @@ void Filler::addToggleUnreadMark() { const auto markAsRead = isUnread(peer); const auto handle = [&](not_null history) { if (markAsRead) { - peer->session().data().histories().readInbox(history); + peer->owner().histories().readInbox(history); } else { - peer->session().api().changeDialogUnreadMark( + peer->owner().histories().changeDialogUnreadMark( history, !markAsRead); }