Added message preview to message statistics.

This commit is contained in:
23rd 2023-10-22 22:07:53 +03:00 committed by John Preston
parent 0be2e8b672
commit d4db838d43
2 changed files with 21 additions and 10 deletions

View file

@ -542,6 +542,14 @@ void InnerWidget::fill() {
lifetime().make_state<Api::Statistics>(&_peer->session().api()), lifetime().make_state<Api::Statistics>(&_peer->session().api()),
_controller->uiShow()->toastParent(), _controller->uiShow()->toastParent(),
}; };
if (_state.stats.message) {
if (const auto i = _peer->owner().message(_contextId)) {
::Settings::AddSkip(inner);
inner->add(object_ptr<MessagePreview>(this, i, -1, -1, QImage()));
::Settings::AddSkip(inner);
::Settings::AddDivider(inner);
}
}
FillOverview(inner, _state.stats); FillOverview(inner, _state.stats);
FillStatistic(inner, descriptor, _state.stats); FillStatistic(inner, descriptor, _state.stats);
const auto &channel = _state.stats.channel; const auto &channel = _state.stats.channel;
@ -553,8 +561,7 @@ void InnerWidget::fill() {
const auto showPeerInfo = [=](not_null<PeerData*> peer) { const auto showPeerInfo = [=](not_null<PeerData*> peer) {
_showRequests.fire({ .info = peer->id }); _showRequests.fire({ .info = peer->id });
}; };
const auto addSkip = [&]( const auto addSkip = [&](not_null<Ui::VerticalLayout*> c) {
not_null<Ui::VerticalLayout*> c) {
::Settings::AddSkip(c); ::Settings::AddSkip(c);
::Settings::AddDivider(c); ::Settings::AddDivider(c);
::Settings::AddSkip(c); ::Settings::AddSkip(c);

View file

@ -79,16 +79,20 @@ MessagePreview::MessagePreview(
Ui::FormatDateTime(ItemDateTime(item))) Ui::FormatDateTime(ItemDateTime(item)))
, _views( , _views(
st::defaultPeerListItem.nameStyle, st::defaultPeerListItem.nameStyle,
tr::lng_stats_recent_messages_views( (views >= 0)
? tr::lng_stats_recent_messages_views(
tr::now, tr::now,
lt_count_decimal, lt_count_decimal,
views)) views)
: QString())
, _shares( , _shares(
st::statisticsHeaderTitleTextStyle, st::statisticsHeaderTitleTextStyle,
tr::lng_stats_recent_messages_shares( (shares >= 0)
? tr::lng_stats_recent_messages_shares(
tr::now, tr::now,
lt_count_decimal, lt_count_decimal,
shares)) shares)
: QString())
, _viewsWidth(_views.maxWidth()) , _viewsWidth(_views.maxWidth())
, _sharesWidth(_shares.maxWidth()) , _sharesWidth(_shares.maxWidth())
, _preview(std::move(cachedPreview)) { , _preview(std::move(cachedPreview)) {