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

View File

@ -18,7 +18,7 @@ public:
explicit SendAsPeers(not_null<Session*> session); explicit SendAsPeers(not_null<Session*> session);
bool shouldChoose(not_null<PeerData*> peer); 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( [[nodiscard]] const std::vector<not_null<PeerData*>> &list(
not_null<PeerData*> peer) const; not_null<PeerData*> peer) const;
[[nodiscard]] rpl::producer<not_null<PeerData*>> updated() const; [[nodiscard]] rpl::producer<not_null<PeerData*>> updated() const;