pr suggestions

This commit is contained in:
Mauro Romito
2025-03-20 19:33:17 +01:00
committed by Mauro
parent 9e0e5bbb13
commit 8e439bc8f5
11 changed files with 31 additions and 25 deletions
@@ -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.
+1 -1
View File
@@ -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>,