diff --git a/ntfy/App/AppMain.swift b/ntfy/App/AppMain.swift index a30d5e0..2cd58cb 100644 --- a/ntfy/App/AppMain.swift +++ b/ntfy/App/AppMain.swift @@ -2,7 +2,6 @@ import SwiftUI import Firebase // TODO: Verify whether model version needs to be specified -// TODO: Disallow adding same topic twice!! // TODO: Errors are not shown to the user, but instead just logged @main diff --git a/ntfy/Views/NotificationListView.swift b/ntfy/Views/NotificationListView.swift index f205b61..5f145fd 100644 --- a/ntfy/Views/NotificationListView.swift +++ b/ntfy/Views/NotificationListView.swift @@ -1,4 +1,5 @@ import SwiftUI +import UniformTypeIdentifiers enum ActiveAlert { case clear, unsubscribe, selected @@ -282,6 +283,10 @@ struct NotificationRowView: View { } } .padding(.all, 4) + .onTapGesture { + // TODO: This gives no feedback to the user, and it only works if the text is tapped + UIPasteboard.general.setValue(notification.formatMessage(), forPasteboardType: UTType.plainText.identifier) + } } } diff --git a/ntfy/Views/SubscriptionAddView.swift b/ntfy/Views/SubscriptionAddView.swift index 4130d2c..692e2e6 100644 --- a/ntfy/Views/SubscriptionAddView.swift +++ b/ntfy/Views/SubscriptionAddView.swift @@ -50,7 +50,14 @@ struct SubscriptionAddView: View { private func isValid(topic: String) -> Bool { let sanitizedTopic = sanitize(topic: topic) - return !sanitizedTopic.isEmpty && (sanitizedTopic.range(of: "^[-_A-Za-z0-9]{1,64}$", options: .regularExpression, range: nil, locale: nil) != nil) + if sanitizedTopic.isEmpty { + return false + } else if sanitizedTopic.range(of: "^[-_A-Za-z0-9]{1,64}$", options: .regularExpression, range: nil, locale: nil) == nil { + return false + } else if store.getSubscription(baseUrl: Config.appBaseUrl, topic: topic) != nil { + return false + } + return true } private func subscribeAction() {