Temporarily disable AddFeedIntentHandler — it’s causing a build failure.

This commit is contained in:
Brent Simmons 2024-02-25 23:14:37 -08:00
parent d173b04d0c
commit f4fae47fda
2 changed files with 122 additions and 122 deletions

View File

@ -21,123 +21,123 @@ public enum AddFeedIntentHandlerError: LocalizedError {
} }
public class AddFeedIntentHandler: NSObject, AddFeedIntentHandling { //public class AddFeedIntentHandler: NSObject, AddFeedIntentHandling {
//
override init() { // override init() {
super.init() // super.init()
} // }
//
public func resolveUrl(for intent: AddFeedIntent, with completion: @escaping (AddFeedUrlResolutionResult) -> Void) { // public func resolveUrl(for intent: AddFeedIntent, with completion: @escaping (AddFeedUrlResolutionResult) -> Void) {
guard let url = intent.url else { // guard let url = intent.url else {
completion(.unsupported(forReason: .required)) // completion(.unsupported(forReason: .required))
return // return
} // }
completion(.success(with: url)) // completion(.success(with: url))
} // }
//
public func provideAccountNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) { // public func provideAccountNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) {
guard let extensionContainers = ExtensionContainersFile.read() else { // guard let extensionContainers = ExtensionContainersFile.read() else {
completion(nil, AddFeedIntentHandlerError.communicationFailure) // completion(nil, AddFeedIntentHandlerError.communicationFailure)
return // return
} // }
//
let accountNames = extensionContainers.accounts.map { $0.name } // let accountNames = extensionContainers.accounts.map { $0.name }
completion(accountNames, nil) // completion(accountNames, nil)
} // }
//
public func resolveAccountName(for intent: AddFeedIntent, with completion: @escaping (AddFeedAccountNameResolutionResult) -> Void) { // public func resolveAccountName(for intent: AddFeedIntent, with completion: @escaping (AddFeedAccountNameResolutionResult) -> Void) {
guard let accountName = intent.accountName else { // guard let accountName = intent.accountName else {
completion(AddFeedAccountNameResolutionResult.notRequired()) // completion(AddFeedAccountNameResolutionResult.notRequired())
return // return
} // }
//
guard let extensionContainers = ExtensionContainersFile.read() else { // guard let extensionContainers = ExtensionContainersFile.read() else {
completion(.unsupported(forReason: .communication)) // completion(.unsupported(forReason: .communication))
return // return
} // }
//
if extensionContainers.findAccount(forName: accountName) == nil { // if extensionContainers.findAccount(forName: accountName) == nil {
completion(.unsupported(forReason: .invalid)) // completion(.unsupported(forReason: .invalid))
} else { // } else {
completion(.success(with: accountName)) // completion(.success(with: accountName))
} // }
} // }
//
public func provideFolderNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) { // public func provideFolderNameOptions(for intent: AddFeedIntent, with completion: @escaping ([String]?, Error?) -> Void) {
guard let extensionContainers = ExtensionContainersFile.read() else { // guard let extensionContainers = ExtensionContainersFile.read() else {
completion(nil, AddFeedIntentHandlerError.communicationFailure) // completion(nil, AddFeedIntentHandlerError.communicationFailure)
return // return
} // }
//
guard let accountName = intent.accountName, let account = extensionContainers.findAccount(forName: accountName) else { // guard let accountName = intent.accountName, let account = extensionContainers.findAccount(forName: accountName) else {
completion([String](), nil) // completion([String](), nil)
return // return
} // }
//
let folderNames = account.folders.map { $0.name } // let folderNames = account.folders.map { $0.name }
completion(folderNames, nil) // completion(folderNames, nil)
} // }
//
public func resolveFolderName(for intent: AddFeedIntent, with completion: @escaping (AddFeedFolderNameResolutionResult) -> Void) { // public func resolveFolderName(for intent: AddFeedIntent, with completion: @escaping (AddFeedFolderNameResolutionResult) -> Void) {
guard let accountName = intent.accountName, let folderName = intent.folderName else { // guard let accountName = intent.accountName, let folderName = intent.folderName else {
completion(AddFeedFolderNameResolutionResult.notRequired()) // completion(AddFeedFolderNameResolutionResult.notRequired())
return // return
} // }
//
guard let extensionContainers = ExtensionContainersFile.read() else { // guard let extensionContainers = ExtensionContainersFile.read() else {
completion(.unsupported(forReason: .communication)) // completion(.unsupported(forReason: .communication))
return // return
} // }
//
guard let account = extensionContainers.findAccount(forName: accountName) else { // guard let account = extensionContainers.findAccount(forName: accountName) else {
completion(.unsupported(forReason: .invalid)) // completion(.unsupported(forReason: .invalid))
return // return
} // }
//
if account.findFolder(forName: folderName) == nil { // if account.findFolder(forName: folderName) == nil {
completion(.unsupported(forReason: .invalid)) // completion(.unsupported(forReason: .invalid))
} else { // } else {
completion(.success(with: folderName)) // completion(.success(with: folderName))
} // }
return // return
//
} // }
//
public func handle(intent: AddFeedIntent, completion: @escaping (AddFeedIntentResponse) -> Void) { // public func handle(intent: AddFeedIntent, completion: @escaping (AddFeedIntentResponse) -> Void) {
guard let url = intent.url, let extensionContainers = ExtensionContainersFile.read() else { // guard let url = intent.url, let extensionContainers = ExtensionContainersFile.read() else {
completion(AddFeedIntentResponse(code: .failure, userActivity: nil)) // completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
return // return
} // }
//
let account: ExtensionAccount? = { // let account: ExtensionAccount? = {
if let accountName = intent.accountName { // if let accountName = intent.accountName {
return extensionContainers.findAccount(forName: accountName) // return extensionContainers.findAccount(forName: accountName)
} else { // } else {
return extensionContainers.accounts.first // return extensionContainers.accounts.first
} // }
}() // }()
//
guard let validAccount = account else { // guard let validAccount = account else {
completion(AddFeedIntentResponse(code: .failure, userActivity: nil)) // completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
return // return
} // }
//
let container: ExtensionContainer? = { // let container: ExtensionContainer? = {
if let folderName = intent.folderName { // if let folderName = intent.folderName {
return validAccount.findFolder(forName: folderName) // return validAccount.findFolder(forName: folderName)
} else { // } else {
return validAccount // return validAccount
} // }
}() // }()
//
guard let validContainer = container, let containerID = validContainer.containerID else { // guard let validContainer = container, let containerID = validContainer.containerID else {
completion(AddFeedIntentResponse(code: .failure, userActivity: nil)) // completion(AddFeedIntentResponse(code: .failure, userActivity: nil))
return // return
} // }
//
let request = ExtensionFeedAddRequest(name: nil, feedURL: url, destinationContainerID: containerID) // let request = ExtensionFeedAddRequest(name: nil, feedURL: url, destinationContainerID: containerID)
ExtensionFeedAddRequestFile.save(request) // ExtensionFeedAddRequestFile.save(request)
completion(AddFeedIntentResponse(code: .success, userActivity: nil)) // completion(AddFeedIntentResponse(code: .success, userActivity: nil))
} // }
//
} //}

View File

@ -12,8 +12,8 @@ class IntentHandler: INExtension {
override func handler(for intent: INIntent) -> Any { override func handler(for intent: INIntent) -> Any {
switch intent { switch intent {
case is AddFeedIntent: // case is AddFeedIntent:
return AddFeedIntentHandler() // return AddFeedIntentHandler()
default: default:
fatalError("Unhandled intent type: \(intent)") fatalError("Unhandled intent type: \(intent)")
} }