Skip to content
Snippets Groups Projects
Commit b709cccb authored by Mauro Romito's avatar Mauro Romito Committed by Mauro
Browse files

fix: DM invites now correctly render the avatar

parent a142ce43
No related branches found
No related tags found
No related merge requests found
Showing
with 33 additions and 26 deletions
......@@ -18,7 +18,13 @@ struct HomeScreenInviteCell: View {
let hideInviteAvatars: Bool
private var avatar: RoomAvatar {
hideInviteAvatars ? room.avatar.removingAvatar : room.avatar
// DM invites avatars are broken, this is a workaround
// https://github.com/matrix-org/matrix-rust-sdk/issues/4825
if room.isDirect, let inviter = room.inviter {
.heroes([.init(userID: inviter.id, displayName: inviter.displayName, avatarURL: hideInviteAvatars ? nil : inviter.avatarURL)])
} else {
hideInviteAvatars ? room.avatar.removingAvatar : room.avatar
}
}
var body: some View {
......@@ -77,7 +83,7 @@ struct HomeScreenInviteCell: View {
if let inviter = room.inviter,
!room.isDirect {
RoomInviterLabel(inviter: inviter,
shouldHideAvatar: context.viewState.hideInviteAvatars,
shouldHideAvatar: hideInviteAvatars,
mediaProvider: context.mediaProvider)
.font(.compound.bodyMD)
.foregroundStyle(.compound.textSecondary)
......@@ -157,7 +163,7 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org", avatarURL: .mockMXCAvatar),
context: viewModel().context, hideInviteAvatars: false)
HomeScreenInviteCell(room: .roomInvite(alias: "#footest-hidden-avatars:somewhere.org", avatarURL: .mockMXCAvatar),
context: viewModel(hideInviteAvatars: true).context, hideInviteAvatars: true)
context: viewModel().context, hideInviteAvatars: true)
HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org"),
context: viewModel().context, hideInviteAvatars: false)
.dynamicTypeSize(.accessibility1)
......@@ -166,7 +172,7 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
.previewLayout(.sizeThatFits)
}
static func viewModel(hideInviteAvatars: Bool = false) -> HomeScreenViewModel {
static func viewModel() -> HomeScreenViewModel {
let clientProxy = ClientProxyMock(.init())
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
......@@ -183,8 +189,8 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
private extension HomeScreenRoom {
static var dmInvite: HomeScreenRoom {
let inviter = RoomMemberProxyMock()
inviter.displayName = "Jack"
inviter.userID = "@jack:somewhere.com"
inviter.displayName = "Some Guy"
inviter.userID = "@someone:somewhere.com"
let summary = RoomSummary(roomListItem: RoomListItemSDKMock(),
id: "@someone:somewhere.com",
......
......@@ -83,14 +83,15 @@ struct JoinRoomScreenViewState: BindableState {
var avatar: RoomAvatar? {
// DM invites avatars are broken, this is a workaround
// https://github.com/matrix-org/matrix-rust-sdk/issues/4825
if isDMInvite, let inviter = roomDetails?.inviter {
return .room(id: roomID, name: inviter.displayName, avatarURL: hideInviteAvatars ? nil : inviter.avatarURL)
.heroes([.init(userID: inviter.id, displayName: inviter.displayName, avatarURL: hideInviteAvatars ? nil : inviter.avatarURL)])
} else if let roomDetails, let avatar = roomDetails.avatar {
return shouldHideAvatars ? avatar.removingAvatar : avatar
shouldHideAvatars ? avatar.removingAvatar : avatar
} else if let name = roomDetails?.name {
return .room(id: roomID, name: name, avatarURL: nil)
.room(id: roomID, name: name, avatarURL: nil)
} else {
return nil
nil
}
}
......
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-en-GB-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-en-GB-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-en-GB-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-en-GB-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-en-GB-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-en-GB-0.png
  • 2-up
  • Swipe
  • Onion skin
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-pseudo-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-pseudo-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-pseudo-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-pseudo-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-pseudo-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPad-pseudo-0.png
  • 2-up
  • Swipe
  • Onion skin
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-en-GB-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-en-GB-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-en-GB-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-en-GB-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-en-GB-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-en-GB-0.png
  • 2-up
  • Swipe
  • Onion skin
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-pseudo-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-pseudo-0.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-pseudo-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-pseudo-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-pseudo-0.png
PreviewTests/Sources/__Snapshots__/PreviewTests/homeScreenInviteCell.iPhone-16-pseudo-0.png
  • 2-up
  • Swipe
  • Onion skin
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-en-GB.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-en-GB.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-en-GB.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-en-GB.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-en-GB.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-en-GB.png
  • 2-up
  • Swipe
  • Onion skin
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-pseudo.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-pseudo.png

131 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-pseudo.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-pseudo.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-pseudo.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPad-pseudo.png
  • 2-up
  • Swipe
  • Onion skin
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-en-GB.png

130 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-en-GB.png

130 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-en-GB.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-en-GB.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-en-GB.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-en-GB.png
  • 2-up
  • Swipe
  • Onion skin
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-pseudo.png

130 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-pseudo.png

130 B | W: | H:

PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-pseudo.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-pseudo.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-pseudo.png
PreviewTests/Sources/__Snapshots__/PreviewTests/joinRoomScreen.InvitedDM-iPhone-16-pseudo.png
  • 2-up
  • Swipe
  • Onion skin
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment