mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +02:00
Moved out Info::Statistics::Tag to separated file.
This commit is contained in:
parent
bf55c325ce
commit
32b8d83c04
11 changed files with 65 additions and 104 deletions
|
@ -995,6 +995,7 @@ PRIVATE
|
|||
info/statistics/info_statistics_list_controllers.h
|
||||
info/statistics/info_statistics_recent_message.cpp
|
||||
info/statistics/info_statistics_recent_message.h
|
||||
info/statistics/info_statistics_tag.h
|
||||
info/statistics/info_statistics_widget.cpp
|
||||
info/statistics/info_statistics_widget.h
|
||||
info/stories/info_stories_inner_widget.cpp
|
||||
|
|
|
@ -16,11 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Info::BotEarn {
|
||||
|
||||
Memento::Memento(not_null<Controller*> controller)
|
||||
: ContentMemento(Info::Statistics::Tag{
|
||||
controller->statisticsPeer(),
|
||||
{},
|
||||
{},
|
||||
}) {
|
||||
: ContentMemento(controller->statisticsTag()) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<PeerData*> peer)
|
||||
|
@ -58,7 +54,7 @@ Widget::Widget(
|
|||
object_ptr<InnerWidget>(
|
||||
this,
|
||||
controller,
|
||||
controller->statisticsPeer()))) {
|
||||
controller->statisticsTag().peer))) {
|
||||
_inner->showRequests(
|
||||
) | rpl::start_with_next([=](InnerWidget::ShowRequest request) {
|
||||
}, _inner->lifetime());
|
||||
|
@ -73,7 +69,7 @@ not_null<PeerData*> Widget::peer() const {
|
|||
}
|
||||
|
||||
bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
||||
return (memento->statisticsPeer() == peer());
|
||||
return (memento->statisticsTag().peer == peer());
|
||||
}
|
||||
|
||||
rpl::producer<QString> Widget::title() {
|
||||
|
|
|
@ -16,11 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Info::Boosts {
|
||||
|
||||
Memento::Memento(not_null<Controller*> controller)
|
||||
: ContentMemento(Info::Statistics::Tag{
|
||||
controller->statisticsPeer(),
|
||||
{},
|
||||
{},
|
||||
}) {
|
||||
: ContentMemento(controller->statisticsTag()) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<PeerData*> peer)
|
||||
|
@ -58,7 +54,7 @@ Widget::Widget(
|
|||
object_ptr<InnerWidget>(
|
||||
this,
|
||||
controller,
|
||||
controller->statisticsPeer()))) {
|
||||
controller->statisticsTag().peer))) {
|
||||
_inner->showRequests(
|
||||
) | rpl::start_with_next([=](InnerWidget::ShowRequest request) {
|
||||
}, _inner->lifetime());
|
||||
|
@ -73,7 +69,7 @@ not_null<PeerData*> Widget::peer() const {
|
|||
}
|
||||
|
||||
bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
||||
return (memento->statisticsPeer() == peer());
|
||||
return (memento->statisticsTag().peer == peer());
|
||||
}
|
||||
|
||||
rpl::producer<QString> Widget::title() {
|
||||
|
|
|
@ -16,11 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Info::ChannelEarn {
|
||||
|
||||
Memento::Memento(not_null<Controller*> controller)
|
||||
: ContentMemento(Info::Statistics::Tag{
|
||||
controller->statisticsPeer(),
|
||||
{},
|
||||
{},
|
||||
}) {
|
||||
: ContentMemento(controller->statisticsTag()) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<PeerData*> peer)
|
||||
|
@ -58,7 +54,7 @@ Widget::Widget(
|
|||
object_ptr<InnerWidget>(
|
||||
this,
|
||||
controller,
|
||||
controller->statisticsPeer()))) {
|
||||
controller->statisticsTag().peer))) {
|
||||
_inner->showRequests(
|
||||
) | rpl::start_with_next([=](InnerWidget::ShowRequest request) {
|
||||
}, _inner->lifetime());
|
||||
|
@ -73,7 +69,7 @@ not_null<PeerData*> Widget::peer() const {
|
|||
}
|
||||
|
||||
bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
||||
return (memento->statisticsPeer() == peer());
|
||||
return (memento->statisticsTag().peer == peer());
|
||||
}
|
||||
|
||||
rpl::producer<QString> Widget::title() {
|
||||
|
|
|
@ -375,12 +375,8 @@ Key ContentMemento::key() const {
|
|||
return Settings::Tag{ self };
|
||||
} else if (const auto peer = storiesPeer()) {
|
||||
return Stories::Tag{ peer, storiesTab() };
|
||||
} else if (const auto peer = statisticsPeer()) {
|
||||
return Statistics::Tag{
|
||||
peer,
|
||||
statisticsContextId(),
|
||||
statisticsStoryId(),
|
||||
};
|
||||
} else if (const auto peer = statisticsTag().peer) {
|
||||
return statisticsTag();
|
||||
} else {
|
||||
return Downloads::Tag();
|
||||
}
|
||||
|
@ -418,9 +414,7 @@ ContentMemento::ContentMemento(Stories::Tag stories)
|
|||
}
|
||||
|
||||
ContentMemento::ContentMemento(Statistics::Tag statistics)
|
||||
: _statisticsPeer(statistics.peer)
|
||||
, _statisticsContextId(statistics.contextId)
|
||||
, _statisticsStoryId(statistics.storyId) {
|
||||
: _statisticsTag(statistics) {
|
||||
}
|
||||
|
||||
} // namespace Info
|
||||
|
|
|
@ -7,9 +7,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <rpl/variable.h>
|
||||
#include "ui/rp_widget.h"
|
||||
#include "info/info_wrap_widget.h"
|
||||
#include "info/statistics/info_statistics_tag.h"
|
||||
|
||||
namespace Dialogs::Stories {
|
||||
struct Content;
|
||||
|
@ -216,14 +215,8 @@ public:
|
|||
Stories::Tab storiesTab() const {
|
||||
return _storiesTab;
|
||||
}
|
||||
PeerData *statisticsPeer() const {
|
||||
return _statisticsPeer;
|
||||
}
|
||||
FullMsgId statisticsContextId() const {
|
||||
return _statisticsContextId;
|
||||
}
|
||||
FullStoryId statisticsStoryId() const {
|
||||
return _statisticsStoryId;
|
||||
Statistics::Tag statisticsTag() const {
|
||||
return _statisticsTag;
|
||||
}
|
||||
PollData *poll() const {
|
||||
return _poll;
|
||||
|
@ -269,9 +262,7 @@ private:
|
|||
UserData * const _settingsSelf = nullptr;
|
||||
PeerData * const _storiesPeer = nullptr;
|
||||
Stories::Tab _storiesTab = {};
|
||||
PeerData * const _statisticsPeer = nullptr;
|
||||
const FullMsgId _statisticsContextId;
|
||||
const FullStoryId _statisticsStoryId;
|
||||
Statistics::Tag _statisticsTag;
|
||||
PollData * const _poll = nullptr;
|
||||
const FullMsgId _pollContextId;
|
||||
|
||||
|
|
|
@ -92,25 +92,11 @@ Stories::Tab Key::storiesTab() const {
|
|||
return Stories::Tab();
|
||||
}
|
||||
|
||||
PeerData *Key::statisticsPeer() const {
|
||||
Statistics::Tag Key::statisticsTag() const {
|
||||
if (const auto tag = std::get_if<Statistics::Tag>(&_value)) {
|
||||
return tag->peer;
|
||||
return *tag;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FullMsgId Key::statisticsContextId() const {
|
||||
if (const auto tag = std::get_if<Statistics::Tag>(&_value)) {
|
||||
return tag->contextId;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
FullStoryId Key::statisticsStoryId() const {
|
||||
if (const auto tag = std::get_if<Statistics::Tag>(&_value)) {
|
||||
return tag->storyId;
|
||||
}
|
||||
return {};
|
||||
return Statistics::Tag();
|
||||
}
|
||||
|
||||
PollData *Key::poll() const {
|
||||
|
@ -292,7 +278,7 @@ bool Controller::validateMementoPeer(
|
|||
&& memento->migratedPeerId() == migratedPeerId()
|
||||
&& memento->settingsSelf() == settingsSelf()
|
||||
&& memento->storiesPeer() == storiesPeer()
|
||||
&& memento->statisticsPeer() == statisticsPeer();
|
||||
&& memento->statisticsTag().peer == statisticsTag().peer;
|
||||
}
|
||||
|
||||
void Controller::setSection(not_null<ContentMemento*> memento) {
|
||||
|
|
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#pragma once
|
||||
|
||||
#include "data/data_search_controller.h"
|
||||
#include "info/statistics/info_statistics_tag.h"
|
||||
#include "window/window_session_controller.h"
|
||||
|
||||
namespace Data {
|
||||
|
@ -55,25 +56,6 @@ struct Tag {
|
|||
|
||||
} // namespace Info::Stories
|
||||
|
||||
namespace Info::Statistics {
|
||||
|
||||
struct Tag {
|
||||
explicit Tag(
|
||||
not_null<PeerData*> peer,
|
||||
FullMsgId contextId,
|
||||
FullStoryId storyId)
|
||||
: peer(peer)
|
||||
, contextId(contextId)
|
||||
, storyId(storyId) {
|
||||
}
|
||||
|
||||
not_null<PeerData*> peer;
|
||||
FullMsgId contextId;
|
||||
FullStoryId storyId;
|
||||
};
|
||||
|
||||
} // namespace Info::Statistics
|
||||
|
||||
namespace Info {
|
||||
|
||||
class Key {
|
||||
|
@ -92,9 +74,7 @@ public:
|
|||
bool isDownloads() const;
|
||||
PeerData *storiesPeer() const;
|
||||
Stories::Tab storiesTab() const;
|
||||
PeerData *statisticsPeer() const;
|
||||
FullMsgId statisticsContextId() const;
|
||||
FullStoryId statisticsStoryId() const;
|
||||
Statistics::Tag statisticsTag() const;
|
||||
PollData *poll() const;
|
||||
FullMsgId pollContextId() const;
|
||||
|
||||
|
@ -199,14 +179,8 @@ public:
|
|||
[[nodiscard]] Stories::Tab storiesTab() const {
|
||||
return key().storiesTab();
|
||||
}
|
||||
[[nodiscard]] PeerData *statisticsPeer() const {
|
||||
return key().statisticsPeer();
|
||||
}
|
||||
[[nodiscard]] FullMsgId statisticsContextId() const {
|
||||
return key().statisticsContextId();
|
||||
}
|
||||
[[nodiscard]] FullStoryId statisticsStoryId() const {
|
||||
return key().statisticsStoryId();
|
||||
[[nodiscard]] Statistics::Tag statisticsTag() const {
|
||||
return key().statisticsTag();
|
||||
}
|
||||
[[nodiscard]] PollData *poll() const;
|
||||
[[nodiscard]] FullMsgId pollContextId() const {
|
||||
|
|
|
@ -290,7 +290,7 @@ Dialogs::RowDescriptor WrapWidget::activeChat() const {
|
|||
} else if (key().settingsSelf()
|
||||
|| key().isDownloads()
|
||||
|| key().poll()
|
||||
|| key().statisticsPeer()) {
|
||||
|| key().statisticsTag().peer) {
|
||||
return Dialogs::RowDescriptor();
|
||||
}
|
||||
Unexpected("Owner in WrapWidget::activeChat().");
|
||||
|
|
31
Telegram/SourceFiles/info/statistics/info_statistics_tag.h
Normal file
31
Telegram/SourceFiles/info/statistics/info_statistics_tag.h
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
class PeerData;
|
||||
|
||||
namespace Info::Statistics {
|
||||
|
||||
struct Tag final {
|
||||
explicit Tag() = default;
|
||||
explicit Tag(
|
||||
PeerData *peer,
|
||||
FullMsgId contextId,
|
||||
FullStoryId storyId)
|
||||
: peer(peer)
|
||||
, contextId(contextId)
|
||||
, storyId(storyId) {
|
||||
}
|
||||
|
||||
PeerData *peer = nullptr;
|
||||
FullMsgId contextId;
|
||||
FullStoryId storyId;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Info::Statistics
|
|
@ -19,11 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
namespace Info::Statistics {
|
||||
|
||||
Memento::Memento(not_null<Controller*> controller)
|
||||
: ContentMemento(Tag{
|
||||
controller->statisticsPeer(),
|
||||
controller->statisticsContextId(),
|
||||
controller->statisticsStoryId(),
|
||||
}) {
|
||||
: ContentMemento(controller->statisticsTag()) {
|
||||
}
|
||||
|
||||
Memento::Memento(not_null<PeerData*> peer, FullMsgId contextId)
|
||||
|
@ -65,9 +61,9 @@ Widget::Widget(
|
|||
object_ptr<InnerWidget>(
|
||||
this,
|
||||
controller,
|
||||
controller->statisticsPeer(),
|
||||
controller->statisticsContextId(),
|
||||
controller->statisticsStoryId()))) {
|
||||
controller->statisticsTag().peer,
|
||||
controller->statisticsTag().contextId,
|
||||
controller->statisticsTag().storyId))) {
|
||||
_inner->showRequests(
|
||||
) | rpl::start_with_next([=](InnerWidget::ShowRequest request) {
|
||||
if (request.history) {
|
||||
|
@ -79,7 +75,7 @@ Widget::Widget(
|
|||
controller->showPeerInfo(request.info);
|
||||
} else if (request.messageStatistic || request.storyStatistic) {
|
||||
controller->showSection(Make(
|
||||
controller->statisticsPeer(),
|
||||
controller->statisticsTag().peer,
|
||||
request.messageStatistic,
|
||||
request.storyStatistic));
|
||||
} else if (const auto &s = request.story) {
|
||||
|
@ -92,7 +88,7 @@ Widget::Widget(
|
|||
}
|
||||
}, _inner->lifetime());
|
||||
_inner->scrollToRequests(
|
||||
) | rpl::start_with_next([=](const Ui::ScrollToRequest &request) {
|
||||
) | rpl::start_with_next([this](const Ui::ScrollToRequest &request) {
|
||||
scrollTo(request);
|
||||
}, _inner->lifetime());
|
||||
}
|
||||
|
@ -102,9 +98,9 @@ bool Widget::showInternal(not_null<ContentMemento*> memento) {
|
|||
}
|
||||
|
||||
rpl::producer<QString> Widget::title() {
|
||||
return controller()->statisticsContextId()
|
||||
return controller()->statisticsTag().contextId
|
||||
? tr::lng_stats_message_title()
|
||||
: controller()->statisticsStoryId()
|
||||
: controller()->statisticsTag().storyId
|
||||
? tr::lng_stats_story_title()
|
||||
: tr::lng_stats_title();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue