Fix build errors.

This commit is contained in:
Brent Simmons 2017-11-04 19:29:43 -07:00
parent 17e22fb91a
commit 66c02a6fe1
2 changed files with 40 additions and 18 deletions

View File

@ -15,11 +15,11 @@ import Data
final class DeleteFromSidebarCommand: UndoableCommand { final class DeleteFromSidebarCommand: UndoableCommand {
private struct ActionName { private struct ActionName {
static private let deleteFeed = NSLocalizedString("Delete Feed", comment: "command") static let deleteFeed = NSLocalizedString("Delete Feed", comment: "command")
static private let deleteFeeds = NSLocalizedString("Delete Feeds", comment: "command") static let deleteFeeds = NSLocalizedString("Delete Feeds", comment: "command")
static private let deleteFolder = NSLocalizedString("Delete Folder", comment: "command") static let deleteFolder = NSLocalizedString("Delete Folder", comment: "command")
static private let deleteFolders = NSLocalizedString("Delete Folders", comment: "command") static let deleteFolders = NSLocalizedString("Delete Folders", comment: "command")
static private let deleteFeedsAndFolders = NSLocalizedString("Delete Feeds and Folders", comment: "command") static let deleteFeedsAndFolders = NSLocalizedString("Delete Feeds and Folders", comment: "command")
} }
let undoActionName: String let undoActionName: String
@ -104,31 +104,55 @@ final class DeleteFromSidebarCommand: UndoableCommand {
private struct SidebarItemSpecifier { private struct SidebarItemSpecifier {
weak var account: Account? weak var account: Account?
let node: Node
let folder: Folder? let folder: Folder?
let feed: Feed? let feed: Feed?
let path: ContainerPath let path: ContainerPath
init?(node: Node) { init?(node: Node) {
self.node = node
var account: Account? var account: Account?
if let feed = node.representedObject as? Feed { if let feed = node.representedObject as? Feed {
self.feed = feed self.feed = feed
account = feed.account self.folder = nil
account = feed.account
} }
else if let folder = node.representedObject as? Folder { else if let folder = node.representedObject as? Folder {
self.feed = nil
self.folder = folder self.folder = folder
account = folder.account account = folder.account
} }
else {
return nil
}
if account == nil {
return nil
}
guard let account = account else { self.account = account!
return nil self.path = ContainerPath(account: account!, folders: node.containingFolders())
}
self.account = account
self.path = SidebarPath(account: account, node: node)
} }
} }
private extension Node {
func containingFolders() -> [Folder] {
var nomad = self.parent
var folders = [Folder]()
while nomad != nil {
if let folder = nomad!.representedObject as? Folder {
folders += [folder]
}
else {
break
}
nomad = nomad!.parent
}
return folders.reversed()
}
}

View File

@ -27,9 +27,7 @@ public struct ContainerPath {
self.names = folders.map { $0.nameForDisplay } self.names = folders.map { $0.nameForDisplay }
self.isTopLevel = folders.isEmpty self.isTopLevel = folders.isEmpty
if let lastFolder = folders.last { self.folderID = folders.last?.folderID
self.folderID = lastFolder.folderID
}
} }
public func resolveContainer() -> Container? { public func resolveContainer() -> Container? {