Skip to content

Commit

Permalink
Fixes #2291 - Wrong notification placeholder avatar orientation on 17…
Browse files Browse the repository at this point in the history
….2.1
  • Loading branch information
stefanceriu committed Jan 8, 2024
1 parent d338fd0 commit 6c9efaf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ElementX/Sources/Other/Extensions/UNNotificationContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ extension UNMutableNotificationContent {
private func getPlaceholderAvatarImageData(name: String, id: String) async -> Data? {
// The version value is used in case the design of the placeholder is updated to force a replacement
let shouldFlipAvatar = shouldFlipAvatar()
let prefix = "notification_placeholder\(shouldFlipAvatar ? "V5" : "V4")"
let prefix = "notification_placeholder\(shouldFlipAvatar ? "V7" : "V6")"
let fileName = "\(prefix)_\(name)_\(id).png"
if let data = try? Data(contentsOf: URL.temporaryDirectory.appendingPathComponent(fileName)) {
MXLog.info("Found existing notification icon placeholder")
Expand Down Expand Up @@ -224,7 +224,8 @@ extension UNMutableNotificationContent {
}

/// On simulators and macOS the image is rendered correctly
/// On devices before iOS 17 and after iOS 17.2 it's rendered upside down and needs to be flipped
/// On devices before iOS 17 and iOS 17.2.0 it's rendered upside down and needs to be flipped
/// On all other versions it's rendered correctly and **doesn't** need to be flipped
private func shouldFlipAvatar() -> Bool {
#if targetEnvironment(simulator)
return false
Expand All @@ -237,11 +238,15 @@ extension UNMutableNotificationContent {
return false
}

if version >= Version(17, 0, 0), version < Version(17, 2, 0) {
return false
if version < Version(17, 0, 0) {
return true
}

if version == Version(17, 2, 0) {
return true
}

return true
return false
#endif
}
}
Expand Down
1 change: 1 addition & 0 deletions changelog.d/2291.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix wrong notification placeholder avatar orientation on 17.2.1

0 comments on commit 6c9efaf

Please sign in to comment.