MCPcopy Create free account
hub / github.com/TDesktop-x64/tdesktop / requestUnreadCount

Method requestUnreadCount

Telegram/SourceFiles/data/data_replies_list.cpp:924–959  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

922}
923
924void RepliesList::requestUnreadCount() {
925 if (_reloadUnreadCountRequestId) {
926 return;
927 }
928 const auto weak = base::make_weak(this);
929 const auto session = &_history->session();
930 const auto fullId = FullMsgId(_history->peer->id, _rootId);
931 const auto apply = [weak, session, fullId](
932 MsgId readTill,
933 int unreadCount) {
934 if (const auto strong = weak.get()) {
935 strong->setInboxReadTill(readTill, unreadCount);
936 }
937 if (const auto root = session->data().message(fullId)) {
938 if (const auto post = root->lookupDiscussionPostOriginal()) {
939 post->setCommentsInboxReadTill(readTill);
940 }
941 }
942 };
943 _reloadUnreadCountRequestId = session->api().request(
944 MTPmessages_GetDiscussionMessage(
945 _history->peer->input(),
946 MTP_int(_rootId))
947 ).done([=](const MTPmessages_DiscussionMessage &result) {
948 if (weak) {
949 _reloadUnreadCountRequestId = 0;
950 }
951 result.match([&](const MTPDmessages_discussionMessage &data) {
952 session->data().processUsers(data.vusers());
953 session->data().processChats(data.vchats());
954 apply(
955 data.vread_inbox_max_id().value_or_empty(),
956 data.vunread_count().v);
957 });
958 }).send();
959}
960
961void RepliesList::readTill(not_null<HistoryItem*> item) {
962 readTill(item->id, item);

Callers

nothing calls this directly

Calls 15

apiMethod · 0.80
processUsersMethod · 0.80
processChatsMethod · 0.80
FullMsgIdClass · 0.70
MTP_intFunction · 0.70
sessionMethod · 0.45
getMethod · 0.45
setInboxReadTillMethod · 0.45
messageMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected