mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Unregister channel from shortpoll.
This commit is contained in:
parent
6f71d21bb7
commit
1dc310586d
4 changed files with 27 additions and 11 deletions
|
@ -417,13 +417,12 @@ void Updates::channelDifferenceDone(
|
||||||
"{ good - after not final channelDifference was received }%1"
|
"{ good - after not final channelDifference was received }%1"
|
||||||
).arg(_session->mtp().isTestMode() ? " TESTMODE" : ""));
|
).arg(_session->mtp().isTestMode() ? " TESTMODE" : ""));
|
||||||
getChannelDifference(channel);
|
getChannelDifference(channel);
|
||||||
} else if (ranges::contains(
|
} else if (inActiveChats(channel)) {
|
||||||
_activeChats,
|
channel->ptsSetWaitingForShortPoll(timeout
|
||||||
channel,
|
|
||||||
[](const auto &pair) { return pair.second.peer; })) {
|
|
||||||
channel->ptsWaitingForShortPoll(timeout
|
|
||||||
? (timeout * crl::time(1000))
|
? (timeout * crl::time(1000))
|
||||||
: kWaitForChannelGetDifference);
|
: kWaitForChannelGetDifference);
|
||||||
|
} else {
|
||||||
|
channel->ptsSetWaitingForShortPoll(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -743,16 +742,32 @@ void Updates::addActiveChat(rpl::producer<PeerData*> chat) {
|
||||||
std::move(
|
std::move(
|
||||||
chat
|
chat
|
||||||
) | rpl::start_with_next_done([=](PeerData *peer) {
|
) | rpl::start_with_next_done([=](PeerData *peer) {
|
||||||
_activeChats[key].peer = peer;
|
auto &active = _activeChats[key];
|
||||||
if (const auto channel = peer ? peer->asChannel() : nullptr) {
|
const auto was = active.peer;
|
||||||
channel->ptsWaitingForShortPoll(
|
if (was != peer) {
|
||||||
kWaitForChannelGetDifference);
|
active.peer = peer;
|
||||||
|
if (const auto channel = was ? was->asChannel() : nullptr) {
|
||||||
|
if (!inActiveChats(channel)) {
|
||||||
|
channel->ptsSetWaitingForShortPoll(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (const auto channel = peer ? peer->asChannel() : nullptr) {
|
||||||
|
channel->ptsSetWaitingForShortPoll(
|
||||||
|
kWaitForChannelGetDifference);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [=] {
|
}, [=] {
|
||||||
_activeChats.erase(key);
|
_activeChats.erase(key);
|
||||||
}, _activeChats[key].lifetime);
|
}, _activeChats[key].lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Updates::inActiveChats(not_null<PeerData*> peer) const {
|
||||||
|
return ranges::contains(
|
||||||
|
_activeChats,
|
||||||
|
peer.get(),
|
||||||
|
[](const auto &pair) { return pair.second.peer; });
|
||||||
|
}
|
||||||
|
|
||||||
void Updates::requestChannelRangeDifference(not_null<History*> history) {
|
void Updates::requestChannelRangeDifference(not_null<History*> history) {
|
||||||
Expects(history->peer->isChannel());
|
Expects(history->peer->isChannel());
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,7 @@ public:
|
||||||
void requestChannelRangeDifference(not_null<History*> history);
|
void requestChannelRangeDifference(not_null<History*> history);
|
||||||
|
|
||||||
void addActiveChat(rpl::producer<PeerData*> chat);
|
void addActiveChat(rpl::producer<PeerData*> chat);
|
||||||
|
[[nodiscard]] bool inActiveChats(not_null<PeerData*> peer) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class ChannelDifferenceRequest {
|
enum class ChannelDifferenceRequest {
|
||||||
|
|
|
@ -2028,7 +2028,7 @@ void ApiWrap::deleteHistory(
|
||||||
}
|
}
|
||||||
if (const auto channel = peer->asChannel()) {
|
if (const auto channel = peer->asChannel()) {
|
||||||
if (!justClear && !revoke) {
|
if (!justClear && !revoke) {
|
||||||
channel->ptsWaitingForShortPoll(-1);
|
channel->ptsSetWaitingForShortPoll(-1);
|
||||||
leaveChannel(channel);
|
leaveChannel(channel);
|
||||||
} else {
|
} else {
|
||||||
if (const auto migrated = peer->migrateFrom()) {
|
if (const auto migrated = peer->migrateFrom()) {
|
||||||
|
|
|
@ -423,7 +423,7 @@ public:
|
||||||
return _ptsWaiter.setRequesting(isRequesting);
|
return _ptsWaiter.setRequesting(isRequesting);
|
||||||
}
|
}
|
||||||
// < 0 - not waiting
|
// < 0 - not waiting
|
||||||
void ptsWaitingForShortPoll(int32 ms) {
|
void ptsSetWaitingForShortPoll(int32 ms) {
|
||||||
return _ptsWaiter.setWaitingForShortPoll(this, ms);
|
return _ptsWaiter.setWaitingForShortPoll(this, ms);
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool ptsWaitingForSkipped() const {
|
[[nodiscard]] bool ptsWaitingForSkipped() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue