Don't read avatarUrl from local profile, if no global avatar is set

This commit is contained in:
Nicolas Werner 2021-06-12 16:05:45 +02:00
parent 7d5e82c888
commit e6878ee298
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 12 additions and 11 deletions

View file

@ -447,6 +447,8 @@ Page {
RowLayout { RowLayout {
id: userInfoGrid id: userInfoGrid
property var profile: Nheko.currentUser
spacing: Nheko.paddingMedium spacing: Nheko.paddingMedium
anchors.fill: parent anchors.fill: parent
anchors.margins: Nheko.paddingMedium anchors.margins: Nheko.paddingMedium
@ -457,9 +459,9 @@ Page {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.preferredWidth: fontMetrics.lineSpacing * 2 Layout.preferredWidth: fontMetrics.lineSpacing * 2
Layout.preferredHeight: fontMetrics.lineSpacing * 2 Layout.preferredHeight: fontMetrics.lineSpacing * 2
url: Nheko.currentUser.avatarUrl.replace("mxc://", "image://MxcImage/") url: (userInfoGrid.profile ? userInfoGrid.profile.avatarUrl : "").replace("mxc://", "image://MxcImage/")
displayName: Nheko.currentUser.displayName displayName: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
userid: Nheko.currentUser.userid userid: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
} }
ColumnLayout { ColumnLayout {
@ -476,7 +478,7 @@ Page {
Layout.alignment: Qt.AlignBottom Layout.alignment: Qt.AlignBottom
font.pointSize: fontMetrics.font.pointSize * 1.1 font.pointSize: fontMetrics.font.pointSize * 1.1
font.weight: Font.DemiBold font.weight: Font.DemiBold
fullText: Nheko.currentUser.displayName fullText: userInfoGrid.profile ? userInfoGrid.profile.displayName : ""
elideWidth: col.width elideWidth: col.width
} }
@ -486,7 +488,7 @@ Page {
font.weight: Font.Thin font.weight: Font.Thin
font.pointSize: fontMetrics.font.pointSize * 0.9 font.pointSize: fontMetrics.font.pointSize * 0.9
elideWidth: col.width elideWidth: col.width
fullText: Nheko.currentUser.userid fullText: userInfoGrid.profile ? userInfoGrid.profile.userid : ""
} }
} }

View file

@ -2479,7 +2479,8 @@ Cache::getMember(const std::string &room_id, const std::string &user_id)
return m; return m;
} }
} catch (std::exception &e) { } catch (std::exception &e) {
nhlog::db()->warn("Failed to read member ({}): {}", user_id, e.what()); nhlog::db()->warn(
"Failed to read member ({}) in room ({}): {}", user_id, room_id, e.what());
} }
return std::nullopt; return std::nullopt;
} }

View file

@ -39,7 +39,8 @@ UserProfile::UserProfile(QString roomid,
getGlobalProfileData(); getGlobalProfileData();
} }
if (!cache::client() || !cache::client()->isDatabaseReady()) if (!cache::client() || !cache::client()->isDatabaseReady() ||
!ChatPage::instance()->timelineManager())
return; return;
connect(cache::client(), connect(cache::client(),
@ -127,10 +128,7 @@ UserProfile::displayName()
QString QString
UserProfile::avatarUrl() UserProfile::avatarUrl()
{ {
return (isGlobalUserProfile() && globalAvatarUrl != "") return isGlobalUserProfile() ? globalAvatarUrl : cache::avatarUrl(roomid_, userid_);
? globalAvatarUrl
: cache::avatarUrl(roomid_, userid_);
;
} }
bool bool