pr suggestions
This commit is contained in:
@@ -105,14 +105,14 @@ extension UNMutableNotificationContent {
|
||||
forcePlaceholder: Bool = false) async throws -> UNMutableNotificationContent {
|
||||
var fetchedImage: INImage?
|
||||
let image: INImage
|
||||
if !forcePlaceholder, let mediaSource = icon.mediaSource {
|
||||
switch await mediaProvider?.loadThumbnailForSource(source: mediaSource, size: .init(width: 100, height: 100)) {
|
||||
if !forcePlaceholder,
|
||||
let mediaProvider,
|
||||
let mediaSource = icon.mediaSource {
|
||||
switch await mediaProvider.loadThumbnailForSource(source: mediaSource, size: .init(width: 100, height: 100)) {
|
||||
case .success(let data):
|
||||
fetchedImage = INImage(imageData: data)
|
||||
case .failure(let error):
|
||||
MXLog.error("Couldn't add sender icon: \(error)")
|
||||
case .none:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,15 @@ enum RoomAvatar: Equatable {
|
||||
case room(id: String, name: String?, avatarURL: URL?)
|
||||
/// An avatar generated from the room's heroes.
|
||||
case heroes([UserProfileProxy])
|
||||
|
||||
var removingAvatar: RoomAvatar {
|
||||
switch self {
|
||||
case let .room(id, name, _):
|
||||
return .room(id: id, name: name, avatarURL: nil)
|
||||
case let .heroes(users):
|
||||
return .heroes(users.map { .init(userID: $0.userID, displayName: $0.displayName, avatarURL: nil) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A view that shows the avatar for a room, or a cluster of heroes if provided.
|
||||
|
||||
@@ -30,7 +30,7 @@ final class UserPreference<T: Codable> {
|
||||
/// - key: The key used to store and retrieve the value.
|
||||
/// - defaultValue: The default value to use if no stored value exists or if `forceDefault` is `true`.
|
||||
/// - keyedStorage: The storage instance where the value is saved.
|
||||
/// - forceDefault: A publisher that determines whether the default value should always be used. Defaults to publish`false`. Useful in the context of MDM settings.
|
||||
/// - forceDefault: A publisher that determines whether the default value should always be used. Defaults to publish `false`. Useful in the context of remote settings.
|
||||
init(key: String,
|
||||
defaultValue: @autoclosure @escaping () -> T,
|
||||
keyedStorage: any KeyedStorage<T>,
|
||||
|
||||
@@ -18,7 +18,7 @@ struct HomeScreenInviteCell: View {
|
||||
let hideInviteAvatars: Bool
|
||||
|
||||
private var avatar: RoomAvatar {
|
||||
hideInviteAvatars ? .room(id: room.id, name: room.name, avatarURL: nil) : room.avatar
|
||||
hideInviteAvatars ? room.avatar.removingAvatar : room.avatar
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@@ -156,7 +156,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:somewhere.org", avatarURL: .mockMXCAvatar),
|
||||
HomeScreenInviteCell(room: .roomInvite(alias: "#footest-hidden-avatars:somewhere.org", avatarURL: .mockMXCAvatar),
|
||||
context: viewModel(hideInviteAvatars: true).context, hideInviteAvatars: true)
|
||||
HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org"),
|
||||
context: viewModel().context, hideInviteAvatars: false)
|
||||
|
||||
@@ -82,10 +82,11 @@ struct JoinRoomScreenViewState: BindableState {
|
||||
}
|
||||
|
||||
var avatar: RoomAvatar? {
|
||||
// DM invites avatars are broken, this is a workaround
|
||||
if isDMInvite, let inviter = roomDetails?.inviter {
|
||||
return .room(id: roomID, name: inviter.displayName, avatarURL: hideInviteAvatars ? nil : inviter.avatarURL)
|
||||
} else if let roomDetails, let avatar = roomDetails.avatar {
|
||||
return shouldHideAvatars ? .room(id: roomID, name: roomDetails.name, avatarURL: nil) : avatar
|
||||
return shouldHideAvatars ? avatar.removingAvatar : avatar
|
||||
} else if let name = roomDetails?.name {
|
||||
return .room(id: roomID, name: name, avatarURL: nil)
|
||||
} else {
|
||||
|
||||
@@ -33,10 +33,8 @@ struct RoomInfoProxy: BaseRoomInfoProxyProtocol {
|
||||
var avatarURL: URL? { roomInfo.avatarUrl.flatMap(URL.init) }
|
||||
/// The room's avatar info for use in a ``RoomAvatarImage``.
|
||||
var avatar: RoomAvatar {
|
||||
if isDirect, avatarURL == nil {
|
||||
if heroes.count == 1 {
|
||||
return .heroes(heroes.map(UserProfileProxy.init))
|
||||
}
|
||||
if isDirect, avatarURL == nil, heroes.count == 1 {
|
||||
return .heroes(heroes.map(UserProfileProxy.init))
|
||||
}
|
||||
|
||||
return .room(id: id, name: displayName, avatarURL: avatarURL)
|
||||
@@ -127,12 +125,9 @@ struct RoomPreviewInfoProxy: BaseRoomInfoProxyProtocol {
|
||||
|
||||
/// The room's avatar info for use in a ``RoomAvatarImage``.
|
||||
var avatar: RoomAvatar {
|
||||
if isDirect, avatarURL == nil {
|
||||
if heroes.count == 1 {
|
||||
return .heroes(heroes.map(UserProfileProxy.init))
|
||||
}
|
||||
if isDirect, avatarURL == nil, heroes.count == 1 {
|
||||
return .heroes(heroes.map(UserProfileProxy.init))
|
||||
}
|
||||
|
||||
return .room(id: id, name: displayName, avatarURL: avatarURL)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ extension RoomSummary {
|
||||
isFavourite = false
|
||||
}
|
||||
|
||||
// This doesn't have to work properly for DM invites, the heroes are always empty
|
||||
var avatar: RoomAvatar {
|
||||
if isDirect, avatarURL == nil, heroes.count == 1 {
|
||||
.heroes(heroes)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3d675d9e609a6c653409fd340cb93307ea2a06d1f3603d4bac8cd5f48b47db7b
|
||||
size 312144
|
||||
oid sha256:a2afcba709e9e534cdd62168d6957db70cef57703a6033c0bdc8bb1ff491e974
|
||||
size 317756
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3e55fbb94a46655b7ca88aef7dd71c88447de3383c695b5b35169c3480045a7d
|
||||
size 331760
|
||||
oid sha256:d38436f84b344252e929f15075a5219260b5454c223c77fb1f41c88322adda02
|
||||
size 337324
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4f75c56f0788459cf6e26aed0c3cab9f05265b27e5e3a751221bb0c70c6e04ab
|
||||
size 251916
|
||||
oid sha256:2994fc2ce1f3a12e0b1fd60c27f7649de7e69027d4c57f941211f6e268344fd3
|
||||
size 259148
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5c434f5efdb18dd5cb3158342736a076286583e05dc9c6348e9256573a1c03a2
|
||||
size 333485
|
||||
oid sha256:7b07fc5ed7e4355332558a45b7117b3825e3d61bf9a6cde9c38e967e0bfd78d1
|
||||
size 341431
|
||||
|
||||
Reference in New Issue
Block a user