mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
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
This commit is contained in:
parent
252e85fef9
commit
dfdf843f66
|
@ -154,6 +154,7 @@ extension ConversationVC:
|
||||||
_ sendMediaNavigationController: SendMediaNavigationController,
|
_ sendMediaNavigationController: SendMediaNavigationController,
|
||||||
didApproveAttachments attachments: [SignalAttachment],
|
didApproveAttachments attachments: [SignalAttachment],
|
||||||
forThreadId threadId: String,
|
forThreadId threadId: String,
|
||||||
|
threadVariant: SessionThread.Variant,
|
||||||
messageText: String?,
|
messageText: String?,
|
||||||
using dependencies: Dependencies
|
using dependencies: Dependencies
|
||||||
) {
|
) {
|
||||||
|
@ -180,7 +181,14 @@ extension ConversationVC:
|
||||||
|
|
||||||
// MARK: - AttachmentApprovalViewControllerDelegate
|
// 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)
|
sendMessage(text: (messageText ?? ""), attachments: attachments, using: dependencies)
|
||||||
resetMentions()
|
resetMentions()
|
||||||
|
|
||||||
|
@ -255,11 +263,13 @@ extension ConversationVC:
|
||||||
|
|
||||||
func handleLibraryButtonTapped() {
|
func handleLibraryButtonTapped() {
|
||||||
let threadId: String = self.viewModel.threadData.threadId
|
let threadId: String = self.viewModel.threadData.threadId
|
||||||
|
let threadVariant: SessionThread.Variant = self.viewModel.threadData.threadVariant
|
||||||
|
|
||||||
Permissions.requestLibraryPermissionIfNeeded { [weak self] in
|
Permissions.requestLibraryPermissionIfNeeded { [weak self] in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
let sendMediaNavController = SendMediaNavigationController.showingMediaLibraryFirst(
|
let sendMediaNavController = SendMediaNavigationController.showingMediaLibraryFirst(
|
||||||
threadId: threadId
|
threadId: threadId,
|
||||||
|
threadVariant: threadVariant
|
||||||
)
|
)
|
||||||
sendMediaNavController.sendMediaNavDelegate = self
|
sendMediaNavController.sendMediaNavDelegate = self
|
||||||
sendMediaNavController.modalPresentationStyle = .fullScreen
|
sendMediaNavController.modalPresentationStyle = .fullScreen
|
||||||
|
@ -277,7 +287,10 @@ extension ConversationVC:
|
||||||
SNLog("Proceeding without microphone access. Any recorded video will be silent.")
|
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.sendMediaNavDelegate = self
|
||||||
sendMediaNavController.modalPresentationStyle = .fullScreen
|
sendMediaNavController.modalPresentationStyle = .fullScreen
|
||||||
|
|
||||||
|
@ -363,6 +376,7 @@ extension ConversationVC:
|
||||||
func showAttachmentApprovalDialog(for attachments: [SignalAttachment]) {
|
func showAttachmentApprovalDialog(for attachments: [SignalAttachment]) {
|
||||||
let navController = AttachmentApprovalViewController.wrappedInNavController(
|
let navController = AttachmentApprovalViewController.wrappedInNavController(
|
||||||
threadId: self.viewModel.threadData.threadId,
|
threadId: self.viewModel.threadData.threadId,
|
||||||
|
threadVariant: self.viewModel.threadData.threadVariant,
|
||||||
attachments: attachments,
|
attachments: attachments,
|
||||||
approvalDelegate: self
|
approvalDelegate: self
|
||||||
)
|
)
|
||||||
|
@ -647,6 +661,7 @@ extension ConversationVC:
|
||||||
|
|
||||||
let approvalVC = AttachmentApprovalViewController.wrappedInNavController(
|
let approvalVC = AttachmentApprovalViewController.wrappedInNavController(
|
||||||
threadId: self.viewModel.threadData.threadId,
|
threadId: self.viewModel.threadData.threadId,
|
||||||
|
threadVariant: self.viewModel.threadData.threadVariant,
|
||||||
attachments: [ attachment ],
|
attachments: [ attachment ],
|
||||||
approvalDelegate: self
|
approvalDelegate: self
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,12 +18,14 @@ class SendMediaNavigationController: UINavigationController {
|
||||||
static let bottomButtonsCenterOffset: CGFloat = -50
|
static let bottomButtonsCenterOffset: CGFloat = -50
|
||||||
|
|
||||||
private let threadId: String
|
private let threadId: String
|
||||||
|
private let threadVariant: SessionThread.Variant
|
||||||
private var disposables: Set<AnyCancellable> = Set()
|
private var disposables: Set<AnyCancellable> = Set()
|
||||||
|
|
||||||
// MARK: - Initialization
|
// MARK: - Initialization
|
||||||
|
|
||||||
init(threadId: String) {
|
init(threadId: String, threadVariant: SessionThread.Variant) {
|
||||||
self.threadId = threadId
|
self.threadId = threadId
|
||||||
|
self.threadVariant = threadVariant
|
||||||
|
|
||||||
super.init(nibName: nil, bundle: nil)
|
super.init(nibName: nil, bundle: nil)
|
||||||
}
|
}
|
||||||
|
@ -74,17 +76,15 @@ class SendMediaNavigationController: UINavigationController {
|
||||||
|
|
||||||
public weak var sendMediaNavDelegate: SendMediaNavDelegate?
|
public weak var sendMediaNavDelegate: SendMediaNavDelegate?
|
||||||
|
|
||||||
@objc
|
public class func showingCameraFirst(threadId: String, threadVariant: SessionThread.Variant) -> SendMediaNavigationController {
|
||||||
public class func showingCameraFirst(threadId: String) -> SendMediaNavigationController {
|
let navController = SendMediaNavigationController(threadId: threadId, threadVariant: threadVariant)
|
||||||
let navController = SendMediaNavigationController(threadId: threadId)
|
|
||||||
navController.viewControllers = [navController.captureViewController]
|
navController.viewControllers = [navController.captureViewController]
|
||||||
|
|
||||||
return navController
|
return navController
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc
|
public class func showingMediaLibraryFirst(threadId: String, threadVariant: SessionThread.Variant) -> SendMediaNavigationController {
|
||||||
public class func showingMediaLibraryFirst(threadId: String) -> SendMediaNavigationController {
|
let navController = SendMediaNavigationController(threadId: threadId, threadVariant: threadVariant)
|
||||||
let navController = SendMediaNavigationController(threadId: threadId)
|
|
||||||
navController.viewControllers = [navController.mediaLibraryViewController]
|
navController.viewControllers = [navController.mediaLibraryViewController]
|
||||||
|
|
||||||
return navController
|
return navController
|
||||||
|
@ -233,6 +233,7 @@ class SendMediaNavigationController: UINavigationController {
|
||||||
let approvalViewController = AttachmentApprovalViewController(
|
let approvalViewController = AttachmentApprovalViewController(
|
||||||
mode: .sharedNavigation,
|
mode: .sharedNavigation,
|
||||||
threadId: self.threadId,
|
threadId: self.threadId,
|
||||||
|
threadVariant: self.threadVariant,
|
||||||
attachments: self.attachments
|
attachments: self.attachments
|
||||||
)
|
)
|
||||||
approvalViewController.approvalDelegate = self
|
approvalViewController.approvalDelegate = self
|
||||||
|
@ -431,8 +432,22 @@ extension SendMediaNavigationController: AttachmentApprovalViewControllerDelegat
|
||||||
attachmentDraftCollection.remove(attachment: attachment)
|
attachmentDraftCollection.remove(attachment: attachment)
|
||||||
}
|
}
|
||||||
|
|
||||||
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], forThreadId threadId: String, messageText: String?, using dependencies: Dependencies) {
|
func attachmentApproval(
|
||||||
sendMediaNavDelegate?.sendMediaNav(self, didApproveAttachments: attachments, forThreadId: threadId, messageText: messageText, using: dependencies)
|
_ 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) {
|
func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) {
|
||||||
|
@ -765,7 +780,7 @@ private class DoneButton: UIView {
|
||||||
|
|
||||||
protocol SendMediaNavDelegate: AnyObject {
|
protocol SendMediaNavDelegate: AnyObject {
|
||||||
func sendMediaNavDidCancel(_ sendMediaNavigationController: SendMediaNavigationController?)
|
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 sendMediaNavInitialMessageText(_ sendMediaNavigationController: SendMediaNavigationController) -> String?
|
||||||
func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController, didChangeMessageText newMessageText: String?)
|
func sendMediaNav(_ sendMediaNavigationController: SendMediaNavigationController, didChangeMessageText newMessageText: String?)
|
||||||
|
|
|
@ -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(
|
try MessageReceiver.handle(
|
||||||
db,
|
db,
|
||||||
threadId: (lookup.sessionId ?? lookup.blindedId),
|
threadId: (lookup.sessionId ?? lookup.blindedId),
|
||||||
threadVariant: .contact, // Technically not open group messages
|
threadVariant: .contact, // Technically not open group messages
|
||||||
message: messageInfo.message,
|
message: messageInfo.message,
|
||||||
serverExpirationTimestamp: messageInfo.serverExpirationTimestamp,
|
serverExpirationTimestamp: messageInfo.serverExpirationTimestamp,
|
||||||
associatedWithProto: try SNProtoContent.parseData(messageInfo.serializedProtoData),
|
associatedWithProto: proto,
|
||||||
using: dependencies
|
using: dependencies
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,8 +45,11 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
||||||
.replacingMentions(for: thread.id))
|
.replacingMentions(for: thread.id))
|
||||||
.defaulting(to: "APN_Message".localized())
|
.defaulting(to: "APN_Message".localized())
|
||||||
|
|
||||||
var userInfo: [String: Any] = [ NotificationServiceExtension.isFromRemoteKey: true ]
|
let userInfo: [String: Any] = [
|
||||||
userInfo[NotificationServiceExtension.threadIdKey] = thread.id
|
NotificationServiceExtension.isFromRemoteKey: true,
|
||||||
|
NotificationServiceExtension.threadIdKey: thread.id,
|
||||||
|
NotificationServiceExtension.threadVariantRaw: thread.variant.rawValue
|
||||||
|
]
|
||||||
|
|
||||||
let notificationContent = UNMutableNotificationContent()
|
let notificationContent = UNMutableNotificationContent()
|
||||||
notificationContent.userInfo = userInfo
|
notificationContent.userInfo = userInfo
|
||||||
|
@ -145,8 +148,11 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
||||||
// Only notify missed calls
|
// Only notify missed calls
|
||||||
guard messageInfo.state == .missed || messageInfo.state == .permissionDenied else { return }
|
guard messageInfo.state == .missed || messageInfo.state == .permissionDenied else { return }
|
||||||
|
|
||||||
var userInfo: [String: Any] = [ NotificationServiceExtension.isFromRemoteKey: true ]
|
let userInfo: [String: Any] = [
|
||||||
userInfo[NotificationServiceExtension.threadIdKey] = thread.id
|
NotificationServiceExtension.isFromRemoteKey: true,
|
||||||
|
NotificationServiceExtension.threadIdKey: thread.id,
|
||||||
|
NotificationServiceExtension.threadVariantRaw: thread.variant.rawValue
|
||||||
|
]
|
||||||
|
|
||||||
let notificationContent = UNMutableNotificationContent()
|
let notificationContent = UNMutableNotificationContent()
|
||||||
notificationContent.userInfo = userInfo
|
notificationContent.userInfo = userInfo
|
||||||
|
@ -206,8 +212,11 @@ public class NSENotificationPresenter: NSObject, NotificationsProtocol {
|
||||||
default: notificationBody = NotificationStrings.incomingMessageBody
|
default: notificationBody = NotificationStrings.incomingMessageBody
|
||||||
}
|
}
|
||||||
|
|
||||||
var userInfo: [String: Any] = [ NotificationServiceExtension.isFromRemoteKey: true ]
|
let userInfo: [String: Any] = [
|
||||||
userInfo[NotificationServiceExtension.threadIdKey] = thread.id
|
NotificationServiceExtension.isFromRemoteKey: true,
|
||||||
|
NotificationServiceExtension.threadIdKey: thread.id,
|
||||||
|
NotificationServiceExtension.threadVariantRaw: thread.variant.rawValue
|
||||||
|
]
|
||||||
|
|
||||||
let notificationContent = UNMutableNotificationContent()
|
let notificationContent = UNMutableNotificationContent()
|
||||||
notificationContent.userInfo = userInfo
|
notificationContent.userInfo = userInfo
|
||||||
|
|
|
@ -18,6 +18,7 @@ public final class NotificationServiceExtension: UNNotificationServiceExtension
|
||||||
|
|
||||||
public static let isFromRemoteKey = "remote"
|
public static let isFromRemoteKey = "remote"
|
||||||
public static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId"
|
public static let threadIdKey = "Signal.AppNotificationsUserInfoKey.threadId"
|
||||||
|
public static let threadVariantRaw = "Signal.AppNotificationsUserInfoKey.threadVariantRaw"
|
||||||
public static let threadNotificationCounter = "Session.AppNotificationsUserInfoKey.threadNotificationCounter"
|
public static let threadNotificationCounter = "Session.AppNotificationsUserInfoKey.threadNotificationCounter"
|
||||||
|
|
||||||
// MARK: Did receive a remote push notification request
|
// MARK: Did receive a remote push notification request
|
||||||
|
|
|
@ -36,10 +36,6 @@ final class ShareNavController: UINavigationController, ShareViewDelegate {
|
||||||
SetCurrentAppContext(appContext)
|
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("")
|
Logger.info("")
|
||||||
|
|
||||||
_ = AppVersion.sharedInstance()
|
_ = AppVersion.sharedInstance()
|
||||||
|
@ -66,6 +62,11 @@ final class ShareNavController: UINavigationController, ShareViewDelegate {
|
||||||
case .failure: SNLog("[SessionShareExtension] Failed to complete migrations")
|
case .failure: SNLog("[SessionShareExtension] Failed to complete migrations")
|
||||||
case .success:
|
case .success:
|
||||||
DispatchQueue.main.async {
|
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
|
// performUpdateCheck must be invoked after Environment has been initialized because
|
||||||
// upgrade process may depend on Environment.
|
// upgrade process may depend on Environment.
|
||||||
self?.versionMigrationsDidComplete(needsConfigSync: needsConfigSync)
|
self?.versionMigrationsDidComplete(needsConfigSync: needsConfigSync)
|
||||||
|
|
|
@ -185,6 +185,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
|
||||||
|
|
||||||
let approvalVC: UINavigationController = AttachmentApprovalViewController.wrappedInNavController(
|
let approvalVC: UINavigationController = AttachmentApprovalViewController.wrappedInNavController(
|
||||||
threadId: strongSelf.viewModel.viewData[indexPath.row].threadId,
|
threadId: strongSelf.viewModel.viewData[indexPath.row].threadId,
|
||||||
|
threadVariant: strongSelf.viewModel.viewData[indexPath.row].threadVariant,
|
||||||
attachments: attachments,
|
attachments: attachments,
|
||||||
approvalDelegate: strongSelf
|
approvalDelegate: strongSelf
|
||||||
)
|
)
|
||||||
|
@ -197,6 +198,7 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
|
||||||
_ attachmentApproval: AttachmentApprovalViewController,
|
_ attachmentApproval: AttachmentApprovalViewController,
|
||||||
didApproveAttachments attachments: [SignalAttachment],
|
didApproveAttachments attachments: [SignalAttachment],
|
||||||
forThreadId threadId: String,
|
forThreadId threadId: String,
|
||||||
|
threadVariant: SessionThread.Variant,
|
||||||
messageText: String?,
|
messageText: String?,
|
||||||
using dependencies: Dependencies = Dependencies()
|
using dependencies: Dependencies = Dependencies()
|
||||||
) {
|
) {
|
||||||
|
@ -221,8 +223,42 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
|
||||||
ModalActivityIndicatorViewController.present(fromViewController: shareNavController!, canCancel: false, message: "vc_share_sending_message".localized()) { activityIndicator in
|
ModalActivityIndicatorViewController.present(fromViewController: shareNavController!, canCancel: false, message: "vc_share_sending_message".localized()) { activityIndicator in
|
||||||
Storage.resumeDatabaseAccess()
|
Storage.resumeDatabaseAccess()
|
||||||
|
|
||||||
dependencies.storage
|
/// When we prepare the message we set the timestamp to be the `SnodeAPI.currentOffsetTimestampMs()`
|
||||||
.writePublisher { db -> MessageSender.PreparedSendData in
|
/// 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()
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
guard
|
||||||
let threadVariant: SessionThread.Variant = try SessionThread
|
let threadVariant: SessionThread.Variant = try SessionThread
|
||||||
.filter(id: threadId)
|
.filter(id: threadId)
|
||||||
|
@ -289,10 +325,9 @@ final class ThreadPickerVC: UIViewController, UITableViewDataSource, UITableView
|
||||||
using: dependencies
|
using: dependencies
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
.subscribe(on: DispatchQueue.global(qos: .userInitiated))
|
}
|
||||||
.flatMap { MessageSender.performUploadsIfNeeded(preparedSendData: $0, using: dependencies) }
|
.flatMap { MessageSender.performUploadsIfNeeded(preparedSendData: $0, using: dependencies) }
|
||||||
.flatMap { MessageSender.sendImmediate(data: $0, using: dependencies) }
|
.flatMap { MessageSender.sendImmediate(data: $0, using: dependencies) }
|
||||||
.subscribe(on: DispatchQueue.global(qos: .userInitiated))
|
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sinkUntilComplete(
|
.sinkUntilComplete(
|
||||||
receiveCompletion: { [weak self] result in
|
receiveCompletion: { [weak self] result in
|
||||||
|
|
|
@ -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
|
// 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
|
// 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
|
// 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")
|
SNLog("[GetSnodePoolJob] Has valid cached pool, running async instead")
|
||||||
SnodeAPI
|
SnodeAPI
|
||||||
.getSnodePool()
|
.getSnodePool()
|
||||||
|
|
|
@ -141,7 +141,7 @@ public final class SnodeAPI {
|
||||||
|
|
||||||
// MARK: - Public API
|
// MARK: - Public API
|
||||||
|
|
||||||
public static func hasCachedSnodesInclusingExpired() -> Bool {
|
public static func hasCachedSnodesIncludingExpired() -> Bool {
|
||||||
loadSnodePoolIfNeeded()
|
loadSnodePoolIfNeeded()
|
||||||
|
|
||||||
return !hasInsufficientSnodes
|
return !hasInsufficientSnodes
|
||||||
|
@ -1009,7 +1009,7 @@ public final class SnodeAPI {
|
||||||
|
|
||||||
// MARK: - Internal API
|
// MARK: - Internal API
|
||||||
|
|
||||||
private static func getNetworkTime(
|
public static func getNetworkTime(
|
||||||
from snode: Snode,
|
from snode: Snode,
|
||||||
using dependencies: Dependencies = Dependencies()
|
using dependencies: Dependencies = Dependencies()
|
||||||
) -> AnyPublisher<UInt64, Error> {
|
) -> AnyPublisher<UInt64, Error> {
|
||||||
|
@ -1024,7 +1024,14 @@ public final class SnodeAPI {
|
||||||
using: dependencies
|
using: dependencies
|
||||||
)
|
)
|
||||||
.decoded(as: GetNetworkTimestampResponse.self, 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()
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ public protocol AttachmentApprovalViewControllerDelegate: AnyObject {
|
||||||
_ attachmentApproval: AttachmentApprovalViewController,
|
_ attachmentApproval: AttachmentApprovalViewController,
|
||||||
didApproveAttachments attachments: [SignalAttachment],
|
didApproveAttachments attachments: [SignalAttachment],
|
||||||
forThreadId threadId: String,
|
forThreadId threadId: String,
|
||||||
|
threadVariant: SessionThread.Variant,
|
||||||
messageText: String?,
|
messageText: String?,
|
||||||
using dependencies: Dependencies
|
using dependencies: Dependencies
|
||||||
)
|
)
|
||||||
|
@ -59,6 +60,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
|
||||||
|
|
||||||
private let mode: Mode
|
private let mode: Mode
|
||||||
private let threadId: String
|
private let threadId: String
|
||||||
|
private let threadVariant: SessionThread.Variant
|
||||||
private let isAddMoreVisible: Bool
|
private let isAddMoreVisible: Bool
|
||||||
|
|
||||||
public weak var approvalDelegate: AttachmentApprovalViewControllerDelegate?
|
public weak var approvalDelegate: AttachmentApprovalViewControllerDelegate?
|
||||||
|
@ -128,11 +130,13 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
|
||||||
required public init(
|
required public init(
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
threadId: String,
|
threadId: String,
|
||||||
|
threadVariant: SessionThread.Variant,
|
||||||
attachments: [SignalAttachment]
|
attachments: [SignalAttachment]
|
||||||
) {
|
) {
|
||||||
assert(attachments.count > 0)
|
assert(attachments.count > 0)
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.threadId = threadId
|
self.threadId = threadId
|
||||||
|
self.threadVariant = threadVariant
|
||||||
let attachmentItems = attachments.map { SignalAttachmentItem(attachment: $0 )}
|
let attachmentItems = attachments.map { SignalAttachmentItem(attachment: $0 )}
|
||||||
self.isAddMoreVisible = (mode == .sharedNavigation)
|
self.isAddMoreVisible = (mode == .sharedNavigation)
|
||||||
|
|
||||||
|
@ -162,10 +166,16 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
|
||||||
|
|
||||||
public class func wrappedInNavController(
|
public class func wrappedInNavController(
|
||||||
threadId: String,
|
threadId: String,
|
||||||
|
threadVariant: SessionThread.Variant,
|
||||||
attachments: [SignalAttachment],
|
attachments: [SignalAttachment],
|
||||||
approvalDelegate: AttachmentApprovalViewControllerDelegate
|
approvalDelegate: AttachmentApprovalViewControllerDelegate
|
||||||
) -> UINavigationController {
|
) -> UINavigationController {
|
||||||
let vc = AttachmentApprovalViewController(mode: .modal, threadId: threadId, attachments: attachments)
|
let vc = AttachmentApprovalViewController(
|
||||||
|
mode: .modal,
|
||||||
|
threadId: threadId,
|
||||||
|
threadVariant: threadVariant,
|
||||||
|
attachments: attachments
|
||||||
|
)
|
||||||
vc.approvalDelegate = approvalDelegate
|
vc.approvalDelegate = approvalDelegate
|
||||||
|
|
||||||
let navController = StyledNavigationController(rootViewController: vc)
|
let navController = StyledNavigationController(rootViewController: vc)
|
||||||
|
@ -674,7 +684,14 @@ extension AttachmentApprovalViewController: AttachmentTextToolbarDelegate {
|
||||||
attachmentTextToolbar.isUserInteractionEnabled = false
|
attachmentTextToolbar.isUserInteractionEnabled = false
|
||||||
attachmentTextToolbar.isHidden = true
|
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) {
|
func attachmentTextToolbarDidChange(_ attachmentTextToolbar: AttachmentTextToolbar) {
|
||||||
|
|
Loading…
Reference in a new issue