mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-25 10:01:00 +00:00
Added more universal RecentPostId for saved state of statistics info.
This commit is contained in:
parent
69b9d404c0
commit
25d0123b9f
@ -11,9 +11,23 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
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 {
|
||||
Data::AnyStatistics stats;
|
||||
base::flat_map<MsgId, QImage> recentPostPreviews;
|
||||
base::flat_map<RecentPostId, QImage> recentPostPreviews;
|
||||
Data::PublicForwardsSlice publicForwardsFirstSlice;
|
||||
int recentPostsExpanded = 0;
|
||||
};
|
||||
|
@ -704,7 +704,8 @@ void InnerWidget::fillRecentPosts() {
|
||||
messageWrap,
|
||||
rpl::never<QString>(),
|
||||
st::statisticsRecentPostButton));
|
||||
auto it = _state.recentPostPreviews.find(item->fullId().msg);
|
||||
auto it = _state.recentPostPreviews.find(
|
||||
{ .messageId = item->fullId() });
|
||||
auto cachedPreview = (it != end(_state.recentPostPreviews))
|
||||
? base::take(it->second)
|
||||
: QImage();
|
||||
|
@ -73,7 +73,6 @@ MessagePreview::MessagePreview(
|
||||
int shares,
|
||||
QImage cachedPreview)
|
||||
: Ui::RpWidget(parent)
|
||||
, _item(item)
|
||||
, _date(
|
||||
st::statisticsHeaderTitleTextStyle,
|
||||
Ui::FormatDateTime(ItemDateTime(item)))
|
||||
@ -98,7 +97,7 @@ MessagePreview::MessagePreview(
|
||||
, _preview(std::move(cachedPreview)) {
|
||||
_text.setMarkedText(
|
||||
st::defaultPeerListItem.nameStyle,
|
||||
_item->toPreview({ .generateImages = false }).text,
|
||||
item->toPreview({ .generateImages = false }).text,
|
||||
Ui::DialogTextOptions(),
|
||||
Core::MarkedTextContext{
|
||||
.session = &item->history()->session(),
|
||||
@ -238,7 +237,7 @@ void MessagePreview::paintEvent(QPaintEvent *e) {
|
||||
|
||||
void MessagePreview::saveState(SavedState &state) const {
|
||||
if (!_lifetimeDownload) {
|
||||
state.recentPostPreviews[_item->fullId().msg] = _preview;
|
||||
state.recentPostPreviews[{ .messageId = _messageId }] = _preview;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ protected:
|
||||
private:
|
||||
void processPreview(not_null<HistoryItem*> item);
|
||||
|
||||
not_null<HistoryItem*> _item;
|
||||
FullMsgId _messageId;
|
||||
Ui::Text::String _text;
|
||||
Ui::Text::String _date;
|
||||
Ui::Text::String _views;
|
||||
|
Loading…
Reference in New Issue
Block a user