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

@@ -27,7 +27,8 @@ QQC2.Menu {
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.localUser.avatarUrl.toString().length > 0 ? root.connection.makeMediaUrl(root.connection.localUser.avatarUrl) : ""
});
if (typeof root.closeDialog === "function") {
root.closeDialog();

View File

@@ -125,7 +125,7 @@ Kirigami.Dialog {
width: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
height: Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing
}
source: userDelegate.connection.localUser.avatarMediaId ? userDelegate.connection.makeMediaUrl("mxc://" + userDelegate.connection.localUser.avatarMediaId) : ""
source: userDelegate.connection.localUser.avatarUrl.toString().length > 0 ? userDelegate.connection.makeMediaUrl(userDelegate.connection.localUser.avatarUrl) : ""
name: userDelegate.connection.localUser.displayName ?? userDelegate.connection.localUser.id
}

View File

@@ -12,7 +12,7 @@ Components.AbstractMaximizeComponent {
required property string text
property color avatarColor
required property string avatarSource
required property url avatarSource
onOpened: forceActiveFocus()

View File

@@ -37,14 +37,15 @@ RowLayout {
}
KirigamiComponents.AvatarButton {
id: accountButton
readonly property string mediaId: root.connection.localUser.avatarMediaId
readonly property url avatarUrl: root.connection.localUser.avatarUrl
Layout.preferredWidth: Kirigami.Units.iconSizes.medium
Layout.preferredHeight: Kirigami.Units.iconSizes.medium
Layout.leftMargin: Kirigami.Units.largeSpacing
text: i18n("Edit this account")
source: mediaId ? root.connection.makeMediaUrl("mxc://" + mediaId) : ""
// Note: User::avatarUrl does not set user_id, and thus cannot be used directly here. Hence the makeMediaUrl.
source: avatarUrl.toString().length > 0 ? root.connection.makeMediaUrl(avatarUrl) : ""
name: root.connection.localUser.displayName
activeFocusOnTab: true