mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-03 05:21:55 +01:00
Temporarily disable AddFeedIntentHandler — it’s causing a build failure.
This commit is contained in:
parent
d173b04d0c
commit
f4fae47fda
@ -21,123 +21,123 @@ public enum AddFeedIntentHandlerError: LocalizedError {
|
||||
|
||||
}
|
||||
|
||||
public class AddFeedIntentHandler: NSObject, AddFeedIntentHandling {
|
||||
|
||||
override init() {
|
||||
super.init()
|
||||
}
|
||||
|
||||
public func resolveUrl(for intent: AddFeedIntent, with completion: @escaping (AddFeedUrlResolutionResult) -> Void) {
|
||||
guard let url = intent.url else {
|
||||
completion(.unsupported(forReason: .required))
|
||||
return
|
||||
}
|
||||
completion(.success(with: url))
|
||||
}
|
||||
|
||||
public func provideAccountNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) {
|
||||
guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
completion(nil, AddFeedIntentHandlerError.communicationFailure)
|
||||
return
|
||||
}
|
||||
|
||||
let accountNames = extensionContainers.accounts.map { $0.name }
|
||||
completion(accountNames, nil)
|
||||
}
|
||||
|
||||
public func resolveAccountName(for intent: AddFeedIntent, with completion: @escaping (AddFeedAccountNameResolutionResult) -> Void) {
|
||||
guard let accountName = intent.accountName else {
|
||||
completion(AddFeedAccountNameResolutionResult.notRequired())
|
||||
return
|
||||
}
|
||||
|
||||
guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
completion(.unsupported(forReason: .communication))
|
||||
return
|
||||
}
|
||||
|
||||
if extensionContainers.findAccount(forName: accountName) == nil {
|
||||
completion(.unsupported(forReason: .invalid))
|
||||
} else {
|
||||
completion(.success(with: accountName))
|
||||
}
|
||||
}
|
||||
|
||||
public func provideFolderNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) {
|
||||
guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
completion(nil, AddFeedIntentHandlerError.communicationFailure)
|
||||
return
|
||||
}
|
||||
|
||||
guard let accountName = intent.accountName, let account = extensionContainers.findAccount(forName: accountName) else {
|
||||
completion([String](), nil)
|
||||
return
|
||||
}
|
||||
|
||||
let folderNames = account.folders.map { $0.name }
|
||||
completion(folderNames, nil)
|
||||
}
|
||||
|
||||
public func resolveFolderName(for intent: AddFeedIntent, with completion: @escaping (AddFeedFolderNameResolutionResult) -> Void) {
|
||||
guard let accountName = intent.accountName, let folderName = intent.folderName else {
|
||||
completion(AddFeedFolderNameResolutionResult.notRequired())
|
||||
return
|
||||
}
|
||||
|
||||
guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
completion(.unsupported(forReason: .communication))
|
||||
return
|
||||
}
|
||||
|
||||
guard let account = extensionContainers.findAccount(forName: accountName) else {
|
||||
completion(.unsupported(forReason: .invalid))
|
||||
return
|
||||
}
|
||||
|
||||
if account.findFolder(forName: folderName) == nil {
|
||||
completion(.unsupported(forReason: .invalid))
|
||||
} else {
|
||||
completion(.success(with: folderName))
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
public func handle(intent: AddFeedIntent, completion: @escaping (AddFeedIntentResponse) -> Void) {
|
||||
guard let url = intent.url, let extensionContainers = ExtensionContainersFile.read() else {
|
||||
completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
|
||||
return
|
||||
}
|
||||
|
||||
let account: ExtensionAccount? = {
|
||||
if let accountName = intent.accountName {
|
||||
return extensionContainers.findAccount(forName: accountName)
|
||||
} else {
|
||||
return extensionContainers.accounts.first
|
||||
}
|
||||
}()
|
||||
|
||||
guard let validAccount = account else {
|
||||
completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
|
||||
return
|
||||
}
|
||||
|
||||
let container: ExtensionContainer? = {
|
||||
if let folderName = intent.folderName {
|
||||
return validAccount.findFolder(forName: folderName)
|
||||
} else {
|
||||
return validAccount
|
||||
}
|
||||
}()
|
||||
|
||||
guard let validContainer = container, let containerID = validContainer.containerID else {
|
||||
completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
|
||||
return
|
||||
}
|
||||
|
||||
let request = ExtensionFeedAddRequest(name: nil, feedURL: url, destinationContainerID: containerID)
|
||||
ExtensionFeedAddRequestFile.save(request)
|
||||
completion(AddFeedIntentResponse(code: .success, userActivity: nil))
|
||||
}
|
||||
|
||||
}
|
||||
//public class AddFeedIntentHandler: NSObject, AddFeedIntentHandling {
|
||||
//
|
||||
// override init() {
|
||||
// super.init()
|
||||
// }
|
||||
//
|
||||
// public func resolveUrl(for intent: AddFeedIntent, with completion: @escaping (AddFeedUrlResolutionResult) -> Void) {
|
||||
// guard let url = intent.url else {
|
||||
// completion(.unsupported(forReason: .required))
|
||||
// return
|
||||
// }
|
||||
// completion(.success(with: url))
|
||||
// }
|
||||
//
|
||||
// public func provideAccountNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) {
|
||||
// guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
// completion(nil, AddFeedIntentHandlerError.communicationFailure)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// let accountNames = extensionContainers.accounts.map { $0.name }
|
||||
// completion(accountNames, nil)
|
||||
// }
|
||||
//
|
||||
// public func resolveAccountName(for intent: AddFeedIntent, with completion: @escaping (AddFeedAccountNameResolutionResult) -> Void) {
|
||||
// guard let accountName = intent.accountName else {
|
||||
// completion(AddFeedAccountNameResolutionResult.notRequired())
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
// completion(.unsupported(forReason: .communication))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if extensionContainers.findAccount(forName: accountName) == nil {
|
||||
// completion(.unsupported(forReason: .invalid))
|
||||
// } else {
|
||||
// completion(.success(with: accountName))
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public func provideFolderNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) {
|
||||
// guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
// completion(nil, AddFeedIntentHandlerError.communicationFailure)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// guard let accountName = intent.accountName, let account = extensionContainers.findAccount(forName: accountName) else {
|
||||
// completion([String](), nil)
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// let folderNames = account.folders.map { $0.name }
|
||||
// completion(folderNames, nil)
|
||||
// }
|
||||
//
|
||||
// public func resolveFolderName(for intent: AddFeedIntent, with completion: @escaping (AddFeedFolderNameResolutionResult) -> Void) {
|
||||
// guard let accountName = intent.accountName, let folderName = intent.folderName else {
|
||||
// completion(AddFeedFolderNameResolutionResult.notRequired())
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// guard let extensionContainers = ExtensionContainersFile.read() else {
|
||||
// completion(.unsupported(forReason: .communication))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// guard let account = extensionContainers.findAccount(forName: accountName) else {
|
||||
// completion(.unsupported(forReason: .invalid))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// if account.findFolder(forName: folderName) == nil {
|
||||
// completion(.unsupported(forReason: .invalid))
|
||||
// } else {
|
||||
// completion(.success(with: folderName))
|
||||
// }
|
||||
// return
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public func handle(intent: AddFeedIntent, completion: @escaping (AddFeedIntentResponse) -> Void) {
|
||||
// guard let url = intent.url, let extensionContainers = ExtensionContainersFile.read() else {
|
||||
// completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// let account: ExtensionAccount? = {
|
||||
// if let accountName = intent.accountName {
|
||||
// return extensionContainers.findAccount(forName: accountName)
|
||||
// } else {
|
||||
// return extensionContainers.accounts.first
|
||||
// }
|
||||
// }()
|
||||
//
|
||||
// guard let validAccount = account else {
|
||||
// completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// let container: ExtensionContainer? = {
|
||||
// if let folderName = intent.folderName {
|
||||
// return validAccount.findFolder(forName: folderName)
|
||||
// } else {
|
||||
// return validAccount
|
||||
// }
|
||||
// }()
|
||||
//
|
||||
// guard let validContainer = container, let containerID = validContainer.containerID else {
|
||||
// completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// let request = ExtensionFeedAddRequest(name: nil, feedURL: url, destinationContainerID: containerID)
|
||||
// ExtensionFeedAddRequestFile.save(request)
|
||||
// completion(AddFeedIntentResponse(code: .success, userActivity: nil))
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
@ -12,8 +12,8 @@ class IntentHandler: INExtension {
|
||||
|
||||
override func handler(for intent: INIntent) -> Any {
|
||||
switch intent {
|
||||
case is AddFeedIntent:
|
||||
return AddFeedIntentHandler()
|
||||
// case is AddFeedIntent:
|
||||
// return AddFeedIntentHandler()
|
||||
default:
|
||||
fatalError("Unhandled intent type: \(intent)")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user