2024-04-09 15:04:18 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
class TopPeers final {
|
|
|
|
public:
|
|
|
|
explicit TopPeers(not_null<Main::Session*> session);
|
|
|
|
~TopPeers();
|
|
|
|
|
|
|
|
[[nodiscard]] std::vector<not_null<PeerData*>> list() const;
|
|
|
|
[[nodiscard]] bool disabled() const;
|
|
|
|
[[nodiscard]] rpl::producer<> updates() const;
|
|
|
|
|
2024-04-11 09:12:57 +00:00
|
|
|
void remove(not_null<PeerData*> peer);
|
2024-04-09 15:04:18 +00:00
|
|
|
void increment(not_null<PeerData*> peer, TimeId date);
|
|
|
|
void reload();
|
2024-04-11 12:32:58 +00:00
|
|
|
void toggleDisabled(bool disabled);
|
2024-04-09 15:04:18 +00:00
|
|
|
|
2024-04-11 13:46:19 +00:00
|
|
|
[[nodiscard]] QByteArray serialize() const;
|
|
|
|
void applyLocal(QByteArray serialized);
|
|
|
|
|
2024-04-09 15:04:18 +00:00
|
|
|
private:
|
|
|
|
struct TopPeer {
|
|
|
|
not_null<PeerData*> peer;
|
|
|
|
float64 rating = 0.;
|
|
|
|
};
|
|
|
|
|
|
|
|
void request();
|
|
|
|
[[nodiscard]] uint64 countHash() const;
|
2024-04-12 08:25:37 +00:00
|
|
|
void updated();
|
2024-04-09 15:04:18 +00:00
|
|
|
|
|
|
|
const not_null<Main::Session*> _session;
|
|
|
|
|
|
|
|
std::vector<TopPeer> _list;
|
|
|
|
rpl::event_stream<> _updates;
|
|
|
|
crl::time _lastReceived = 0;
|
|
|
|
TimeId _lastReceivedDate = 0;
|
|
|
|
|
|
|
|
mtpRequestId _requestId = 0;
|
|
|
|
|
|
|
|
bool _disabled = false;
|
|
|
|
bool _received = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Data
|