Reuse shared channel avatars in direct message conversations

This commit is contained in:
evgeny committed 2026-10-06 12:40:07 +02:00
1 parent b8ddf0f52d
commit 405755f06a
2 files changed
+12 -2

No files matched your search

+6 -2
View File
@@ -339,8 +339,8 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
auto *layout = new QVBoxLayout(this);
if (auto* manager = AvatarManager::instance()) connect(manager, &AvatarManager::changed, this,
[this, manager](const QString& channel, quint64 owner) {
if (channel != m_currentChannelId) return;
const QImage image = manager->image(channel, owner);
if (channel != m_currentChannelId && !isDmChannel(m_currentChannelId)) return;
const QImage image = manager->image(m_currentChannelId, owner);
for (int row = 0; row < m_model->rowCount(); row++) {
auto* item = m_model->item(row);
if (item->data(MsgAuthorNodeIdRole).toULongLong() != owner) continue;
@@ -1205,6 +1205,10 @@ void MessageList::onDmMessages(const uint8_t* data, int len) {
if (!m_avatarCache.contains(author))
m_avatarCache[author] = color;
auto avatar = makeAvatar(color, letter);
if (auto* manager = AvatarManager::instance()) {
const QImage image = manager->image(m_currentChannelId, author);
if (!image.isNull()) avatar = QPixmap::fromImage(image);
}
auto time = QDateTime::fromMSecsSinceEpoch((qint64)ts).toString("HH:mm");
if (!file && !status.isEmpty()) time += QStringLiteral(" · ") + status;