From 42ad7fe75969656d9e9cb04efd6f6efa6557e4b8 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Thu, 4 Jan 2024 15:36:46 +0200 Subject: [PATCH] Fixes #2291 - Wrong notification placeholder avatar orientation on 17.2.1 --- .../Other/Extensions/UNNotificationContent.swift | 15 ++++++++++----- changelog.d/2291.bugfix | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changelog.d/2291.bugfix diff --git a/ElementX/Sources/Other/Extensions/UNNotificationContent.swift b/ElementX/Sources/Other/Extensions/UNNotificationContent.swift index a723de96d9..4424eb4d3f 100644 --- a/ElementX/Sources/Other/Extensions/UNNotificationContent.swift +++ b/ElementX/Sources/Other/Extensions/UNNotificationContent.swift @@ -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") @@ -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 @@ -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 } } diff --git a/changelog.d/2291.bugfix b/changelog.d/2291.bugfix new file mode 100644 index 0000000000..da0377628c --- /dev/null +++ b/changelog.d/2291.bugfix @@ -0,0 +1 @@ +Fix wrong notification placeholder avatar orientation on 17.2.1 \ No newline at end of file