From 46f63572e90dbf460faab9ce694181209712bd00 Mon Sep 17 00:00:00 2001 From: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> Date: Wed, 13 Dec 2023 17:03:47 +0400 Subject: [PATCH] fix pasteboardHasURLs, disable paste button based on it --- apps/ios/Shared/AppDelegate.swift | 2 +- apps/ios/Shared/Model/ChatModel.swift | 2 +- apps/ios/Shared/Views/ChatList/ChatListView.swift | 1 - apps/ios/Shared/Views/NewChat/NewChatView.swift | 1 + 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/ios/Shared/AppDelegate.swift b/apps/ios/Shared/AppDelegate.swift index 7287a4386..ad0f93c56 100644 --- a/apps/ios/Shared/AppDelegate.swift +++ b/apps/ios/Shared/AppDelegate.swift @@ -38,7 +38,7 @@ class AppDelegate: NSObject, UIApplicationDelegate { } @objc func pasteboardChanged() { - ChatModel.shared.pasteboardHasURLs = UIPasteboard.general.hasStrings + ChatModel.shared.pasteboardHasURLs = UIPasteboard.general.hasURLs } func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { diff --git a/apps/ios/Shared/Model/ChatModel.swift b/apps/ios/Shared/Model/ChatModel.swift index ba2b3bd28..64760b3ef 100644 --- a/apps/ios/Shared/Model/ChatModel.swift +++ b/apps/ios/Shared/Model/ChatModel.swift @@ -95,7 +95,7 @@ final class ChatModel: ObservableObject { @Published var draftChatId: String? // tracks keyboard height via subscription in AppDelegate @Published var keyboardHeight: CGFloat = 0 - @Published var pasteboardHasURLs: Bool = UIPasteboard.general.hasStrings + @Published var pasteboardHasURLs: Bool = UIPasteboard.general.hasURLs var messageDelivery: Dictionary Void> = [:] diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 34cc441df..ebdd76dc9 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -279,7 +279,6 @@ struct ChatListSearchBar: View { @Binding var searchShowingSimplexLink: Bool @Binding var searchChatFilteredBySimplexLink: String? @State private var ignoreSearchTextChange = false - @State private var pasteboardHasString = false @State private var showScanCodeSheet = false @State private var alert: PlanAndConnectAlert? @State private var sheet: PlanAndConnectActionSheet? diff --git a/apps/ios/Shared/Views/NewChat/NewChatView.swift b/apps/ios/Shared/Views/NewChat/NewChatView.swift index ab72a2510..1f16ec050 100644 --- a/apps/ios/Shared/Views/NewChat/NewChatView.swift +++ b/apps/ios/Shared/Views/NewChat/NewChatView.swift @@ -344,6 +344,7 @@ private struct ConnectView: View { } label: { Text("Tap to paste link") } + .disabled(!ChatModel.shared.pasteboardHasURLs) .frame(maxWidth: .infinity, alignment: .center) } else { linkTextView(pastedLink)