2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-27 12:47:16 +00:00

65 lines
1.3 KiB
C
Raw Normal View History

2024-04-09 19:04:18 +04: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 {
2024-07-25 18:08:22 +02:00
enum class TopPeerType {
Chat,
BotApp,
};
2024-04-09 19:04:18 +04:00
class TopPeers final {
public:
2024-07-25 18:08:22 +02:00
TopPeers(not_null<Main::Session*> session, TopPeerType type);
2024-04-09 19:04:18 +04:00
~TopPeers();
[[nodiscard]] std::vector<not_null<PeerData*>> list() const;
[[nodiscard]] bool disabled() const;
[[nodiscard]] rpl::producer<> updates() const;
2024-04-11 13:12:57 +04:00
void remove(not_null<PeerData*> peer);
2024-04-09 19:04:18 +04:00
void increment(not_null<PeerData*> peer, TimeId date);
void reload();
void toggleDisabled(bool disabled);
2024-04-09 19:04:18 +04:00
2024-04-11 17:46:19 +04:00
[[nodiscard]] QByteArray serialize() const;
void applyLocal(QByteArray serialized);
2024-04-09 19:04:18 +04:00
private:
struct TopPeer {
not_null<PeerData*> peer;
float64 rating = 0.;
};
2024-07-25 18:08:22 +02:00
void loadAfterChats();
2024-04-09 19:04:18 +04:00
void request();
[[nodiscard]] uint64 countHash() const;
2024-04-12 12:25:37 +04:00
void updated();
2024-04-09 19:04:18 +04:00
const not_null<Main::Session*> _session;
2024-07-25 18:08:22 +02:00
const TopPeerType _type = {};
2024-04-09 19:04:18 +04:00
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