From dfdf843f66fe40f900fed8957fc8298ec92eb481 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Mon, 21 Aug 2023 16:13:17 +1000 Subject: [PATCH] Fixed a few more issues Fixed an issue where tapping a remote notification wasn't opening the conversation Fixed an issue where the Share Extension could fail due to not having a snode pool loaded Fixed an issue where the Theme may not be applied at the right time in the Share extension --- .../ConversationVC+Interaction.swift | 21 ++- .../SendMediaNavigationController.swift | 35 ++-- .../Open Groups/OpenGroupManager.swift | 4 +- .../NSENotificationPresenter.swift | 21 ++- .../NotificationServiceExtension.swift | 1 + .../ShareNavController.swift | 9 +- SessionShareExtension/ThreadPickerVC.swift | 167 +++++++++++------- SessionSnodeKit/Jobs/GetSnodePoolJob.swift | 2 +- SessionSnodeKit/Networking/SnodeAPI.swift | 13 +- .../AttachmentApprovalViewController.swift | 21 ++- 10 files changed, 197 insertions(+), 97 deletions(-) diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 2b0def3f6..9d7c469a1 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -154,6 +154,7 @@ extension ConversationVC: _ sendMediaNavigationController: SendMediaNavigationController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, + threadVariant: SessionThread.Variant, messageText: String?, using dependencies: Dependencies ) { @@ -180,7 +181,14 @@ extension ConversationVC: // MARK: - AttachmentApprovalViewControllerDelegate - func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, messageText: String?, using dependencies: Dependencies) { + func attachmentApproval( + _ attachmentApproval: AttachmentApprovalViewController, + didApproveAttachments attachments: [SignalAttachment], + forThreadId threadId: String, + threadVariant: SessionThread.Variant, + messageText: String?, + using dependencies: Dependencies + ) { sendMessage(text: (messageText ?? ""), attachments: attachments, using: dependencies) resetMentions() @@ -255,11 +263,13 @@ extension ConversationVC: func handleLibraryButtonTapped() { let threadId: String = self.viewModel.threadData.threadId + let threadVariant: SessionThread.Variant = self.viewModel.threadData.threadVariant Permissions.requestLibraryPermissionIfNeeded { [weak self] in DispatchQueue.main.async { let sendMediaNavController = SendMediaNavigationController.showingMediaLibraryFirst( - threadId: threadId + threadId: threadId, + threadVariant: threadVariant ) sendMediaNavController.sendMediaNavDelegate = self sendMediaNavController.modalPresentationStyle = .fullScreen @@ -277,7 +287,10 @@ extension ConversationVC: SNLog("Proceeding without microphone access. Any recorded video will be silent.") } - let sendMediaNavController = SendMediaNavigationController.showingCameraFirst(threadId: self.viewModel.threadData.threadId) + let sendMediaNavController = SendMediaNavigationController.showingCameraFirst( + threadId: self.viewModel.threadData.threadId, + threadVariant: self.viewModel.threadData.threadVariant + ) sendMediaNavController.sendMediaNavDelegate = self sendMediaNavController.modalPresentationStyle = .fullScreen @@ -363,6 +376,7 @@ extension ConversationVC: func showAttachmentApprovalDialog(for attachments: [SignalAttachment]) { let navController = AttachmentApprovalViewController.wrappedInNavController( threadId: self.viewModel.threadData.threadId, + threadVariant: self.viewModel.threadData.threadVariant, attachments: attachments, approvalDelegate: self ) @@ -647,6 +661,7 @@ extension ConversationVC: let approvalVC = AttachmentApprovalViewController.wrappedInNavController( threadId: self.viewModel.threadData.threadId, + threadVariant: self.viewModel.threadData.threadVariant, attachments: [ attachment ], approvalDelegate: self ) diff --git a/Session/Media Viewing & Editing/SendMediaNavigationController.swift b/Session/Media Viewing & Editing/SendMediaNavigationController.swift index 32cf44c16..e706d08be 100644 --- a/Session/Media Viewing & Editing/SendMediaNavigationController.swift +++ b/Session/Media Viewing & Editing/SendMediaNavigationController.swift @@ -18,12 +18,14 @@ class SendMediaNavigationController: UINavigationController { static let bottomButtonsCenterOffset: CGFloat = -50 private let threadId: String + private let threadVariant: SessionThread.Variant private var disposables: Set = Set() // MARK: - Initialization - init(threadId: String) { + init(threadId: String, threadVariant: SessionThread.Variant) { self.threadId = threadId + self.threadVariant = threadVariant super.init(nibName: nil, bundle: nil) } @@ -74,17 +76,15 @@ class SendMediaNavigationController: UINavigationController { public weak var sendMediaNavDelegate: SendMediaNavDelegate? - @objc - public class func showingCameraFirst(threadId: String) -> SendMediaNavigationController { - let navController = SendMediaNavigationController(threadId: threadId) + public class func showingCameraFirst(threadId: String, threadVariant: SessionThread.Variant) -> SendMediaNavigationController { + let navController = SendMediaNavigationController(threadId: threadId, threadVariant: threadVariant) navController.viewControllers = [navController.captureViewController] return navController } - @objc - public class func showingMediaLibraryFirst(threadId: String) -> SendMediaNavigationController { - let navController = SendMediaNavigationController(threadId: threadId) + public class func showingMediaLibraryFirst(threadId: String, threadVariant: SessionThread.Variant) -> SendMediaNavigationController { + let navController = SendMediaNavigationController(threadId: threadId, threadVariant: threadVariant) navController.viewControllers = [navController.mediaLibraryViewController] return navController @@ -233,6 +233,7 @@ class SendMediaNavigationController: UINavigationController { let approvalViewController = AttachmentApprovalViewController( mode: .sharedNavigation, threadId: self.threadId, + threadVariant: self.threadVariant, attachments: self.attachments ) approvalViewController.approvalDelegate = self @@ -431,8 +432,22 @@ extension SendMediaNavigationController: AttachmentApprovalViewControllerDelegat attachmentDraftCollection.remove(attachment: attachment) } - func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, messageText: String?, using dependencies: Dependencies) { - sendMediaNavDelegate?.sendMediaNav(self, didApproveAttachments: attachments, forThreadId: threadId, messageText: messageText, using: dependencies) + func attachmentApproval( + _ attachmentApproval: AttachmentApprovalViewController, + didApproveAttachments attachments: [SignalAttachment], + forThreadId threadId: String, + threadVariant: SessionThread.Variant, + messageText: String?, + using dependencies: Dependencies + ) { + sendMediaNavDelegate?.sendMediaNav( + self, + didApproveAttachments: attachments, + forThreadId: threadId, + threadVariant: threadVariant, + messageText: messageText, + using: dependencies + ) } func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) { @@ -765,7 +780,7 @@ private class DoneButton: UIView { protocol SendMediaNavDelegate: AnyObject { func sendMediaNavDidCancel(_ sendMediaNavigationController: SendMediaNavigationController?) - func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, messageText: String?, using dependencies: Dependencies) + func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, threadVariant: SessionThread.Variant, messageText: String?, using dependencies: Dependencies) func sendMediaNavInitialMessageText(_ sendMediaNavigationController: SendMediaNavigationController) -> String? func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController, didChangeMessageText newMessageText: String?) diff --git a/SessionMessagingKit/Open Groups/OpenGroupManager.swift b/SessionMessagingKit/Open Groups/OpenGroupManager.swift index 1af88d959..b45dfcf2c 100644 --- a/SessionMessagingKit/Open Groups/OpenGroupManager.swift +++ b/SessionMessagingKit/Open Groups/OpenGroupManager.swift @@ -786,14 +786,14 @@ public final class OpenGroupManager { } } - if let messageInfo: MessageReceiveJob.Details.MessageInfo = processedMessage?.messageInfo { + if let messageInfo: MessageReceiveJob.Details.MessageInfo = processedMessage?.messageInfo, let proto: SNProtoContent = processedMessage?.proto { try MessageReceiver.handle( db, threadId: (lookup.sessionId ?? lookup.blindedId), threadVariant: .contact, // Technically not open group messages message: messageInfo.message, serverExpirationTimestamp: messageInfo.serverExpirationTimestamp, - associatedWithProto: try SNProtoContent.parseData(messageInfo.serializedProtoData), + associatedWithProto: proto, using: dependencies ) } diff --git a/SessionNotificationServiceExtension/NSENotificationPresenter.swift b/SessionNotificationServiceExtension/NSENotificationPresenter.swift index f091f4eb6..2a0d12b80 100644 --- a/SessionNotificationServiceExtension/NSENotificationPresenter.swift +++ b/SessionNotificationServiceExtension/NSENotificationPresenter.swift @@ -45,8 +45,11 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol { .replacingMentions(for: thread.id)) .defaulting(to: "APN_Message".localized()) - var userInfo: [String: Any] = [ NotificationServiceExtension.isFromRemoteKey: true ] - userInfo[NotificationServiceExtension.threadIdKey] = thread.id + let userInfo: [String: Any] = [ + NotificationServiceExtension.isFromRemoteKey: true, + NotificationServiceExtension.threadIdKey: thread.id, + NotificationServiceExtension.threadVariantRaw: thread.variant.rawValue + ] let notificationContent = UNMutableNotificationContent() notificationContent.userInfo = userInfo @@ -145,8 +148,11 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol { // Only notify missed calls guard messageInfo.state == .missed || messageInfo.state == .permissionDenied else { return } - var userInfo: [String: Any] = [ NotificationServiceExtension.isFromRemoteKey: true ] - userInfo[NotificationServiceExtension.threadIdKey] = thread.id + let userInfo: [String: Any] = [ + NotificationServiceExtension.isFromRemoteKey: true, + NotificationServiceExtension.threadIdKey: thread.id, + NotificationServiceExtension.threadVariantRaw: thread.variant.rawValue + ] let notificationContent = UNMutableNotificationContent() notificationContent.userInfo = userInfo @@ -206,8 +212,11 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol { default: notificationBody = NotificationStrings.incomingMessageBody } - var userInfo: [String: Any] = [ NotificationServiceExtension.isFromRemoteKey: true ] - userInfo[NotificationServiceExtension.threadIdKey] = thread.id + let userInfo: [String: Any] = [ + NotificationServiceExtension.isFromRemoteKey: true, + NotificationServiceExtension.threadIdKey: thread.id, + NotificationServiceExtension.threadVariantRaw: thread.variant.rawValue + ] let notificationContent = UNMutableNotificationContent() notificationContent.userInfo = userInfo diff --git a/SessionNotificationServiceExtension/NotificationServiceExtension.swift b/SessionNotificationServiceExtension/NotificationServiceExtension.swift index 22c6f4948..a80b424f5 100644 --- a/SessionNotificationServiceExtension/NotificationServiceExtension.swift +++ b/SessionNotificationServiceExtension/NotificationServiceExtension.swift @@ -18,6 +18,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension public static let isFromRemoteKey = "remote" public static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId" + public static let threadVariantRaw = "Signal.AppNotificationsUserInfoKey.threadVariantRaw" public static let threadNotificationCounter = "Session.AppNotificationsUserInfoKey.threadNotificationCounter" // MARK: Did receive a remote push notification request diff --git a/SessionShareExtension/ShareNavController.swift b/SessionShareExtension/ShareNavController.swift index 22c0ce612..1789ab470 100644 --- a/SessionShareExtension/ShareNavController.swift +++ b/SessionShareExtension/ShareNavController.swift @@ -36,10 +36,6 @@ final class ShareNavController: UINavigationController, ShareViewDelegate { SetCurrentAppContext(appContext) } - // Need to manually trigger these since we don't have a "mainWindow" here and the current theme - // might have been changed since the share extension was last opened - ThemeManager.applySavedTheme() - Logger.info("") _ = AppVersion.sharedInstance() @@ -66,6 +62,11 @@ final class ShareNavController: UINavigationController, ShareViewDelegate { case .failure: SNLog("[SessionShareExtension] Failed to complete migrations") case .success: DispatchQueue.main.async { + // Need to manually trigger these since we don't have a "mainWindow" here + // and the current theme might have been changed since the share extension + // was last opened + ThemeManager.applySavedTheme() + // performUpdateCheck must be invoked after Environment has been initialized because // upgrade process may depend on Environment. self?.versionMigrationsDidComplete(needsConfigSync: needsConfigSync) diff --git a/SessionShareExtension/ThreadPickerVC.swift b/SessionShareExtension/ThreadPickerVC.swift index afc92180a..ced7e707c 100644 --- a/SessionShareExtension/ThreadPickerVC.swift +++ b/SessionShareExtension/ThreadPickerVC.swift @@ -185,6 +185,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView let approvalVC: UINavigationController = AttachmentApprovalViewController.wrappedInNavController( threadId: strongSelf.viewModel.viewData[indexPath.row].threadId, + threadVariant: strongSelf.viewModel.viewData[indexPath.row].threadVariant, attachments: attachments, approvalDelegate: strongSelf ) @@ -197,6 +198,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView _ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, + threadVariant: SessionThread.Variant, messageText: String?, using dependencies: Dependencies = Dependencies() ) { @@ -221,78 +223,111 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView ModalActivityIndicatorViewController.present(fromViewController: shareNavController!, canCancel: false, message: "vc_share_sending_message".localized()) { activityIndicator in Storage.resumeDatabaseAccess() - dependencies.storage - .writePublisher { db -> MessageSender.PreparedSendData in - guard - let threadVariant: SessionThread.Variant = try SessionThread - .filter(id: threadId) - .select(.variant) - .asRequest(of: SessionThread.Variant.self) - .fetchOne(db) - else { throw MessageSenderError.noThread } - - // Create the interaction - let interaction: Interaction = try Interaction( - threadId: threadId, - authorId: getUserHexEncodedPublicKey(db), - variant: .standardOutgoing, - body: body, - timestampMs: SnodeAPI.currentOffsetTimestampMs(), - hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: body), - expiresInSeconds: try? DisappearingMessagesConfiguration - .select(.durationSeconds) - .filter(id: threadId) - .filter(DisappearingMessagesConfiguration.Columns.isEnabled == true) - .asRequest(of: TimeInterval.self) - .fetchOne(db), - linkPreviewUrl: (isSharingUrl ? attachments.first?.linkPreviewDraft?.urlString : nil) - ).inserted(db) - - guard let interactionId: Int64 = interaction.id else { - throw StorageError.failedToSave + /// When we prepare the message we set the timestamp to be the `SnodeAPI.currentOffsetTimestampMs()` + /// but won't actually have a value because the share extension won't have talked to a service node yet which can cause + /// issues with Disappearing Messages, as a result we need to explicitly `getNetworkTime` in order to ensure it's accurate + Just(()) + .setFailureType(to: Error.self) + .flatMap { _ in + // We may not have sufficient snodes, so rather than failing we try to load/fetch + // them if needed + guard !SnodeAPI.hasCachedSnodesIncludingExpired() else { + return Just(()) + .setFailureType(to: Error.self) + .eraseToAnyPublisher() } - // If the user is sharing a Url, there is a LinkPreview and it doesn't match an existing - // one then add it now - if - isSharingUrl, - let linkPreviewDraft: LinkPreviewDraft = attachments.first?.linkPreviewDraft, - (try? interaction.linkPreview.isEmpty(db)) == true - { - try LinkPreview( - url: linkPreviewDraft.urlString, - title: linkPreviewDraft.title, - attachmentId: LinkPreview - .generateAttachmentIfPossible( - imageData: linkPreviewDraft.jpegImageData, - mimeType: OWSMimeTypeImageJpeg - )? - .inserted(db) - .id - ).insert(db) - } - - // Prepare any attachments - try Attachment.process( - db, - data: Attachment.prepare(attachments: finalAttachments), - for: interactionId - ) - - // Prepare the message send data - return try MessageSender - .preparedSendData( - db, - interaction: interaction, - threadId: threadId, - threadVariant: threadVariant, - using: dependencies - ) + return SnodeAPI.getSnodePool() + .map { _ in () } + .eraseToAnyPublisher() } .subscribe(on: DispatchQueue.global(qos: .userInitiated)) + .flatMap { _ in + SnodeAPI + .getSwarm( + for: { + switch threadVariant { + case .contact, .legacyGroup, .group: return threadId + case .community: return getUserHexEncodedPublicKey(using: dependencies) + } + }(), + using: dependencies + ) + .tryFlatMapWithRandomSnode { SnodeAPI.getNetworkTime(from: $0, using: dependencies) } + .map { _ in () } + .eraseToAnyPublisher() + } + .flatMap { _ in + dependencies.storage.writePublisher { db -> MessageSender.PreparedSendData in + guard + let threadVariant: SessionThread.Variant = try SessionThread + .filter(id: threadId) + .select(.variant) + .asRequest(of: SessionThread.Variant.self) + .fetchOne(db) + else { throw MessageSenderError.noThread } + + // Create the interaction + let interaction: Interaction = try Interaction( + threadId: threadId, + authorId: getUserHexEncodedPublicKey(db), + variant: .standardOutgoing, + body: body, + timestampMs: SnodeAPI.currentOffsetTimestampMs(), + hasMention: Interaction.isUserMentioned(db, threadId: threadId, body: body), + expiresInSeconds: try? DisappearingMessagesConfiguration + .select(.durationSeconds) + .filter(id: threadId) + .filter(DisappearingMessagesConfiguration.Columns.isEnabled == true) + .asRequest(of: TimeInterval.self) + .fetchOne(db), + linkPreviewUrl: (isSharingUrl ? attachments.first?.linkPreviewDraft?.urlString : nil) + ).inserted(db) + + guard let interactionId: Int64 = interaction.id else { + throw StorageError.failedToSave + } + + // If the user is sharing a Url, there is a LinkPreview and it doesn't match an existing + // one then add it now + if + isSharingUrl, + let linkPreviewDraft: LinkPreviewDraft = attachments.first?.linkPreviewDraft, + (try? interaction.linkPreview.isEmpty(db)) == true + { + try LinkPreview( + url: linkPreviewDraft.urlString, + title: linkPreviewDraft.title, + attachmentId: LinkPreview + .generateAttachmentIfPossible( + imageData: linkPreviewDraft.jpegImageData, + mimeType: OWSMimeTypeImageJpeg + )? + .inserted(db) + .id + ).insert(db) + } + + // Prepare any attachments + try Attachment.process( + db, + data: Attachment.prepare(attachments: finalAttachments), + for: interactionId + ) + + // Prepare the message send data + return try MessageSender + .preparedSendData( + db, + interaction: interaction, + threadId: threadId, + threadVariant: threadVariant, + using: dependencies + ) + } + } .flatMap { MessageSender.performUploadsIfNeeded(preparedSendData: $0, using: dependencies) } .flatMap { MessageSender.sendImmediate(data: $0, using: dependencies) } - .subscribe(on: DispatchQueue.global(qos: .userInitiated)) .receive(on: DispatchQueue.main) .sinkUntilComplete( receiveCompletion: { [weak self] result in diff --git a/SessionSnodeKit/Jobs/GetSnodePoolJob.swift b/SessionSnodeKit/Jobs/GetSnodePoolJob.swift index 22cdad93d..72844ff82 100644 --- a/SessionSnodeKit/Jobs/GetSnodePoolJob.swift +++ b/SessionSnodeKit/Jobs/GetSnodePoolJob.swift @@ -23,7 +23,7 @@ public enum GetSnodePoolJob: JobExecutor { // but we want to succeed this job immediately (since it's marked as blocking), this allows us // to block if we have no Snode pool and prevent other jobs from failing but avoids having to // wait if we already have a potentially valid snode pool - guard !SnodeAPI.hasCachedSnodesInclusingExpired() else { + guard !SnodeAPI.hasCachedSnodesIncludingExpired() else { SNLog("[GetSnodePoolJob] Has valid cached pool, running async instead") SnodeAPI .getSnodePool() diff --git a/SessionSnodeKit/Networking/SnodeAPI.swift b/SessionSnodeKit/Networking/SnodeAPI.swift index 159d13fad..a2e9af6a8 100644 --- a/SessionSnodeKit/Networking/SnodeAPI.swift +++ b/SessionSnodeKit/Networking/SnodeAPI.swift @@ -141,7 +141,7 @@ public final class SnodeAPI { // MARK: - Public API - public static func hasCachedSnodesInclusingExpired() -> Bool { + public static func hasCachedSnodesIncludingExpired() -> Bool { loadSnodePoolIfNeeded() return !hasInsufficientSnodes @@ -1009,7 +1009,7 @@ public final class SnodeAPI { // MARK: - Internal API - private static func getNetworkTime( + public static func getNetworkTime( from snode: Snode, using dependencies: Dependencies = Dependencies() ) -> AnyPublisher { @@ -1024,7 +1024,14 @@ public final class SnodeAPI { using: dependencies ) .decoded(as: GetNetworkTimestampResponse.self, using: dependencies) - .map { _, response in response.timestamp } + .map { _, response in + // Assume we've fetched the networkTime in order to send a message to the specified snode, in + // which case we want to update the 'clockOffsetMs' value for subsequent requests + let offset = (Int64(response.timestamp) - Int64(floor(dependencies.dateNow.timeIntervalSince1970 * 1000))) + SnodeAPI.clockOffsetMs.mutate { $0 = offset } + + return response.timestamp + } .eraseToAnyPublisher() } diff --git a/SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentApprovalViewController.swift b/SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentApprovalViewController.swift index a6b1a8782..77b13ab15 100644 --- a/SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentApprovalViewController.swift +++ b/SignalUtilitiesKit/Media Viewing & Editing/Attachment Approval/AttachmentApprovalViewController.swift @@ -16,6 +16,7 @@ public protocol AttachmentApprovalViewControllerDelegate: AnyObject { _ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, + threadVariant: SessionThread.Variant, messageText: String?, using dependencies: Dependencies ) @@ -59,6 +60,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC private let mode: Mode private let threadId: String + private let threadVariant: SessionThread.Variant private let isAddMoreVisible: Bool public weak var approvalDelegate: AttachmentApprovalViewControllerDelegate? @@ -128,11 +130,13 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC required public init( mode: Mode, threadId: String, + threadVariant: SessionThread.Variant, attachments: [SignalAttachment] ) { assert(attachments.count > 0) self.mode = mode self.threadId = threadId + self.threadVariant = threadVariant let attachmentItems = attachments.map { SignalAttachmentItem(attachment: $0 )} self.isAddMoreVisible = (mode == .sharedNavigation) @@ -162,10 +166,16 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC public class func wrappedInNavController( threadId: String, + threadVariant: SessionThread.Variant, attachments: [SignalAttachment], approvalDelegate: AttachmentApprovalViewControllerDelegate ) -> UINavigationController { - let vc = AttachmentApprovalViewController(mode: .modal, threadId: threadId, attachments: attachments) + let vc = AttachmentApprovalViewController( + mode: .modal, + threadId: threadId, + threadVariant: threadVariant, + attachments: attachments + ) vc.approvalDelegate = approvalDelegate let navController = StyledNavigationController(rootViewController: vc) @@ -674,7 +684,14 @@ extension AttachmentApprovalViewController: AttachmentTextToolbarDelegate { attachmentTextToolbar.isUserInteractionEnabled = false attachmentTextToolbar.isHidden = true - approvalDelegate?.attachmentApproval(self, didApproveAttachments: attachments, forThreadId: threadId, messageText: attachmentTextToolbar.messageText, using: dependencies) + approvalDelegate?.attachmentApproval( + self, + didApproveAttachments: attachments, + forThreadId: threadId, + threadVariant: threadVariant, + messageText: attachmentTextToolbar.messageText, + using: dependencies + ) } func attachmentTextToolbarDidChange(_ attachmentTextToolbar: AttachmentTextToolbar) {