mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added show more button to statistics info for list of recent messages.
This commit is contained in:
parent
33cf9a0702
commit
f7ab8298cf
4 changed files with 47 additions and 17 deletions
|
@ -15,6 +15,7 @@ struct SavedState final {
|
||||||
Data::AnyStatistics stats;
|
Data::AnyStatistics stats;
|
||||||
base::flat_map<MsgId, QImage> recentPostPreviews;
|
base::flat_map<MsgId, QImage> recentPostPreviews;
|
||||||
Data::PublicForwardsSlice publicForwardsFirstSlice;
|
Data::PublicForwardsSlice publicForwardsFirstSlice;
|
||||||
|
int recentPostsExpanded = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Info::Statistics
|
} // namespace Info::Statistics
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "api/api_statistics.h"
|
#include "api/api_statistics.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
#include "base/call_delayed.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -697,25 +698,53 @@ void InnerWidget::fillRecentPosts() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto foundLoaded = false;
|
const auto buttonWrap = container->add(
|
||||||
for (const auto &recent : stats.recentMessageInteractions) {
|
object_ptr<Ui::SlideWrap<Ui::SettingsButton>>(
|
||||||
const auto messageWrap = content->add(
|
container,
|
||||||
object_ptr<Ui::VerticalLayout>(content));
|
object_ptr<Ui::SettingsButton>(
|
||||||
const auto msgId = recent.messageId;
|
container,
|
||||||
if (const auto item = _peer->owner().message(_peer, msgId)) {
|
tr::lng_stories_show_more())));
|
||||||
addMessage(messageWrap, item, recent);
|
|
||||||
foundLoaded = true;
|
constexpr auto kPerPage = int(10);
|
||||||
continue;
|
const auto max = stats.recentMessageInteractions.size();
|
||||||
|
if (_state.recentPostsExpanded) {
|
||||||
|
_state.recentPostsExpanded = std::max(
|
||||||
|
_state.recentPostsExpanded - kPerPage,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
const auto showMore = [=] {
|
||||||
|
const auto from = _state.recentPostsExpanded;
|
||||||
|
_state.recentPostsExpanded = std::min(
|
||||||
|
int(max),
|
||||||
|
_state.recentPostsExpanded + kPerPage);
|
||||||
|
if (_state.recentPostsExpanded == max) {
|
||||||
|
buttonWrap->toggle(false, anim::type::instant);
|
||||||
}
|
}
|
||||||
const auto callback = crl::guard(content, [=] {
|
for (auto i = from; i < _state.recentPostsExpanded; i++) {
|
||||||
|
const auto &recent = stats.recentMessageInteractions[i];
|
||||||
|
const auto messageWrap = content->add(
|
||||||
|
object_ptr<Ui::VerticalLayout>(content));
|
||||||
|
const auto msgId = recent.messageId;
|
||||||
if (const auto item = _peer->owner().message(_peer, msgId)) {
|
if (const auto item = _peer->owner().message(_peer, msgId)) {
|
||||||
addMessage(messageWrap, item, recent);
|
addMessage(messageWrap, item, recent);
|
||||||
content->resizeToWidth(content->width());
|
continue;
|
||||||
}
|
}
|
||||||
});
|
const auto callback = crl::guard(content, [=] {
|
||||||
_peer->session().api().requestMessageData(_peer, msgId, callback);
|
if (const auto item = _peer->owner().message(_peer, msgId)) {
|
||||||
}
|
addMessage(messageWrap, item, recent);
|
||||||
if (!foundLoaded) {
|
content->resizeToWidth(content->width());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_peer->session().api().requestMessageData(_peer, msgId, callback);
|
||||||
|
}
|
||||||
|
container->resizeToWidth(container->width());
|
||||||
|
};
|
||||||
|
const auto delay = st::defaultRippleAnimation.hideDuration;
|
||||||
|
buttonWrap->entity()->setClickedCallback([=] {
|
||||||
|
base::call_delayed(delay, crl::guard(container, showMore));
|
||||||
|
});
|
||||||
|
showMore();
|
||||||
|
if (_messagePreviews.empty()) {
|
||||||
wrap->toggle(false, anim::type::instant);
|
wrap->toggle(false, anim::type::instant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -696,7 +696,6 @@ void AddMembersList(
|
||||||
container,
|
container,
|
||||||
tr::lng_stories_show_more())),
|
tr::lng_stories_show_more())),
|
||||||
{ 0, -st::settingsButton.padding.top(), 0, 0 });
|
{ 0, -st::settingsButton.padding.top(), 0, 0 });
|
||||||
const auto button = wrap->entity();
|
|
||||||
|
|
||||||
const auto showMore = [=] {
|
const auto showMore = [=] {
|
||||||
state->limit = std::min(int(max), state->limit + kPerPage);
|
state->limit = std::min(int(max), state->limit + kPerPage);
|
||||||
|
@ -706,7 +705,7 @@ void AddMembersList(
|
||||||
}
|
}
|
||||||
container->resizeToWidth(container->width());
|
container->resizeToWidth(container->width());
|
||||||
};
|
};
|
||||||
button->setClickedCallback(showMore);
|
wrap->entity()->setClickedCallback(showMore);
|
||||||
showMore();
|
showMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,6 +215,7 @@ void MessagePreview::paintEvent(QPaintEvent *e) {
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = crl::now(),
|
.now = crl::now(),
|
||||||
.elisionHeight = st::statisticsDetailsPopupHeaderStyle.font->height,
|
.elisionHeight = st::statisticsDetailsPopupHeaderStyle.font->height,
|
||||||
|
.elisionLines = 1,
|
||||||
});
|
});
|
||||||
_views.draw(p, {
|
_views.draw(p, {
|
||||||
.position = { width() - _viewsWidth, topTextTop },
|
.position = { width() - _viewsWidth, topTextTop },
|
||||||
|
|
Loading…
Add table
Reference in a new issue