Remove more needless usages of makeMediaUrl

This is only really needed in specific cases, e.g. localUser which isn't
attached to a connection and thus needs a little help. Notes for when
this is needed is added for future readers.

(cherry picked from commit ef953b7574)
This commit is contained in:
Joshua Goins
2024-11-16 12:29:35 -05:00
parent ae12c838bd
commit d5c3054da4
9 changed files with 18 additions and 12 deletions

View File

@@ -34,7 +34,8 @@ FormCard.FormCardPage {
padding: 0
source: root.connection && root.connection.localUser.avatarMediaId ? root.connection.makeMediaUrl("mxc://" + root.connection.localUser.avatarMediaId) : ""
// Note: User::avatarUrl does not set user_id, and thus cannot be used directly here. Hence the makeMediaUrl.
source: root.connection && (root.connection.localUser.avatarUrl.toString().length > 0 ? root.connection.makeMediaUrl(root.connection.localUser.avatarUrl) : "")
name: root.connection.localUser.displayName
onClicked: {
@@ -122,7 +123,8 @@ FormCard.FormCardPage {
text: "https://matrix.to/#/" + root.connection.localUser.id,
title: root.connection.localUser.displayName,
subtitle: root.connection.localUser.id,
avatarSource: root.connection.makeMediaUrl(root.connection.localUser.avatarUrl)
// Note: User::avatarUrl does not set user_id, and thus cannot be used directly here. Hence the makeMediaUrl.
avatarSource: root.connection && (root.connection.localUser.avatarUrl.toString().length > 0 ? root.connection.makeMediaUrl(root.connection.localUser.avatarUrl) : "")
});
if (typeof root.closeDialog === "function") {
root.closeDialog();

View File

@@ -53,7 +53,8 @@ FormCard.FormCardPage {
contentItem: RowLayout {
KirigamiComponents.Avatar {
name: accountDelegate.connection.localUser.displayName
source: accountDelegate.connection.localUser.avatarMediaId ? accountDelegate.connection.makeMediaUrl("mxc://" + accountDelegate.connection.localUser.avatarMediaId) : ""
// Note: User::avatarUrl does not set user_id, and thus cannot be used directly here. Hence the makeMediaUrl.
source: accountDelegate.connection.localUser.avatarUrl.toString().length > 0 ? accountDelegate.connection.makeMediaUrl(accountDelegate.connection.localUser.avatarUrl) : ""
Layout.rightMargin: Kirigami.Units.largeSpacing
implicitWidth: Kirigami.Units.iconSizes.medium

View File

@@ -169,7 +169,7 @@ FormCard.FormCardPage {
id: userListItem
required property string userId
required property string avatar
required property url avatar
required property string name
required property int powerLevel
required property string powerLevelString
@@ -180,7 +180,7 @@ FormCard.FormCardPage {
KirigamiComponents.Avatar {
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
source: userListItem.avatar ? root.room.connection.makeMediaUrl(userListItem.avatar) : ""
source: userListItem.avatar
name: userListItem.name
}