diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index 57fc80da..d6f5de2f 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -288,9 +288,11 @@ void MessageList::saveChannelState() { int vpHeight = m_view->viewport()->height(); QModelIndex topIdx = m_view->indexAt(QPoint(0, 0)); + QScrollBar* sb = m_view->verticalScrollBar(); + bool atBottom = sb && (sb->value() >= sb->maximum()); qint64 lastPosMsgId = 0; - if (topIdx.isValid()) + if (!atBottom && topIdx.isValid()) lastPosMsgId = topIdx.data(MsgIdRole).toLongLong(); qint64 lastReadMsgId = m_lastReadMsgId; @@ -353,7 +355,9 @@ void MessageList::updateReadPosition() { } QModelIndex topIdx = m_view->indexAt(QPoint(0, 0)); - qint64 lastPosMsgId = topIdx.isValid() ? topIdx.data(MsgIdRole).toLongLong() : 0; + QScrollBar* sb = m_view->verticalScrollBar(); + bool atBottom = sb && (sb->value() >= sb->maximum()); + qint64 lastPosMsgId = (!atBottom && topIdx.isValid()) ? topIdx.data(MsgIdRole).toLongLong() : 0; DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "MessageList::updateReadPosition ch=%s oldRead=%lld newRead=%lld pos=%lld lastVisRow=%d/%d",