Use correct account method for adding folders

This commit is contained in:
Maurice Parker 2019-09-27 06:38:43 -05:00
parent 3464fbfc7f
commit 6536dbf2a5
4 changed files with 34 additions and 7 deletions

View File

@ -426,7 +426,7 @@ public final class Account: DisplayNameProvider, UnreadCountProvider, Container,
}
@discardableResult
public func ensureFolder(with name: String) -> Folder? {
func ensureFolder(with name: String) -> Folder? {
// TODO: support subfolders, maybe, some day
if name.isEmpty {

View File

@ -72,7 +72,15 @@ class AddFolderWindowController : NSWindowController {
return
}
account.ensureFolder(with: folderName)
account.addFolder(folderName) { result in
switch result {
case .success:
break
case .failure(let error):
NSApplication.shared.presentError(error)
}
}
}
// MARK: Actions

View File

@ -76,11 +76,20 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
print("support for folders within folders is NYI");
return nil
}
let scriptableAccount = ScriptableAccount(account)
if let newFolder = account.ensureFolder(with:name) {
let scriptableFolder = ScriptableFolder(newFolder, container:scriptableAccount)
return(scriptableFolder.objectSpecifier)
}
command.suspendExecution()
account.addFolder(name) { result in
switch result {
case .success(let folder):
let scriptableAccount = ScriptableAccount(account)
let scriptableFolder = ScriptableFolder(folder, container:scriptableAccount)
command.resumeExecution(withResult:scriptableFolder.objectSpecifier)
case .failure:
command.resumeExecution(withResult:nil)
}
}
return nil
}

View File

@ -28,6 +28,16 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "849C64701ED37A5D003D8FC0"
BuildableName = "NetNewsWireTests.xctest"
BlueprintName = "NetNewsWireTests"
ReferencedContainer = "container:NetNewsWire.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction