Fix "Send As" list refresh on admin anonymity change.

This commit is contained in:
John Preston 2021-11-29 09:24:38 +04:00
parent 8460a62588
commit f2915064b5
2 changed files with 4 additions and 4 deletions

View File

@ -37,7 +37,7 @@ SendAsPeers::SendAsPeers(not_null<Session*> session)
) | rpl::filter([=](not_null<PeerData*> peer, bool, bool) {
return _lists.contains(peer);
}) | rpl::start_with_next([=](not_null<PeerData*> peer, bool, bool) {
refresh(peer);
refresh(peer, true);
}, _lifetime);
}
@ -46,14 +46,14 @@ bool SendAsPeers::shouldChoose(not_null<PeerData*> peer) {
return peer->canWrite() && (list(peer).size() > 1);
}
void SendAsPeers::refresh(not_null<PeerData*> peer) {
void SendAsPeers::refresh(not_null<PeerData*> peer, bool force) {
if (!peer->isMegagroup()) {
return;
}
const auto now = crl::now();
const auto i = _lastRequestTime.find(peer);
const auto when = (i == end(_lastRequestTime)) ? -1 : i->second;
if (when >= 0 && now < when + kRequestEach) {
if (!force && (when >= 0 && now < when + kRequestEach)) {
return;
}
_lastRequestTime[peer] = now;

View File

@ -18,7 +18,7 @@ public:
explicit SendAsPeers(not_null<Session*> session);
bool shouldChoose(not_null<PeerData*> peer);
void refresh(not_null<PeerData*> peer);
void refresh(not_null<PeerData*> peer, bool force = false);
[[nodiscard]] const std::vector<not_null<PeerData*>> &list(
not_null<PeerData*> peer) const;
[[nodiscard]] rpl::producer<not_null<PeerData*>> updated() const;