Fill reply history windows at boundaries and preserve read position

This commit is contained in:
evgeny committed 2026-10-08 00:36:52 +02:00
1 parent 3ea830fa00
commit adf1e9507a
2 files changed
+20 -7

No files matched your search

+5 -2
View File
@@ -676,8 +676,6 @@ void MessageList::loadChannel(const QString& channelId) {
QWidget* prevFocus = QApplication::focusWidget();
bool sameChannel = (m_currentChannelId == channelId);
if (!sameChannel) m_historyAnchor.clear();
m_view->setHistoricalWindow(!m_historyAnchor.isEmpty());
/* Save state of current channel before switching */
if (!m_currentChannelId.isEmpty()) {
@@ -699,6 +697,8 @@ void MessageList::loadChannel(const QString& channelId) {
}
}
if (!sameChannel) m_historyAnchor.clear();
m_view->setHistoricalWindow(!m_historyAnchor.isEmpty());
m_model->clear();
m_avatarCache.clear();
if (m_currentChannelId != channelId) { m_feedback.clear(); m_pendingPoll.clear(); }
@@ -869,6 +869,7 @@ void MessageList::refresh() {
}
void MessageList::saveChannelState() {
if (!m_historyAnchor.isEmpty()) return; // Просмотр цитаты сохраняет прежнюю позицию чтения свежей истории.
if (m_currentChannelId.isEmpty() || m_model->rowCount() == 0) return;
QScrollBar* sb = m_view->verticalScrollBar();
@@ -922,6 +923,7 @@ void MessageList::reloadLocalNicks() {
quint64 nid = v.value<quint64>();
item->setData(authorName(nid), MsgAuthorRole);
}
if (!isDmChannel(m_currentChannelId)) refreshReplies();
m_view->viewport()->update();
}
@@ -947,6 +949,7 @@ void MessageList::restoreScrollPosition(const QString& channelId) {
}
void MessageList::updateReadPosition() {
if (!m_historyAnchor.isEmpty()) return;
if (m_currentChannelId.isEmpty() || m_model->rowCount() == 0) return;
int vpHeight = m_view->viewport()->height();