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()),
_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);
FillStatistic(inner, descriptor, _state.stats);
const auto &channel = _state.stats.channel;
@ -553,8 +561,7 @@ void InnerWidget::fill() {
const auto showPeerInfo = [=](not_null<PeerData*> peer) {
_showRequests.fire({ .info = peer->id });
};
const auto addSkip = [&](
not_null<Ui::VerticalLayout*> c) {
const auto addSkip = [&](not_null<Ui::VerticalLayout*> c) {
::Settings::AddSkip(c);
::Settings::AddDivider(c);
::Settings::AddSkip(c);

View File

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