fix pasteboardHasURLs, disable paste button based on it

This commit is contained in:
spaced4ndy 2023-12-13 17:03:47 +04:00
parent c7da9053ac
commit 46f63572e9
4 changed files with 3 additions and 3 deletions

View File

@ -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) {

View File

@ -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<Int64, () -> Void> = [:]

View File

@ -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?

View File

@ -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)