Remove redundant read comments thread requests.
This commit is contained in:
parent
808e8dcf4f
commit
40e925d3f9
|
@ -218,11 +218,13 @@ RepliesWidget::~RepliesWidget() {
|
||||||
|
|
||||||
void RepliesWidget::sendReadTillRequest() {
|
void RepliesWidget::sendReadTillRequest() {
|
||||||
if (!_commentsRoot) {
|
if (!_commentsRoot) {
|
||||||
|
_readRequestPending = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_readRequestTimer.isActive()) {
|
if (_readRequestTimer.isActive()) {
|
||||||
_readRequestTimer.cancel();
|
_readRequestTimer.cancel();
|
||||||
}
|
}
|
||||||
|
_readRequestPending = false;
|
||||||
const auto api = &_history->session().api();
|
const auto api = &_history->session().api();
|
||||||
api->request(base::take(_readRequestId)).cancel();
|
api->request(base::take(_readRequestId)).cancel();
|
||||||
_readRequestId = api->request(MTPmessages_ReadDiscussion(
|
_readRequestId = api->request(MTPmessages_ReadDiscussion(
|
||||||
|
@ -258,15 +260,19 @@ void RepliesWidget::setupCommentsRoot() {
|
||||||
if (!postChannel) {
|
if (!postChannel) {
|
||||||
return;
|
return;
|
||||||
} else if (_commentsRoot) {
|
} else if (_commentsRoot) {
|
||||||
|
if (_readRequestTimer.isActive() || _readRequestPending) {
|
||||||
sendReadTillRequest();
|
sendReadTillRequest();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto forwarded = _root->Get<HistoryMessageForwarded>();
|
const auto forwarded = _root->Get<HistoryMessageForwarded>();
|
||||||
const auto messageId = forwarded->savedFromMsgId;
|
const auto messageId = forwarded->savedFromMsgId;
|
||||||
const auto done = crl::guard(this, [=](ChannelData*, MsgId) {
|
const auto done = crl::guard(this, [=](ChannelData*, MsgId) {
|
||||||
_commentsRoot = lookupCommentsRoot();
|
_commentsRoot = lookupCommentsRoot();
|
||||||
if (_commentsRoot) {
|
if (_commentsRoot) {
|
||||||
|
if (_readRequestTimer.isActive() || _readRequestPending) {
|
||||||
sendReadTillRequest();
|
sendReadTillRequest();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
_history->session().api().requestMessageData(
|
_history->session().api().requestMessageData(
|
||||||
postChannel,
|
postChannel,
|
||||||
|
|
|
@ -257,6 +257,7 @@ private:
|
||||||
bool _choosingAttach = false;
|
bool _choosingAttach = false;
|
||||||
|
|
||||||
base::Timer _readRequestTimer;
|
base::Timer _readRequestTimer;
|
||||||
|
bool _readRequestPending = false;
|
||||||
mtpRequestId _readRequestId = 0;
|
mtpRequestId _readRequestId = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue