mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added more universal RecentPostId for saved state of statistics info.
This commit is contained in:
parent
69b9d404c0
commit
25d0123b9f
4 changed files with 20 additions and 6 deletions
|
@ -11,9 +11,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace Info::Statistics {
|
namespace Info::Statistics {
|
||||||
|
|
||||||
|
struct RecentPostId final {
|
||||||
|
FullMsgId messageId;
|
||||||
|
FullStoryId storyId;
|
||||||
|
|
||||||
|
[[nodiscard]] bool valid() const {
|
||||||
|
return messageId || storyId;
|
||||||
|
}
|
||||||
|
explicit operator bool() const {
|
||||||
|
return valid();
|
||||||
|
}
|
||||||
|
friend inline auto operator<=>(RecentPostId, RecentPostId) = default;
|
||||||
|
friend inline bool operator==(RecentPostId, RecentPostId) = default;
|
||||||
|
};
|
||||||
|
|
||||||
struct SavedState final {
|
struct SavedState final {
|
||||||
Data::AnyStatistics stats;
|
Data::AnyStatistics stats;
|
||||||
base::flat_map<MsgId, QImage> recentPostPreviews;
|
base::flat_map<RecentPostId, QImage> recentPostPreviews;
|
||||||
Data::PublicForwardsSlice publicForwardsFirstSlice;
|
Data::PublicForwardsSlice publicForwardsFirstSlice;
|
||||||
int recentPostsExpanded = 0;
|
int recentPostsExpanded = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -704,7 +704,8 @@ void InnerWidget::fillRecentPosts() {
|
||||||
messageWrap,
|
messageWrap,
|
||||||
rpl::never<QString>(),
|
rpl::never<QString>(),
|
||||||
st::statisticsRecentPostButton));
|
st::statisticsRecentPostButton));
|
||||||
auto it = _state.recentPostPreviews.find(item->fullId().msg);
|
auto it = _state.recentPostPreviews.find(
|
||||||
|
{ .messageId = item->fullId() });
|
||||||
auto cachedPreview = (it != end(_state.recentPostPreviews))
|
auto cachedPreview = (it != end(_state.recentPostPreviews))
|
||||||
? base::take(it->second)
|
? base::take(it->second)
|
||||||
: QImage();
|
: QImage();
|
||||||
|
|
|
@ -73,7 +73,6 @@ MessagePreview::MessagePreview(
|
||||||
int shares,
|
int shares,
|
||||||
QImage cachedPreview)
|
QImage cachedPreview)
|
||||||
: Ui::RpWidget(parent)
|
: Ui::RpWidget(parent)
|
||||||
, _item(item)
|
|
||||||
, _date(
|
, _date(
|
||||||
st::statisticsHeaderTitleTextStyle,
|
st::statisticsHeaderTitleTextStyle,
|
||||||
Ui::FormatDateTime(ItemDateTime(item)))
|
Ui::FormatDateTime(ItemDateTime(item)))
|
||||||
|
@ -98,7 +97,7 @@ MessagePreview::MessagePreview(
|
||||||
, _preview(std::move(cachedPreview)) {
|
, _preview(std::move(cachedPreview)) {
|
||||||
_text.setMarkedText(
|
_text.setMarkedText(
|
||||||
st::defaultPeerListItem.nameStyle,
|
st::defaultPeerListItem.nameStyle,
|
||||||
_item->toPreview({ .generateImages = false }).text,
|
item->toPreview({ .generateImages = false }).text,
|
||||||
Ui::DialogTextOptions(),
|
Ui::DialogTextOptions(),
|
||||||
Core::MarkedTextContext{
|
Core::MarkedTextContext{
|
||||||
.session = &item->history()->session(),
|
.session = &item->history()->session(),
|
||||||
|
@ -238,7 +237,7 @@ void MessagePreview::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
void MessagePreview::saveState(SavedState &state) const {
|
void MessagePreview::saveState(SavedState &state) const {
|
||||||
if (!_lifetimeDownload) {
|
if (!_lifetimeDownload) {
|
||||||
state.recentPostPreviews[_item->fullId().msg] = _preview;
|
state.recentPostPreviews[{ .messageId = _messageId }] = _preview;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
void processPreview(not_null<HistoryItem*> item);
|
void processPreview(not_null<HistoryItem*> item);
|
||||||
|
|
||||||
not_null<HistoryItem*> _item;
|
FullMsgId _messageId;
|
||||||
Ui::Text::String _text;
|
Ui::Text::String _text;
|
||||||
Ui::Text::String _date;
|
Ui::Text::String _date;
|
||||||
Ui::Text::String _views;
|
Ui::Text::String _views;
|
||||||
|
|
Loading…
Add table
Reference in a new issue