mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
Move requestDialogEntry to Histories.
This commit is contained in:
parent
9bdcd08233
commit
db322cc19a
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<bool> ApiWrap::dialogsLoadBlockedByDate() const {
|
||||
return _dialogsLoadBlockedByDate.value();
|
||||
}
|
||||
|
||||
void ApiWrap::requestDialogEntry(not_null<Data::Folder*> folder) {
|
||||
if (_dialogFolderRequests.contains(folder)) {
|
||||
return;
|
||||
}
|
||||
_dialogFolderRequests.emplace(folder);
|
||||
|
||||
auto peers = QVector<MTPInputDialogPeer>(
|
||||
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*> history,
|
||||
Fn<void()> 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<not_null<History*>>();
|
||||
ranges::transform(
|
||||
_dialogRequestsPending,
|
||||
ranges::back_inserter(histories),
|
||||
[](const auto &pair) { return pair.first; });
|
||||
auto peers = QVector<MTPInputDialogPeer>();
|
||||
const auto dialogPeer = [](not_null<History*> 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) {
|
||||
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*> 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*> history) {
|
||||
if (_fakeChatListRequests.contains(history)) {
|
||||
@ -1787,7 +1659,7 @@ void ApiWrap::requestSelfParticipant(not_null<ChannelData*> 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);
|
||||
|
@ -170,17 +170,10 @@ public:
|
||||
rpl::producer<bool> dialogsLoadMayBlockByDate() const;
|
||||
rpl::producer<bool> dialogsLoadBlockedByDate() const;
|
||||
|
||||
void requestDialogEntry(not_null<Data::Folder*> folder);
|
||||
void requestDialogEntry(
|
||||
not_null<History*> history,
|
||||
Fn<void()> callback = nullptr);
|
||||
void dialogEntryApplied(not_null<History*> history);
|
||||
//void applyFeedSources(const MTPDchannels_feedSources &data); // #feed
|
||||
//void setFeedChannels(
|
||||
// not_null<Data::Feed*> feed,
|
||||
// const std::vector<not_null<ChannelData*>> &channels);
|
||||
void changeDialogUnreadMark(not_null<History*> history, bool unread);
|
||||
//void changeDialogUnreadMark(not_null<Data::Feed*> feed, bool unread); // #feed
|
||||
void requestFakeChatListMessage(not_null<History*> history);
|
||||
|
||||
void requestWallPaper(
|
||||
@ -532,7 +525,6 @@ private:
|
||||
|
||||
QVector<MTPInputMessage> collectMessageIds(const MessageDataRequests &requests);
|
||||
MessageDataRequests *messageDataRequests(ChannelData *channel, bool onlyExisting = false);
|
||||
void applyPeerDialogs(const MTPmessages_PeerDialogs &dialogs);
|
||||
|
||||
void gotChatFull(
|
||||
not_null<PeerData*> peer,
|
||||
@ -682,8 +674,6 @@ private:
|
||||
not_null<ChannelData*> channel);
|
||||
void migrateFail(not_null<PeerData*> peer, const RPCError &error);
|
||||
|
||||
void sendDialogRequests();
|
||||
|
||||
not_null<Main::Session*> _session;
|
||||
|
||||
base::flat_map<QString, int> _modifyRequests;
|
||||
@ -753,13 +743,6 @@ private:
|
||||
|
||||
mtpRequestId _contactsRequestId = 0;
|
||||
mtpRequestId _contactsStatusesRequestId = 0;
|
||||
base::flat_set<not_null<Data::Folder*>> _dialogFolderRequests;
|
||||
base::flat_map<
|
||||
not_null<History*>,
|
||||
std::vector<Fn<void()>>> _dialogRequests;
|
||||
base::flat_map<
|
||||
not_null<History*>,
|
||||
std::vector<Fn<void()>>> _dialogRequestsPending;
|
||||
base::flat_set<not_null<History*>> _fakeChatListRequests;
|
||||
|
||||
base::flat_map<not_null<History*>, mtpRequestId> _unreadMentionsRequests;
|
||||
|
@ -76,7 +76,7 @@ void MuteSettingsBox::prepare() {
|
||||
|
||||
_save = [=] {
|
||||
const auto muteForSeconds = group->value() * 3600;
|
||||
_peer->session().data().updateNotifySettings(
|
||||
_peer->owner().updateNotifySettings(
|
||||
_peer,
|
||||
muteForSeconds);
|
||||
closeBox();
|
||||
|
@ -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(),
|
||||
|
@ -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),
|
||||
|
@ -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*> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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*> 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<HistoryItem*> item) {
|
||||
}
|
||||
}
|
||||
|
||||
void Histories::requestDialogEntry(not_null<Data::Folder*> folder) {
|
||||
if (_dialogFolderRequests.contains(folder)) {
|
||||
return;
|
||||
}
|
||||
_dialogFolderRequests.emplace(folder);
|
||||
|
||||
auto peers = QVector<MTPInputDialogPeer>(
|
||||
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*> history,
|
||||
Fn<void()> 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<not_null<History*>>();
|
||||
ranges::transform(
|
||||
_dialogRequestsPending,
|
||||
ranges::back_inserter(histories),
|
||||
[](const auto &pair) { return pair.first; });
|
||||
auto peers = QVector<MTPInputDialogPeer>();
|
||||
const auto dialogPeer = [](not_null<History*> 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) {
|
||||
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*> 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*> history) {
|
||||
if (const auto state = lookup(history)) {
|
||||
if (state->readTill
|
||||
@ -233,7 +363,7 @@ void Histories::sendReadRequest(not_null<History*> 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*> history, int requestId) {
|
||||
postponed.type
|
||||
});
|
||||
if (base::take(state->thenRequestEntry)) {
|
||||
session().api().requestDialogEntry(history);
|
||||
requestDialogEntry(history);
|
||||
}
|
||||
} else {
|
||||
Assert(action == Action::Postpone);
|
||||
|
@ -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<HistoryItem*> item);
|
||||
void sendPendingReadInbox(not_null<History*> history);
|
||||
|
||||
void requestDialogEntry(not_null<Data::Folder*> folder);
|
||||
void requestDialogEntry(
|
||||
not_null<History*> history,
|
||||
Fn<void()> callback = nullptr);
|
||||
void dialogEntryApplied(not_null<History*> history);
|
||||
void changeDialogUnreadMark(not_null<History*> history, bool unread);
|
||||
//void changeDialogUnreadMark(not_null<Data::Feed*> 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<Session*> _owner;
|
||||
|
||||
std::unordered_map<PeerId, std::unique_ptr<History>> _map;
|
||||
base::flat_map<not_null<History*>, State> _states;
|
||||
base::Timer _readRequestsTimer;
|
||||
|
||||
base::flat_set<not_null<Data::Folder*>> _dialogFolderRequests;
|
||||
base::flat_map<
|
||||
not_null<History*>,
|
||||
std::vector<Fn<void()>>> _dialogRequests;
|
||||
base::flat_map<
|
||||
not_null<History*>,
|
||||
std::vector<Fn<void()>>> _dialogRequestsPending;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Data
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
|
@ -685,7 +685,7 @@ not_null<HistoryItem*> History::addNewItem(
|
||||
not_null<HistoryItem*> 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<HistoryItem*> item) {
|
||||
if (unreadCountKnown()) {
|
||||
setUnreadCount(unreadCount() + 1);
|
||||
} else {
|
||||
session().api().requestDialogEntry(this);
|
||||
owner().histories().requestDialogEntry(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1298,7 +1298,7 @@ void History::newItemAdded(not_null<HistoryItem*> 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<int> 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() {
|
||||
|
@ -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.
|
||||
|
@ -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()) {
|
||||
|
@ -304,9 +304,9 @@ void Filler::addToggleUnreadMark() {
|
||||
const auto markAsRead = isUnread(peer);
|
||||
const auto handle = [&](not_null<History*> 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user