Do not allow adding same topic again
This commit is contained in:
parent
61110a51fb
commit
fa14c22413
3 changed files with 13 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue