diff --git a/SessionShareExtension/ShareVC.swift b/SessionShareExtension/ShareVC.swift index ce226e0af..f3f7900e7 100644 --- a/SessionShareExtension/ShareVC.swift +++ b/SessionShareExtension/ShareVC.swift @@ -201,8 +201,16 @@ final class ShareVC : UINavigationController, ShareViewDelegate, AppModeManagerD private func showMainContent() { let threadPickerVC = ThreadPickerVC() + threadPickerVC.shareVC = self setViewControllers([ threadPickerVC ], animated: false) - ShareVC.attachmentPrepPromise = buildAttachments() + showLoader() + let promise = buildAttachments() + promise.done { [weak self] _ in + self?.hideLoader() + }.catch { [weak self] _ in + self?.hideLoader() + } + ShareVC.attachmentPrepPromise = promise } func shareViewWasUnlocked() { @@ -210,15 +218,23 @@ final class ShareVC : UINavigationController, ShareViewDelegate, AppModeManagerD } func shareViewWasCompleted() { - print("completed") + extensionContext!.completeRequest(returningItems: [], completionHandler: nil) } func shareViewWasCancelled() { - print("canceled") + extensionContext!.completeRequest(returningItems: [], completionHandler: nil) } func shareViewFailed(error: Error) { - print("failed") + extensionContext!.cancelRequest(withError: error) + } + + func showLoader() { + + } + + func hideLoader() { + } // MARK: Attachment Prep diff --git a/SessionShareExtension/SimplifiedConversationCell.swift b/SessionShareExtension/SimplifiedConversationCell.swift index 8b45d3fc2..b03404392 100644 --- a/SessionShareExtension/SimplifiedConversationCell.swift +++ b/SessionShareExtension/SimplifiedConversationCell.swift @@ -50,7 +50,7 @@ final class SimplifiedConversationCell : UITableViewCell { profilePictureView.set(.height, to: profilePictureViewSize) profilePictureView.size = profilePictureViewSize // Main stack view - let stackView = UIStackView(arrangedSubviews: [ accentLineView, profilePictureView, displayNameLabel ]) + let stackView = UIStackView(arrangedSubviews: [ accentLineView, profilePictureView, displayNameLabel, UIView.hSpacer(0) ]) stackView.axis = .horizontal stackView.alignment = .center stackView.spacing = Values.mediumSpacing diff --git a/SessionShareExtension/ThreadPickerVC.swift b/SessionShareExtension/ThreadPickerVC.swift index 2f68d1736..384243322 100644 --- a/SessionShareExtension/ThreadPickerVC.swift +++ b/SessionShareExtension/ThreadPickerVC.swift @@ -4,6 +4,7 @@ final class ThreadPickerVC : UIViewController, UITableViewDataSource, UITableVie private var threads: YapDatabaseViewMappings! private var threadViewModelCache: [String:ThreadViewModel] = [:] // Thread ID to ThreadViewModel private var selectedThread: TSThread? + var shareVC: ShareVC? private var threadCount: UInt { threads.numberOfItems(inGroup: TSInboxGroup) @@ -99,6 +100,7 @@ final class ThreadPickerVC : UIViewController, UITableViewDataSource, UITableVie } func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], messageText: String?) { + shareVC?.showLoader() let message = VisibleMessage() message.sentTimestamp = NSDate.millisecondTimestamp() message.text = messageText @@ -107,16 +109,24 @@ final class ThreadPickerVC : UIViewController, UITableViewDataSource, UITableVie tsMessage.save(with: transaction) } Storage.write { transaction in - MessageSender.sendNonDurably(message, with: attachments, in: self.selectedThread!, using: transaction).retainUntilComplete() + MessageSender.sendNonDurably(message, with: attachments, in: self.selectedThread!, using: transaction).done { [weak self] _ in + guard let self = self else { return } + self.shareVC?.hideLoader() + self.shareVC?.shareViewWasCompleted() + }.catch { [weak self] error in + guard let self = self else { return } + self.shareVC?.hideLoader() + self.shareVC?.shareViewFailed(error: error) + } } } func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) { - + // Do nothing } func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didChangeMessageText newMessageText: String?) { - + // Do nothing } // MARK: Convenience