2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 00:55:12 +00:00

Remember scroll state between topic openings.

This commit is contained in:
John Preston
2022-11-03 16:29:22 +04:00
parent d7f2385275
commit 0dd45de254
14 changed files with 103 additions and 28 deletions

View File

@@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_item.h"
#include "history/history_unread_things.h"
#include "history/view/history_view_item_preview.h"
#include "history/view/history_view_replies_section.h"
#include "main/main_session.h"
#include "base/unixtime.h"
#include "ui/painter.h"
@@ -220,6 +221,13 @@ TimeId ForumTopic::creationDate() const {
return _creationDate;
}
not_null<HistoryView::ListMemento*> ForumTopic::listMemento() {
if (!_listMemento) {
_listMemento = std::make_unique<HistoryView::ListMemento>();
}
return _listMemento.get();
}
bool ForumTopic::my() const {
return (_flags & Flag::My);
}
@@ -286,7 +294,7 @@ void ForumTopic::applyTopic(const MTPDforumTopic &data) {
Expects(_rootId == data.vid().v);
applyCreator(peerFromMTP(data.vfrom_id()));
_creationDate = data.vdate().v;
applyCreationDate(data.vdate().v);
applyTitle(qs(data.vtitle()));
if (const auto iconId = data.vicon_emoji_id()) {
@@ -312,11 +320,7 @@ void ForumTopic::applyTopic(const MTPDforumTopic &data) {
_rootId,
draft->c_draftMessage());
}
if (data.is_my()) {
_flags |= Flag::My;
} else {
_flags &= ~Flag::My;
}
applyIsMy(data.is_my());
setClosed(data.is_closed());
_replies->setInboxReadTill(
@@ -335,6 +339,20 @@ void ForumTopic::applyCreator(PeerId creatorId) {
}
}
void ForumTopic::applyCreationDate(TimeId date) {
_creationDate = date;
}
void ForumTopic::applyIsMy(bool my) {
if (my != this->my()) {
if (my) {
_flags |= Flag::My;
} else {
_flags &= ~Flag::My;
}
}
}
bool ForumTopic::closed() const {
return _flags & Flag::Closed;
}