mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Added ability to create statistics info layer with story id.
This commit is contained in:
parent
f88eee8047
commit
34d0dac351
11 changed files with 62 additions and 42 deletions
|
@ -2283,7 +2283,7 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
if (channel->flags() & ChannelDataFlag::CanGetStatistics) {
|
||||
auto callback = crl::guard(controller, [=] {
|
||||
controller->showSection(
|
||||
Info::Statistics::Make(channel, itemId));
|
||||
Info::Statistics::Make(channel, itemId, {}));
|
||||
});
|
||||
_menu->addAction(
|
||||
tr::lng_stats_title(tr::now),
|
||||
|
|
|
@ -17,12 +17,13 @@ namespace Info::Boosts {
|
|||
Memento::Memento(not_null<Controller*> controller)
|
||||
: ContentMemento(Info::Statistics::Tag{
|
||||
controller->statisticsPeer(),
|
||||
{}
|
||||
{},
|
||||
{},
|
||||
}) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<PeerData*> peer)
|
||||
: ContentMemento(Info::Statistics::Tag{ peer, {} }) {
|
||||
: ContentMemento(Info::Statistics::Tag{ peer, {}, {} }) {
|
||||
}
|
||||
|
||||
Memento::~Memento() = default;
|
||||
|
|
|
@ -340,7 +340,11 @@ Key ContentMemento::key() const {
|
|||
} else if (const auto peer = storiesPeer()) {
|
||||
return Stories::Tag{ peer, storiesTab() };
|
||||
} else if (const auto peer = statisticsPeer()) {
|
||||
return Statistics::Tag{ peer, statisticsContextId() };
|
||||
return Statistics::Tag{
|
||||
peer,
|
||||
statisticsContextId(),
|
||||
statisticsStoryId(),
|
||||
};
|
||||
} else {
|
||||
return Downloads::Tag();
|
||||
}
|
||||
|
@ -379,7 +383,8 @@ ContentMemento::ContentMemento(Stories::Tag stories)
|
|||
|
||||
ContentMemento::ContentMemento(Statistics::Tag statistics)
|
||||
: _statisticsPeer(statistics.peer)
|
||||
, _statisticsContextId(statistics.contextId) {
|
||||
, _statisticsContextId(statistics.contextId)
|
||||
, _statisticsStoryId(statistics.storyId) {
|
||||
}
|
||||
|
||||
} // namespace Info
|
||||
|
|
|
@ -202,6 +202,9 @@ public:
|
|||
FullMsgId statisticsContextId() const {
|
||||
return _statisticsContextId;
|
||||
}
|
||||
FullStoryId statisticsStoryId() const {
|
||||
return _statisticsStoryId;
|
||||
}
|
||||
PollData *poll() const {
|
||||
return _poll;
|
||||
}
|
||||
|
@ -248,6 +251,7 @@ private:
|
|||
Stories::Tab _storiesTab = {};
|
||||
PeerData * const _statisticsPeer = nullptr;
|
||||
const FullMsgId _statisticsContextId;
|
||||
const FullStoryId _statisticsStoryId;
|
||||
PollData * const _poll = nullptr;
|
||||
const FullMsgId _pollContextId;
|
||||
|
||||
|
|
|
@ -106,6 +106,13 @@ FullMsgId Key::statisticsContextId() const {
|
|||
return {};
|
||||
}
|
||||
|
||||
FullStoryId Key::statisticsStoryId() const {
|
||||
if (const auto tag = std::get_if<Statistics::Tag>(&_value)) {
|
||||
return tag->storyId;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
PollData *Key::poll() const {
|
||||
if (const auto data = std::get_if<PollKey>(&_value)) {
|
||||
return data->poll;
|
||||
|
|
|
@ -58,13 +58,18 @@ struct Tag {
|
|||
namespace Info::Statistics {
|
||||
|
||||
struct Tag {
|
||||
explicit Tag(not_null<PeerData*> peer, FullMsgId contextId)
|
||||
explicit Tag(
|
||||
not_null<PeerData*> peer,
|
||||
FullMsgId contextId,
|
||||
FullStoryId storyId)
|
||||
: peer(peer)
|
||||
, contextId(contextId) {
|
||||
, contextId(contextId)
|
||||
, storyId(storyId) {
|
||||
}
|
||||
|
||||
not_null<PeerData*> peer;
|
||||
FullMsgId contextId;
|
||||
FullStoryId storyId;
|
||||
};
|
||||
|
||||
} // namespace Info::Statistics
|
||||
|
@ -89,6 +94,7 @@ public:
|
|||
Stories::Tab storiesTab() const;
|
||||
PeerData *statisticsPeer() const;
|
||||
FullMsgId statisticsContextId() const;
|
||||
FullStoryId statisticsStoryId() const;
|
||||
PollData *poll() const;
|
||||
FullMsgId pollContextId() const;
|
||||
|
||||
|
@ -194,6 +200,9 @@ public:
|
|||
[[nodiscard]] FullMsgId statisticsContextId() const {
|
||||
return key().statisticsContextId();
|
||||
}
|
||||
[[nodiscard]] FullStoryId statisticsStoryId() const {
|
||||
return key().statisticsStoryId();
|
||||
}
|
||||
[[nodiscard]] PollData *poll() const;
|
||||
[[nodiscard]] FullMsgId pollContextId() const {
|
||||
return key().pollContextId();
|
||||
|
|
|
@ -533,11 +533,13 @@ InnerWidget::InnerWidget(
|
|||
QWidget *parent,
|
||||
not_null<Controller*> controller,
|
||||
not_null<PeerData*> peer,
|
||||
FullMsgId contextId)
|
||||
FullMsgId contextId,
|
||||
FullStoryId storyId)
|
||||
: VerticalLayout(parent)
|
||||
, _controller(controller)
|
||||
, _peer(peer)
|
||||
, _contextId(contextId) {
|
||||
, _contextId(contextId)
|
||||
, _storyId(storyId) {
|
||||
}
|
||||
|
||||
void InnerWidget::load() {
|
||||
|
@ -803,13 +805,5 @@ void InnerWidget::showFinished() {
|
|||
_showFinished.fire({});
|
||||
}
|
||||
|
||||
not_null<PeerData*> InnerWidget::peer() const {
|
||||
return _peer;
|
||||
}
|
||||
|
||||
FullMsgId InnerWidget::contextId() const {
|
||||
return _contextId;
|
||||
}
|
||||
|
||||
} // namespace Info::Statistics
|
||||
|
||||
|
|
|
@ -38,10 +38,8 @@ public:
|
|||
QWidget *parent,
|
||||
not_null<Controller*> controller,
|
||||
not_null<PeerData*> peer,
|
||||
FullMsgId contextId);
|
||||
|
||||
[[nodiscard]] not_null<PeerData*> peer() const;
|
||||
[[nodiscard]] FullMsgId contextId() const;
|
||||
FullMsgId contextId,
|
||||
FullStoryId storyId);
|
||||
|
||||
[[nodiscard]] rpl::producer<Ui::ScrollToRequest> scrollToRequests() const;
|
||||
[[nodiscard]] rpl::producer<ShowRequest> showRequests() const;
|
||||
|
@ -59,6 +57,7 @@ private:
|
|||
not_null<Controller*> _controller;
|
||||
not_null<PeerData*> _peer;
|
||||
FullMsgId _contextId;
|
||||
FullStoryId _storyId;
|
||||
|
||||
std::vector<not_null<MessagePreview*>> _messagePreviews;
|
||||
|
||||
|
|
|
@ -18,11 +18,16 @@ Memento::Memento(not_null<Controller*> controller)
|
|||
: ContentMemento(Tag{
|
||||
controller->statisticsPeer(),
|
||||
controller->statisticsContextId(),
|
||||
controller->statisticsStoryId(),
|
||||
}) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<PeerData*> peer, FullMsgId contextId)
|
||||
: ContentMemento(Tag{ peer, contextId }) {
|
||||
: ContentMemento(Tag{ peer, contextId, {} }) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<PeerData*> peer, FullStoryId storyId)
|
||||
: ContentMemento(Tag{ peer, {}, storyId }) {
|
||||
}
|
||||
|
||||
Memento::~Memento() = default;
|
||||
|
@ -57,7 +62,8 @@ Widget::Widget(
|
|||
this,
|
||||
controller,
|
||||
controller->statisticsPeer(),
|
||||
controller->statisticsContextId()))) {
|
||||
controller->statisticsContextId(),
|
||||
controller->statisticsStoryId()))) {
|
||||
_inner->showRequests(
|
||||
) | rpl::start_with_next([=](InnerWidget::ShowRequest request) {
|
||||
if (request.history) {
|
||||
|
@ -70,7 +76,8 @@ Widget::Widget(
|
|||
} else if (request.messageStatistic) {
|
||||
controller->showSection(Make(
|
||||
controller->statisticsPeer(),
|
||||
request.messageStatistic));
|
||||
request.messageStatistic,
|
||||
{}));
|
||||
}
|
||||
}, _inner->lifetime());
|
||||
_inner->scrollToRequests(
|
||||
|
@ -79,20 +86,12 @@ Widget::Widget(
|
|||
}, _inner->lifetime());
|
||||
}
|
||||
|
||||
not_null<PeerData*> Widget::peer() const {
|
||||
return _inner->peer();
|
||||
}
|
||||
|
||||
FullMsgId Widget::contextId() const {
|
||||
return _inner->contextId();
|
||||
}
|
||||
|
||||
bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
||||
return false;
|
||||
}
|
||||
|
||||
rpl::producer<QString> Widget::title() {
|
||||
return _inner->contextId()
|
||||
return controller()->statisticsContextId()
|
||||
? tr::lng_stats_message_title()
|
||||
: tr::lng_stats_title();
|
||||
}
|
||||
|
@ -131,11 +130,13 @@ void Widget::restoreState(not_null<Memento*> memento) {
|
|||
|
||||
std::shared_ptr<Info::Memento> Make(
|
||||
not_null<PeerData*> peer,
|
||||
FullMsgId contextId) {
|
||||
FullMsgId contextId,
|
||||
FullStoryId storyId) {
|
||||
const auto memento = storyId
|
||||
? std::make_shared<Memento>(peer, storyId)
|
||||
: std::make_shared<Memento>(peer, contextId);
|
||||
return std::make_shared<Info::Memento>(
|
||||
std::vector<std::shared_ptr<ContentMemento>>(
|
||||
1,
|
||||
std::make_shared<Memento>(peer, contextId)));
|
||||
std::vector<std::shared_ptr<ContentMemento>>(1, std::move(memento)));
|
||||
}
|
||||
|
||||
} // namespace Info::Statistics
|
||||
|
|
|
@ -18,6 +18,7 @@ class Memento final : public ContentMemento {
|
|||
public:
|
||||
Memento(not_null<Controller*> controller);
|
||||
Memento(not_null<PeerData*> peer, FullMsgId contextId);
|
||||
Memento(not_null<PeerData*> peer, FullStoryId storyId);
|
||||
~Memento();
|
||||
|
||||
object_ptr<ContentWidget> createWidget(
|
||||
|
@ -44,9 +45,6 @@ public:
|
|||
rpl::producer<bool> desiredShadowVisibility() const override;
|
||||
void showFinished() override;
|
||||
|
||||
[[nodiscard]] not_null<PeerData*> peer() const;
|
||||
[[nodiscard]] FullMsgId contextId() const;
|
||||
|
||||
void setInternalState(
|
||||
const QRect &geometry,
|
||||
not_null<Memento*> memento);
|
||||
|
@ -63,6 +61,7 @@ private:
|
|||
|
||||
[[nodiscard]] std::shared_ptr<Info::Memento> Make(
|
||||
not_null<PeerData*> peer,
|
||||
FullMsgId contextId);
|
||||
FullMsgId contextId,
|
||||
FullStoryId storyId);
|
||||
|
||||
} // namespace Info::Statistics
|
||||
|
|
|
@ -1008,7 +1008,8 @@ void Filler::addViewStatistics() {
|
|||
if (channel->flags() & ChannelDataFlag::CanGetStatistics) {
|
||||
_addAction(tr::lng_stats_title(tr::now), [=] {
|
||||
if (const auto strong = weak.get()) {
|
||||
controller->showSection(Info::Statistics::Make(peer, {}));
|
||||
using namespace Info;
|
||||
controller->showSection(Statistics::Make(peer, {}, {}));
|
||||
}
|
||||
}, &st::menuIconStats);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue