mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Remove redundant read comments thread requests.
This commit is contained in:
parent
808e8dcf4f
commit
40e925d3f9
2 changed files with 9 additions and 2 deletions
Telegram/SourceFiles/history/view
|
@ -218,11 +218,13 @@ RepliesWidget::~RepliesWidget() {
|
|||
|
||||
void RepliesWidget::sendReadTillRequest() {
|
||||
if (!_commentsRoot) {
|
||||
_readRequestPending = true;
|
||||
return;
|
||||
}
|
||||
if (_readRequestTimer.isActive()) {
|
||||
_readRequestTimer.cancel();
|
||||
}
|
||||
_readRequestPending = false;
|
||||
const auto api = &_history->session().api();
|
||||
api->request(base::take(_readRequestId)).cancel();
|
||||
_readRequestId = api->request(MTPmessages_ReadDiscussion(
|
||||
|
@ -258,14 +260,18 @@ void RepliesWidget::setupCommentsRoot() {
|
|||
if (!postChannel) {
|
||||
return;
|
||||
} else if (_commentsRoot) {
|
||||
sendReadTillRequest();
|
||||
if (_readRequestTimer.isActive() || _readRequestPending) {
|
||||
sendReadTillRequest();
|
||||
}
|
||||
} else {
|
||||
const auto forwarded = _root->Get<HistoryMessageForwarded>();
|
||||
const auto messageId = forwarded->savedFromMsgId;
|
||||
const auto done = crl::guard(this, [=](ChannelData*, MsgId) {
|
||||
_commentsRoot = lookupCommentsRoot();
|
||||
if (_commentsRoot) {
|
||||
sendReadTillRequest();
|
||||
if (_readRequestTimer.isActive() || _readRequestPending) {
|
||||
sendReadTillRequest();
|
||||
}
|
||||
}
|
||||
});
|
||||
_history->session().api().requestMessageData(
|
||||
|
|
|
@ -257,6 +257,7 @@ private:
|
|||
bool _choosingAttach = false;
|
||||
|
||||
base::Timer _readRequestTimer;
|
||||
bool _readRequestPending = false;
|
||||
mtpRequestId _readRequestId = 0;
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue