chatgui: remember last read message, restore scroll position, show unread count badge

Store read/scroll positions per channel via ui_state table (key-value).
Draw red +N badge on channel list items for unread messages.
Fix getMessages() to fetch last N messages (was fetching first N).
This commit is contained in:
Evgeny committed 2026-07-23 23:47:35 +03:00
1 parent de14f82048
commit 86d227bffe
10 files changed
+158 -12

No files matched your search

+10 -2
View File
@@ -212,6 +212,7 @@ void MainWindow::setupConnects() {
this, [this](const QString& channelId) {
QSettings().setValue("last_channel_id", channelId);
m_currentChannelId = channelId;
m_channelList->setChannelUnreadCount(channelId, 0);
m_messageList->loadChannel(channelId);
m_accountList->setChannel(channelId);
QByteArray cidBA = channelId.toUtf8();
@@ -322,8 +323,15 @@ void MainWindow::showSettings() {
void MainWindow::onMessageReceived(const char* ch_id) {
DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "MainWindow: msg received ch=%s", ch_id);
SoundManager::instance()->play("msg_incoming");
if (m_messageList)
m_messageList->refresh();
QString cid = QString::fromUtf8(ch_id);
if (m_messageList) {
if (cid == m_currentChannelId) {
m_messageList->refresh();
} else if (m_channelList) {
int unread = m_channelList->getChannelUnreadCount(cid) + 1;
m_channelList->setChannelUnreadCount(cid, unread);
}
}
}
void MainWindow::onMembersChanged(const char* ch_id) {