2023-04-26 19:06:54 +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
|
|
|
|
*/
|
|
|
|
#include "statistics/statistics_box.h"
|
|
|
|
|
2023-05-24 15:30:30 +00:00
|
|
|
#include "api/api_statistics.h"
|
2023-04-26 19:06:54 +00:00
|
|
|
#include "data/data_peer.h"
|
|
|
|
#include "lang/lang_keys.h"
|
2023-05-24 15:30:30 +00:00
|
|
|
#include "main/main_session.h"
|
|
|
|
#include "statistics/chart_widget.h"
|
2023-04-26 19:06:54 +00:00
|
|
|
#include "ui/layers/generic_box.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void StatisticsBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
2023-05-24 15:30:30 +00:00
|
|
|
const auto chartWidget = box->addRow(
|
|
|
|
object_ptr<Statistic::ChartWidget>(box));
|
|
|
|
const auto api = chartWidget->lifetime().make_state<Api::Statistics>(
|
|
|
|
&peer->session().api());
|
|
|
|
|
|
|
|
api->request(
|
|
|
|
peer
|
|
|
|
) | rpl::start_with_done([=] {
|
|
|
|
if (const auto stats = api->channelStats()) {
|
|
|
|
chartWidget->setChartData(stats.memberCountGraph.chart);
|
|
|
|
}
|
|
|
|
}, chartWidget->lifetime());
|
2023-04-26 19:06:54 +00:00
|
|
|
box->setTitle(tr::lng_stats_title());
|
|
|
|
}
|