chatgui: local nicknames per channel member — edit via MemberPropsDialog, override display everywhere
This commit is contained in:
1 parent
373a2e4687
commit
85bdc00aaf
9 files changed
+87
-16
No files matched your search
@@ -207,11 +207,13 @@ void MessageList::loadChannel(const QString& channelId) {
|
||||
m_readDebounce->stop();
|
||||
if (!m_db || !m_db->isOpen()) return;
|
||||
|
||||
m_localNicks = m_db->getLocalNicknames(channelId);
|
||||
|
||||
auto msgs = m_db->getMessages(channelId, 100);
|
||||
|
||||
for (const auto& m : msgs) {
|
||||
AccountRow acc = m_db->getAccount(m.authorNodeId);
|
||||
QString author = m_db->getDisplayName(m.authorNodeId);
|
||||
QString author = authorName(m.authorNodeId);
|
||||
QString letter = acc.avatarLetter.isEmpty() ? author.mid(0, 1) : acc.avatarLetter;
|
||||
QColor color(acc.avatarColor);
|
||||
|
||||
@@ -271,12 +273,14 @@ void MessageList::refresh() {
|
||||
auto newMsgs = m_db->getMessagesSince(m_currentChannelId, maxId);
|
||||
if (newMsgs.isEmpty()) return;
|
||||
|
||||
m_localNicks = m_db->getLocalNicknames(m_currentChannelId);
|
||||
|
||||
QScrollBar* sb = m_view->verticalScrollBar();
|
||||
bool wasAtBottom = sb && (sb->value() >= sb->maximum());
|
||||
|
||||
for (const auto& m : newMsgs) {
|
||||
AccountRow acc = m_db->getAccount(m.authorNodeId);
|
||||
QString author = m_db->getDisplayName(m.authorNodeId);
|
||||
QString author = authorName(m.authorNodeId);
|
||||
QString letter = acc.avatarLetter.isEmpty() ? author.mid(0, 1) : acc.avatarLetter;
|
||||
QColor color(acc.avatarColor);
|
||||
if (!m_avatarCache.contains(m.authorNodeId))
|
||||
@@ -302,7 +306,7 @@ void MessageList::addMessage(const QString& channelId, quint64 authorNodeId,
|
||||
if (channelId != m_currentChannelId) return;
|
||||
|
||||
AccountRow acc = m_db ? m_db->getAccount(authorNodeId) : AccountRow();
|
||||
QString author = m_db ? m_db->getDisplayName(authorNodeId) : QString("node_%1").arg(authorNodeId);
|
||||
QString author = m_db ? authorName(authorNodeId) : QString("node_%1").arg(authorNodeId);
|
||||
QString letter = acc.avatarLetter.isEmpty() ? author.mid(0, 1) : acc.avatarLetter;
|
||||
QColor color(acc.avatarColor);
|
||||
auto avatar = makeAvatar(color, letter);
|
||||
@@ -356,6 +360,12 @@ void MessageList::saveChannelState() {
|
||||
if (lastPosMsgId > 0) saveKey("_last_pos", lastPosMsgId);
|
||||
}
|
||||
|
||||
QString MessageList::authorName(quint64 nodeId) const {
|
||||
auto it = m_localNicks.find(nodeId);
|
||||
if (it != m_localNicks.end() && !it->isEmpty()) return *it;
|
||||
return m_db->getDisplayName(nodeId);
|
||||
}
|
||||
|
||||
void MessageList::restoreScrollPosition(const QString& channelId) {
|
||||
if (!m_db || m_model->rowCount() == 0) {
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user