Fix avatar loading in multiple places and prefers name instead of

display name for avatar fallback.

This also fixes a bug where users didn't get their avatar loaded in the
room list.

Fix #209
This commit is contained in:
Carl Schwan
2021-01-09 00:37:13 +01:00
parent de23eef519
commit 4be3eac7af
11 changed files with 15 additions and 9 deletions

View File

@@ -256,6 +256,9 @@ QVariant RoomListModel::data(const QModelIndex &index, int role) const
}
NeoChatRoom *room = m_rooms.at(index.row());
if (role == NameRole) {
return !room->name().isEmpty() ? room->name() : room->displayName();
}
if (role == DisplayNameRole) {
return room->displayName();
}
if (role == AvatarRole) {
@@ -324,6 +327,7 @@ QHash<int, QByteArray> RoomListModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[NameRole] = "name";
roles[DisplayNameRole] = "displayName";
roles[AvatarRole] = "avatar";
roles[TopicRole] = "topic";
roles[CategoryRole] = "category";