From b7289e72a3295499ee98aaf5d0c89e8b55df9b5f Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Wed, 25 Aug 2021 12:18:06 +1000 Subject: [PATCH] add accessibility to attachment buttons --- .../ExpandingAttachmentsButton.swift | 32 ++++++++++++++++--- .../Translations/de.lproj/Localizable.strings | 6 ++++ .../Translations/en.lproj/Localizable.strings | 6 ++++ .../Translations/es.lproj/Localizable.strings | 6 ++++ .../Translations/fa.lproj/Localizable.strings | 6 ++++ .../Translations/fi.lproj/Localizable.strings | 6 ++++ .../Translations/fr.lproj/Localizable.strings | 6 ++++ .../Translations/hi.lproj/Localizable.strings | 6 ++++ .../Translations/hr.lproj/Localizable.strings | 6 ++++ .../id-ID.lproj/Localizable.strings | 6 ++++ .../Translations/it.lproj/Localizable.strings | 6 ++++ .../Translations/ja.lproj/Localizable.strings | 6 ++++ .../Translations/nl.lproj/Localizable.strings | 6 ++++ .../Translations/pl.lproj/Localizable.strings | 6 ++++ .../pt_BR.lproj/Localizable.strings | 6 ++++ .../Translations/ru.lproj/Localizable.strings | 6 ++++ .../Translations/sk.lproj/Localizable.strings | 6 ++++ .../Translations/sv.lproj/Localizable.strings | 6 ++++ .../Translations/th.lproj/Localizable.strings | 6 ++++ .../vi-VN.lproj/Localizable.strings | 6 ++++ .../zh-Hant.lproj/Localizable.strings | 6 ++++ .../zh_CN.lproj/Localizable.strings | 6 ++++ .../Jobs/AttachmentDownloadJob.swift | 10 ++++++ .../NotificationServiceExtension.swift | 2 +- 24 files changed, 164 insertions(+), 6 deletions(-) diff --git a/Session/Conversations/Input View/ExpandingAttachmentsButton.swift b/Session/Conversations/Input View/ExpandingAttachmentsButton.swift index a42f4488e..8652d57c6 100644 --- a/Session/Conversations/Input View/ExpandingAttachmentsButton.swift +++ b/Session/Conversations/Input View/ExpandingAttachmentsButton.swift @@ -10,15 +10,35 @@ final class ExpandingAttachmentsButton : UIView, InputViewButtonDelegate { private lazy var cameraButtonContainerBottomConstraint = cameraButtonContainer.pin(.bottom, to: .bottom, of: self) // MARK: UI Components - lazy var gifButton = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_gif_black"), delegate: self, hasOpaqueBackground: true) + lazy var gifButton: InputViewButton = { + let result = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_gif_black"), delegate: self, hasOpaqueBackground: true) + result.accessibilityLabel = NSLocalizedString("accessibility_gif_button", comment: "") + return result + }() lazy var gifButtonContainer = container(for: gifButton) - lazy var documentButton = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_document_black"), delegate: self, hasOpaqueBackground: true) + lazy var documentButton: InputViewButton = { + let result = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_document_black"), delegate: self, hasOpaqueBackground: true) + result.accessibilityLabel = NSLocalizedString("accessibility_document_button", comment: "") + return result + }() lazy var documentButtonContainer = container(for: documentButton) - lazy var libraryButton = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_camera_roll_black"), delegate: self, hasOpaqueBackground: true) + lazy var libraryButton: InputViewButton = { + let result = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_camera_roll_black"), delegate: self, hasOpaqueBackground: true) + result.accessibilityLabel = NSLocalizedString("accessibility_library_button", comment: "") + return result + }() lazy var libraryButtonContainer = container(for: libraryButton) - lazy var cameraButton = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_camera_black"), delegate: self, hasOpaqueBackground: true) + lazy var cameraButton: InputViewButton = { + let result = InputViewButton(icon: #imageLiteral(resourceName: "actionsheet_camera_black"), delegate: self, hasOpaqueBackground: true) + result.accessibilityLabel = NSLocalizedString("accessibility_camera_button", comment: "") + return result + }() lazy var cameraButtonContainer = container(for: cameraButton) - lazy var mainButton = InputViewButton(icon: #imageLiteral(resourceName: "ic_plus_24"), delegate: self) + lazy var mainButton: InputViewButton = { + let result = InputViewButton(icon: #imageLiteral(resourceName: "ic_plus_24"), delegate: self) + result.accessibilityLabel = NSLocalizedString("accessibility_expanding_attachments_button", comment: "") + return result + }() lazy var mainButtonContainer = container(for: mainButton) // MARK: Lifecycle @@ -66,6 +86,7 @@ final class ExpandingAttachmentsButton : UIView, InputViewButtonDelegate { // MARK: Animation private func expandOrCollapse() { if isExpanded { + mainButton.accessibilityLabel = NSLocalizedString("accessibility_main_button_collapse", comment: "") let expandedButtonSize = InputViewButton.expandedSize let spacing: CGFloat = 4 cameraButtonContainerBottomConstraint.constant = -1 * (expandedButtonSize + spacing) @@ -79,6 +100,7 @@ final class ExpandingAttachmentsButton : UIView, InputViewButtonDelegate { self.layoutIfNeeded() } } else { + mainButton.accessibilityLabel = NSLocalizedString("accessibility_expanding_attachments_button", comment: "") [ gifButtonContainerBottomConstraint, documentButtonContainerBottomConstraint, libraryButtonContainerBottomConstraint, cameraButtonContainerBottomConstraint ].forEach { $0.constant = 0 } diff --git a/Session/Meta/Translations/de.lproj/Localizable.strings b/Session/Meta/Translations/de.lproj/Localizable.strings index 5ca82d5a0..3db0bf36c 100644 --- a/Session/Meta/Translations/de.lproj/Localizable.strings +++ b/Session/Meta/Translations/de.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/en.lproj/Localizable.strings b/Session/Meta/Translations/en.lproj/Localizable.strings index 430e5c044..7de331a6d 100644 --- a/Session/Meta/Translations/en.lproj/Localizable.strings +++ b/Session/Meta/Translations/en.lproj/Localizable.strings @@ -557,4 +557,10 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/es.lproj/Localizable.strings b/Session/Meta/Translations/es.lproj/Localizable.strings index 4f3111a6b..34dce14f6 100644 --- a/Session/Meta/Translations/es.lproj/Localizable.strings +++ b/Session/Meta/Translations/es.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/fa.lproj/Localizable.strings b/Session/Meta/Translations/fa.lproj/Localizable.strings index 1021d569f..8cb43a537 100644 --- a/Session/Meta/Translations/fa.lproj/Localizable.strings +++ b/Session/Meta/Translations/fa.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/fi.lproj/Localizable.strings b/Session/Meta/Translations/fi.lproj/Localizable.strings index ef67453b8..c68cc6d28 100644 --- a/Session/Meta/Translations/fi.lproj/Localizable.strings +++ b/Session/Meta/Translations/fi.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/fr.lproj/Localizable.strings b/Session/Meta/Translations/fr.lproj/Localizable.strings index f97d407c7..d91844903 100644 --- a/Session/Meta/Translations/fr.lproj/Localizable.strings +++ b/Session/Meta/Translations/fr.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/hi.lproj/Localizable.strings b/Session/Meta/Translations/hi.lproj/Localizable.strings index 204731d63..f750e97f4 100644 --- a/Session/Meta/Translations/hi.lproj/Localizable.strings +++ b/Session/Meta/Translations/hi.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/hr.lproj/Localizable.strings b/Session/Meta/Translations/hr.lproj/Localizable.strings index 860a546a3..9d32a4823 100644 --- a/Session/Meta/Translations/hr.lproj/Localizable.strings +++ b/Session/Meta/Translations/hr.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/id-ID.lproj/Localizable.strings b/Session/Meta/Translations/id-ID.lproj/Localizable.strings index af4f39234..b3ec9fb89 100644 --- a/Session/Meta/Translations/id-ID.lproj/Localizable.strings +++ b/Session/Meta/Translations/id-ID.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/it.lproj/Localizable.strings b/Session/Meta/Translations/it.lproj/Localizable.strings index f8018c99c..c2301da20 100644 --- a/Session/Meta/Translations/it.lproj/Localizable.strings +++ b/Session/Meta/Translations/it.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/ja.lproj/Localizable.strings b/Session/Meta/Translations/ja.lproj/Localizable.strings index b43619cd7..4c6af761a 100644 --- a/Session/Meta/Translations/ja.lproj/Localizable.strings +++ b/Session/Meta/Translations/ja.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/nl.lproj/Localizable.strings b/Session/Meta/Translations/nl.lproj/Localizable.strings index df6a8d106..61311680a 100644 --- a/Session/Meta/Translations/nl.lproj/Localizable.strings +++ b/Session/Meta/Translations/nl.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/pl.lproj/Localizable.strings b/Session/Meta/Translations/pl.lproj/Localizable.strings index 204ba918b..487c99a88 100644 --- a/Session/Meta/Translations/pl.lproj/Localizable.strings +++ b/Session/Meta/Translations/pl.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings index 583e81ff9..7248083fa 100644 --- a/Session/Meta/Translations/pt_BR.lproj/Localizable.strings +++ b/Session/Meta/Translations/pt_BR.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/ru.lproj/Localizable.strings b/Session/Meta/Translations/ru.lproj/Localizable.strings index b851e2a59..d5fcd1c2d 100644 --- a/Session/Meta/Translations/ru.lproj/Localizable.strings +++ b/Session/Meta/Translations/ru.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/sk.lproj/Localizable.strings b/Session/Meta/Translations/sk.lproj/Localizable.strings index 129b79ad4..ec5306e3e 100644 --- a/Session/Meta/Translations/sk.lproj/Localizable.strings +++ b/Session/Meta/Translations/sk.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/sv.lproj/Localizable.strings b/Session/Meta/Translations/sv.lproj/Localizable.strings index dd4b04329..311db3616 100644 --- a/Session/Meta/Translations/sv.lproj/Localizable.strings +++ b/Session/Meta/Translations/sv.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/th.lproj/Localizable.strings b/Session/Meta/Translations/th.lproj/Localizable.strings index 30f4a0ae2..c10829003 100644 --- a/Session/Meta/Translations/th.lproj/Localizable.strings +++ b/Session/Meta/Translations/th.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings index 2ee0add3b..665f93fd8 100644 --- a/Session/Meta/Translations/vi-VN.lproj/Localizable.strings +++ b/Session/Meta/Translations/vi-VN.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings index 117376ddb..1f25b7e6d 100644 --- a/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh-Hant.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings index aab0afae7..e11098fae 100644 --- a/Session/Meta/Translations/zh_CN.lproj/Localizable.strings +++ b/Session/Meta/Translations/zh_CN.lproj/Localizable.strings @@ -557,3 +557,9 @@ "context_menu_save" = "Save"; "context_menu_ban_user" = "Ban User"; "context_menu_ban_and_delete_all" = "Ban and Delete All"; +"accessibility_expanding_attachments_button" = "Add attachments"; +"accessibility_gif_button" = "Gif"; +"accessibility_document_button" = "Document"; +"accessibility_library_button" = "Photo library"; +"accessibility_camera_button" = "Camera"; +"accessibility_main_button_collapse" = "Collapse attachment options"; diff --git a/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift b/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift index f7a281b20..1ddb1b65c 100644 --- a/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift +++ b/SessionMessagingKit/Jobs/AttachmentDownloadJob.swift @@ -60,6 +60,10 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject // MARK: Running public func execute() { + execute(completion: nil) + } + + public func execute(completion: (() -> Void)?) { if let id = id { JobQueue.currentlyExecutingJobs.insert(id) } @@ -67,9 +71,11 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject if TSAttachment.fetch(uniqueId: attachmentID) is TSAttachmentStream { // FIXME: It's not clear * how * this happens, but apparently we can get to this point // from time to time with an already downloaded attachment. + completion?() return handleSuccess() } guard let pointer = TSAttachment.fetch(uniqueId: attachmentID) as? TSAttachmentPointer else { + completion?() return handleFailure(error: Error.noAttachment) } let storage = SNMessagingKitConfiguration.shared.storage @@ -92,8 +98,10 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject storage.setAttachmentState(to: .failed, for: pointer, associatedWith: self.tsMessageID, using: transaction) }, completion: { }) // This usually indicates a file that has expired on the server, so there's no need to retry. + completion?() self.handlePermanentFailure(error: error) } else { + completion?() self.handleFailure(error: error) } } @@ -103,6 +111,7 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject } OpenGroupAPIV2.download(file, from: v2OpenGroup.room, on: v2OpenGroup.server).done(on: DispatchQueue.global(qos: .userInitiated)) { data in self.handleDownloadedAttachment(data: data, temporaryFilePath: temporaryFilePath, pointer: pointer, failureHandler: handleFailure) + completion?() }.catch(on: DispatchQueue.global()) { error in handleFailure(error) } @@ -113,6 +122,7 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject let useOldServer = pointer.downloadURL.contains(FileServerAPIV2.oldServer) FileServerAPIV2.download(file, useOldServer: useOldServer).done(on: DispatchQueue.global(qos: .userInitiated)) { data in self.handleDownloadedAttachment(data: data, temporaryFilePath: temporaryFilePath, pointer: pointer, failureHandler: handleFailure) + completion?() }.catch(on: DispatchQueue.global()) { error in handleFailure(error) } diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index bc40de1f7..3b1818124 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -48,7 +48,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension case let visibleMessage as VisibleMessage: let tsIncomingMessageID = try MessageReceiver.handleVisibleMessage(visibleMessage, associatedWithProto: proto, openGroupID: nil, isBackgroundPoll: false, using: transaction) guard let tsIncomingMessage = TSIncomingMessage.fetch(uniqueId: tsIncomingMessageID, transaction: transaction) else { - return self.handleFailure(for: notificationContent) + return self.completeSilenty() } let thread = tsIncomingMessage.thread(with: transaction) if thread.isMuted {