mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
add accessibility to attachment buttons
This commit is contained in:
parent
d60475be99
commit
b7289e72a3
24 changed files with 164 additions and 6 deletions
|
@ -10,15 +10,35 @@ final class ExpandingAttachmentsButton : UIView, InputViewButtonDelegate {
|
||||||
private lazy var cameraButtonContainerBottomConstraint = cameraButtonContainer.pin(.bottom, to: .bottom, of: self)
|
private lazy var cameraButtonContainerBottomConstraint = cameraButtonContainer.pin(.bottom, to: .bottom, of: self)
|
||||||
|
|
||||||
// MARK: UI Components
|
// 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 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 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 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 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)
|
lazy var mainButtonContainer = container(for: mainButton)
|
||||||
|
|
||||||
// MARK: Lifecycle
|
// MARK: Lifecycle
|
||||||
|
@ -66,6 +86,7 @@ final class ExpandingAttachmentsButton : UIView, InputViewButtonDelegate {
|
||||||
// MARK: Animation
|
// MARK: Animation
|
||||||
private func expandOrCollapse() {
|
private func expandOrCollapse() {
|
||||||
if isExpanded {
|
if isExpanded {
|
||||||
|
mainButton.accessibilityLabel = NSLocalizedString("accessibility_main_button_collapse", comment: "")
|
||||||
let expandedButtonSize = InputViewButton.expandedSize
|
let expandedButtonSize = InputViewButton.expandedSize
|
||||||
let spacing: CGFloat = 4
|
let spacing: CGFloat = 4
|
||||||
cameraButtonContainerBottomConstraint.constant = -1 * (expandedButtonSize + spacing)
|
cameraButtonContainerBottomConstraint.constant = -1 * (expandedButtonSize + spacing)
|
||||||
|
@ -79,6 +100,7 @@ final class ExpandingAttachmentsButton : UIView, InputViewButtonDelegate {
|
||||||
self.layoutIfNeeded()
|
self.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
mainButton.accessibilityLabel = NSLocalizedString("accessibility_expanding_attachments_button", comment: "")
|
||||||
[ gifButtonContainerBottomConstraint, documentButtonContainerBottomConstraint, libraryButtonContainerBottomConstraint, cameraButtonContainerBottomConstraint ].forEach {
|
[ gifButtonContainerBottomConstraint, documentButtonContainerBottomConstraint, libraryButtonContainerBottomConstraint, cameraButtonContainerBottomConstraint ].forEach {
|
||||||
$0.constant = 0
|
$0.constant = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,4 +557,10 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -557,3 +557,9 @@
|
||||||
"context_menu_save" = "Save";
|
"context_menu_save" = "Save";
|
||||||
"context_menu_ban_user" = "Ban User";
|
"context_menu_ban_user" = "Ban User";
|
||||||
"context_menu_ban_and_delete_all" = "Ban and Delete All";
|
"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";
|
||||||
|
|
|
@ -60,6 +60,10 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
|
||||||
|
|
||||||
// MARK: Running
|
// MARK: Running
|
||||||
public func execute() {
|
public func execute() {
|
||||||
|
execute(completion: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func execute(completion: (() -> Void)?) {
|
||||||
if let id = id {
|
if let id = id {
|
||||||
JobQueue.currentlyExecutingJobs.insert(id)
|
JobQueue.currentlyExecutingJobs.insert(id)
|
||||||
}
|
}
|
||||||
|
@ -67,9 +71,11 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
|
||||||
if TSAttachment.fetch(uniqueId: attachmentID) is TSAttachmentStream {
|
if TSAttachment.fetch(uniqueId: attachmentID) is TSAttachmentStream {
|
||||||
// FIXME: It's not clear * how * this happens, but apparently we can get to this point
|
// 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.
|
// from time to time with an already downloaded attachment.
|
||||||
|
completion?()
|
||||||
return handleSuccess()
|
return handleSuccess()
|
||||||
}
|
}
|
||||||
guard let pointer = TSAttachment.fetch(uniqueId: attachmentID) as? TSAttachmentPointer else {
|
guard let pointer = TSAttachment.fetch(uniqueId: attachmentID) as? TSAttachmentPointer else {
|
||||||
|
completion?()
|
||||||
return handleFailure(error: Error.noAttachment)
|
return handleFailure(error: Error.noAttachment)
|
||||||
}
|
}
|
||||||
let storage = SNMessagingKitConfiguration.shared.storage
|
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)
|
storage.setAttachmentState(to: .failed, for: pointer, associatedWith: self.tsMessageID, using: transaction)
|
||||||
}, completion: { })
|
}, completion: { })
|
||||||
// This usually indicates a file that has expired on the server, so there's no need to retry.
|
// This usually indicates a file that has expired on the server, so there's no need to retry.
|
||||||
|
completion?()
|
||||||
self.handlePermanentFailure(error: error)
|
self.handlePermanentFailure(error: error)
|
||||||
} else {
|
} else {
|
||||||
|
completion?()
|
||||||
self.handleFailure(error: error)
|
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
|
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)
|
self.handleDownloadedAttachment(data: data, temporaryFilePath: temporaryFilePath, pointer: pointer, failureHandler: handleFailure)
|
||||||
|
completion?()
|
||||||
}.catch(on: DispatchQueue.global()) { error in
|
}.catch(on: DispatchQueue.global()) { error in
|
||||||
handleFailure(error)
|
handleFailure(error)
|
||||||
}
|
}
|
||||||
|
@ -113,6 +122,7 @@ public final class AttachmentDownloadJob : NSObject, Job, NSCoding { // NSObject
|
||||||
let useOldServer = pointer.downloadURL.contains(FileServerAPIV2.oldServer)
|
let useOldServer = pointer.downloadURL.contains(FileServerAPIV2.oldServer)
|
||||||
FileServerAPIV2.download(file, useOldServer: useOldServer).done(on: DispatchQueue.global(qos: .userInitiated)) { data in
|
FileServerAPIV2.download(file, useOldServer: useOldServer).done(on: DispatchQueue.global(qos: .userInitiated)) { data in
|
||||||
self.handleDownloadedAttachment(data: data, temporaryFilePath: temporaryFilePath, pointer: pointer, failureHandler: handleFailure)
|
self.handleDownloadedAttachment(data: data, temporaryFilePath: temporaryFilePath, pointer: pointer, failureHandler: handleFailure)
|
||||||
|
completion?()
|
||||||
}.catch(on: DispatchQueue.global()) { error in
|
}.catch(on: DispatchQueue.global()) { error in
|
||||||
handleFailure(error)
|
handleFailure(error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
|
||||||
case let visibleMessage as VisibleMessage:
|
case let visibleMessage as VisibleMessage:
|
||||||
let tsIncomingMessageID = try MessageReceiver.handleVisibleMessage(visibleMessage, associatedWithProto: proto, openGroupID: nil, isBackgroundPoll: false, using: transaction)
|
let tsIncomingMessageID = try MessageReceiver.handleVisibleMessage(visibleMessage, associatedWithProto: proto, openGroupID: nil, isBackgroundPoll: false, using: transaction)
|
||||||
guard let tsIncomingMessage = TSIncomingMessage.fetch(uniqueId: tsIncomingMessageID, transaction: transaction) else {
|
guard let tsIncomingMessage = TSIncomingMessage.fetch(uniqueId: tsIncomingMessageID, transaction: transaction) else {
|
||||||
return self.handleFailure(for: notificationContent)
|
return self.completeSilenty()
|
||||||
}
|
}
|
||||||
let thread = tsIncomingMessage.thread(with: transaction)
|
let thread = tsIncomingMessage.thread(with: transaction)
|
||||||
if thread.isMuted {
|
if thread.isMuted {
|
||||||
|
|
Loading…
Reference in a new issue