diff --git a/Telegram/SourceFiles/statistics/statistics_box.cpp b/Telegram/SourceFiles/statistics/statistics_box.cpp index 9aa7c342f..c93961d15 100644 --- a/Telegram/SourceFiles/statistics/statistics_box.cpp +++ b/Telegram/SourceFiles/statistics/statistics_box.cpp @@ -21,6 +21,14 @@ namespace { void StatisticsBox(not_null box, not_null peer) { const auto chartWidget = box->addRow( object_ptr(box)); + const auto chartWidget2 = box->addRow( + object_ptr(box)); + const auto chartWidget3 = box->addRow( + object_ptr(box)); + const auto chartWidget4 = box->addRow( + object_ptr(box)); + const auto chartWidget5 = box->addRow( + object_ptr(box)); const auto api = chartWidget->lifetime().make_state( &peer->session().api()); @@ -50,13 +58,60 @@ void StatisticsBox(not_null box, not_null peer) { } }; + const auto processChart = [=]( + not_null widget, + const Data::StatisticalGraph &graphData, + rpl::producer &&title) { + if (graphData.chart) { + widget->setChartData(graphData.chart); + processZoom(widget, graphData.zoomToken); + widget->setTitle(std::move(title)); + } else if (!graphData.zoomToken.isEmpty()) { + api->requestZoom( + peer, + graphData.zoomToken, + 0 + ) | rpl::start_with_next_error_done([=]( + const Data::StatisticalGraph &graph) { + if (graph.chart) { + widget->setChartData(graph.chart); + processZoom(widget, graph.zoomToken); + widget->setTitle(rpl::duplicate(title)); + } else if (!graph.error.isEmpty()) { + Ui::Toast::Show( + box->uiShow()->toastParent(), + graph.error); + } + }, [=](const QString &error) { + }, [=] { + }, widget->lifetime()); + } + }; + api->request( peer ) | rpl::start_with_done([=] { if (const auto stats = api->channelStats()) { - chartWidget->setChartData(stats.memberCountGraph.chart); - processZoom(chartWidget, stats.memberCountGraph.zoomToken); - chartWidget->setTitle(tr::lng_chart_title_member_count()); + processChart( + chartWidget, + stats.memberCountGraph, + tr::lng_chart_title_member_count()); + processChart( + chartWidget2, + stats.joinGraph, + tr::lng_chart_title_join()); + processChart( + chartWidget3, + stats.muteGraph, + tr::lng_chart_title_mute()); + processChart( + chartWidget4, + stats.viewCountBySourceGraph, + tr::lng_chart_title_view_count_by_source()); + processChart( + chartWidget5, + stats.joinBySourceGraph, + tr::lng_chart_title_join_by_source()); } }, chartWidget->lifetime()); box->setTitle(tr::lng_stats_title());