tombstoned and upgraded rooms implementation

added tests

tombstoned room avatar
This commit is contained in:
Mauro Romito
2025-06-03 12:52:31 +02:00
committed by Mauro
parent b628f5d2c2
commit 155b47e849
76 changed files with 438 additions and 171 deletions
@@ -13,13 +13,17 @@ enum RoomAvatar: Equatable {
case room(id: String, name: String?, avatarURL: URL?)
/// An avatar generated from the room's heroes.
case heroes([UserProfileProxy])
/// A static avatar for a tombstoned room.
case tombstoned
var removingAvatar: RoomAvatar {
switch self {
case let .room(id, name, _):
return .room(id: id, name: name, avatarURL: nil)
.room(id: id, name: name, avatarURL: nil)
case let .heroes(users):
return .heroes(users.map { .init(userID: $0.userID, displayName: $0.displayName, avatarURL: nil) })
.heroes(users.map { .init(userID: $0.userID, displayName: $0.displayName, avatarURL: nil) })
case .tombstoned:
.tombstoned
}
}
}
@@ -91,6 +95,12 @@ struct RoomAvatarImage: View {
mediaProvider: mediaProvider,
onTap: onAvatarTap)
}
case .tombstoned:
LoadableAvatarImage(url: nil,
name: "!",
contentID: nil, avatarSize: avatarSize,
mediaProvider: mediaProvider,
onTap: onAvatarTap)
}
}
}
@@ -126,6 +136,8 @@ struct RoomAvatarImage_Previews: PreviewProvider, TestablePreview {
.init(userID: "@bob:server.net", displayName: "Bob", avatarURL: nil)]),
avatarSize: .room(on: .home),
mediaProvider: MediaProviderMock(configuration: .init()))
RoomAvatarImage(avatar: .tombstoned, avatarSize: .room(on: .home), mediaProvider: MediaProviderMock(configuration: .init()))
}
}
}