| 922 | } |
| 923 | |
| 924 | void 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 | |
| 961 | void RepliesList::readTill(not_null<HistoryItem*> item) { |
| 962 | readTill(item->id, item); |
nothing calls this directly
no test coverage detected